Hi, Is it possible to automate the process of running fsck -y after a power or other type of failure, in cases the automatic file system check fails? Thanks in advance. Regards, Jose -- An Excellent Credit Score is 750 See Yours in Just 2 Easy Steps!
Jose, this is an ugly modification in /etc/rc but it should do what you
need.
Search for the line that starts with 8) and modify it to look like this:
8)
echo "Corro FSCK de emergencia..."
fsck -y ; fsck_st=$?
if [ $fsck_st != 0 ]; then
echo "Automatic file system check failed; help!"
exit 1
fi
;;
Regards,
Marcos
If that was a wisething to do, we would have already done so. In other words, it is not wise. It's foolish. -Otto
as usually, i absolutely agree with you Otto. however. please all the people in the room raise their hands who have the faintest idea about what 95% of the questions that fsck is going to ask them on a seriously borked fs mean. my hat goes off to them. here's the thing: even though every single diagnostic message fsck may produce is documented in /usr/share/doc/smm/03.fsck_ffs i dont see how these questions help at all. what i mean is, there is nothing to compare the diagnostic data to anyway, so what is the answer going to be based on? so far i have always only took the leap of faith and pressed yes or always.. what else is there to do? a couple of months ago, after a certain incident on my notebook i was presented with a borked suberblock and after i have figured out that the backup superblock were usable, i just crossed my fingers and after a dry run i started fsck. i got some 7700 'UNKNOWN FILE TYPE's, an unallocated root inode, bad magic numbers for CGs and fsck messages i have never had the luck meeting with before... (should read 03.fsck_ffs one of these days probably -- but even then, i would just say yes on every question) unfortunately i dont have a transcript of that fsck session, i do however have a "screenshot" of the last phase: ** Phase 5 - Check Cyl groups CG 0: BAD MAGIC NUMBER FREE BLK COUNT(S) WRONG IN SUPERBLK SALVAGE? yes SUMMARY INFORMATION BAD SALVAGE? yes BLK(S) MISSING IN BIT MAPS SALVAGE? yes 118774 files, 4966785 used, 2542705 free (17073 frags, 315704 blocks, 0.2% fragmentation) UPDATE STANDARD SUPERBLOCK? yes MARK FILE SYSTEM CLEAN? yes ***** FILE SYSTEM WAS MODIFIED ***** (for the curious: all my files survived under lost+found. i was as happy as it can be) if fsck thinks there is a problem, there is nothing left but to press y anyway. although i'd very much like to read stories of other admins doing otherwise. -f -- atheism is a non-prophet organization.
Put a rock on the 'y' key and go get some coffee.
make a dump of the partition before going to execute potentially data destroying actions?
So you can dump a botched filesystem? The manpage says nothing about that... Well it doesn't say the contrary but... So, question is: Can you *really* dump a "borked fs"? -- Mauro Rezzonico <mauro@ch23.org>, Como, Italia "Maybe this world is another planet's hell" - H.Huxley
On Sat, 03 Oct 2009 00:12:39 +0200 Think 'dd', to have a second chance at messing up the data, or work from the image to restore files. (See what i did there? ;) -Robert
Note that I said "dump the partition", not "dump the filesystem". -Otto
Oops. you mean dd(1)... sorry for the noise -- Mauro Rezzonico <mauro@ch23.org>, Como, Italia "Maybe this world is another planet's hell" - H.Huxley
yes, this is sound advice of course. but what are you going to do with the dump if say, fsck is not able to revive the fs? "dump" it back, run fsck again and answer "no" at a couple of fsck prompts? how is it going to change anything in the end? -f -- forget everything, as one day everything will forget you.
You have several options: consult an expert and indeed answer n to some of the prompts, mount -f the fs and recover your most important files, use the image as a test case to improve fsck_ffs... there are probably more cases why having a dump of the inconsistent fs can be good. -Otto
Well, if fsck can't revive your partition, you can always try different tools. Something like fsdb may be able to recover part or all of your filesystem even in cases where fsck loses the plot. There is also the Sleuth kit. And if all else fails, you can always write your own software/grep through the raw disk/etc. fsck is great at what it does, but it's not the only game in town. Needless to say, restoring from backup is easier than reconstructing a filesystem from a hex dump of the disk. But sometimes you don't have backups... Joachim
Also, fsck may fail in the middle due to lack of memory, so moving the dump to a bigger box to make it run through may be a good solution in that case. Or old fsck fails where a -current fsck won't.
What does fsck mean? I always thought it was those strange bearded sysadmins private cuss word as they always seem to scream *fsck yes damnit!!!* whenever the system crashes.... -- Sent from my mobile device http://www.glumbert.com/media/shift http://www.youtube.com/watch?v=tGvHNNOLnCk "This officer's men seem to follow him merely out of idle curiosity." -- Sandhurst officer cadet evaluation. "Securing an environment of Windows platforms from abuse - external or internal - is akin to trying to install sprinklers in a fireworks factory where smoking on the job is permitted." -- Gene Spafford learn french: http://www.youtube.com/watch?v=30v_g83VHK4
