Tuesday, January 25, 2011

running automated fsck on remote server

I had another question about df, and now i came to conclusion i need to run fsck my partition, i've been reading about it and would like some advice, if possible.

The situation is like this, no physical access to the server and i want to run fsck.

from what i read i just need to touch /forcefsck and when i reboot it will run fsck.

My question is, at its basis, with what arguments will the fsck run? Will it need user input to correct errors, etc?

and after running will it save a log of what happened?

if this was how it ran it would be perfect, anyway of enforcing that on reboot?

fsck -v -p /machine/disk/p1 2>&1 > fscklog.txt

Also here they describe this:

it's also a good idea on debian and debian-derivatives like ubuntu to edit /etc/default/rcS on remote servers and set "FSCKFIX=yes" that adds "-y" to the boot time fsck, so it doesn't risk the remote server being stuck waiting for someone to login at the console and run fsck.

But on Centos that doesn't seem to exist

I only have ssh access at the moment so that is why i'm being so picky with it.

here's some info about disks and mounted volumes on the server: http://pastebin.centos.org/33314

Thanks.

  • You set "autofsck" settings in CentOS/Redhat differently then in other distros. You should edit /etc/sysconfig/autofsck with the settings that you want, as described in this mailing list post: http://lists.centos.org/pipermail/centos/2006-November/029837.html

    GriffinHeart : seems that would work also, though i find /forcefsck and /fsckoptions easier to remember. Thanks
    From Cory J
  • Ok, so i found out on CentOS you can do this:

    touch /forcefsck
    echo -n "-ys" > /fsckoptions
    

    to get a log of what fsck did i had to go on a harder route:
    Warning: do this at your own risk, i have no ideia of what implications this could have if goes wrong

    Edited the /etc/rc.sysinit (don't forget to backup) to get the desired behaviour:

    from line 500 (changing the -C to -V gets rid of progress bars)

    if [ "$BOOTUP" = "color" ]; then
           fsckoptions="-C $fsckoptions"
    else
           fsckoption="-V $fsckoptions"
    

    from line 648 changed the block that ran fsck to look like this:

    outputtt="$(fsck -T -t noopts=_netdev -A $fsckoptions)"
    mount -n -o remount,rw /
    echo $outputtt > /var/log/fsckoutput
    mount -n -o remount,ro /
    

    one small perk is that it won't conserve new lines, but its readable in times of dire need.
    Thanks for all the help.

0 comments:

Post a Comment