LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to perform an e2fsck -y on only two volumes at restart (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-perform-an-e2fsck-y-on-only-two-volumes-at-restart-867727/)

rjo98 03-10-2011 11:00 AM

How to perform an e2fsck -y on only two volumes at restart
 
I want to perform an e2fsck with the y switch (so I dont have to answer yes to every question) on two volumes on a server the next time I restart it.

I don't want to do a shutdown -rF because 1) I dont want to check the other volumes and 2) it seems when I do that, the e2fsck doesn't keep restarting itself over and over to fix all the problems. Seems like it runs once, then if it fails it drops you to the repair console in single user mode. I'd rather just have it start the check that will keep repeating over and over right away, because I know it'll take more than one pass.

Can anyone tell me how to do this, or confirm my observations?

business_kid 03-10-2011 12:59 PM

Append to rc.local

echo "Checking Drive 1"
e2fsck -fcvy /dev/drive1 > logfile 2>&1
echo "Checking Drive 2"
e2fsck -fcvy /dev/drive2 >> logfile 2>&1


Options: f=force check; c=check surface with badblocks; v=say something; y=yes, do it.
When it finally boots, remove the offending lines from rc.local.

Alternatively play with tune2fs. Man tune2fs

rjo98 03-10-2011 01:24 PM

thanks. I've messed with tune2fs before to get it to do a check, but it always seems those checks never continually run till its clean, seems like they run for a while then die and drop you into the rescue command line, where you can then do you e2fsck -y which keeps running till its clean.

so that rc.local file runs before all the volumes are mounted, so that's why this would work?

business_kid 03-11-2011 03:42 AM

It runs before you mount any drives, but after the drives in fstab are mounted. You would have to fiddle fstab as well if they are things like / or /var.

The other way is to do it would be something like this. Presuming you know the approximate interval between checks, you can try

tune2fs -T 19750101 /dev/volume1
tune2fs -T 19750101 /dev/volume2

which tells it the system was last checked on 1st January 1975, which is probably longer back than you set as the time check interval :-D. No tidy up after is necessary, as e2fsck updates to the last time checked, but you lose the ability to set e2fsck options without digging through startup stuff.

rjo98 03-11-2011 03:44 AM

that's pretty clever!

Thanks for the info. The volumes i was talking about are in fstab, so i'd have to comment them out first it sounds like if i were to try this. Thanks for the info. I've learned a lot the last couple of days.

business_kid 03-12-2011 03:58 AM

Quote:

Originally Posted by rjo98 (Post 4286609)
that's pretty clever!

Thanks for the info. The volumes i was talking about are in fstab, so i'd have to comment them out first it sounds like if i were to try this. Thanks for the info. I've learned a lot the last couple of days.

I've done my share of suffering. You learn well if there's a bit of pain attached to the lesson - ever notice that? ;-)


All times are GMT -5. The time now is 12:31 AM.