A Couple Ways to Run FSCK on Ubuntu

My server decided that an executable file didn’t really exist on the file system, or so I thought. Lack of sleep was the main problem, but here are some things I did to check my file system for errors. I setup this file system on a Ubuntu 6.06 AMD64 install with LVM, so everything is in LVM instead of standard partitions.

# sudo e2fsck -n /dev/mapper/Ubuntu-root

This was showing errors, but I ran it while the system was mounted and running, so there were open files, so this was normal. The -n kept e2fsck from attempting to fix anything, which was good because later I ran the command after booting from an Ubuntu LiveCD and found no errors.

Before booting from the LiveCD I tried to get the system to fix itself by running fsck on boot. Two methods I used to do this on Ubuntu were running these from the live system before rebooting, they both accomplish the same thing, so only one was really needed.

# sudo touch /forcefsck

# sudo tune2fs -C 40 /dev/mapper/Ubuntu-root

These appeared to have no affect, probably because the filesystem was fine, but I took down the system and ran fsck from a LiveCD instead. Of course, this wasn’t as simple as it should have been, the LiveCD did not detect my LVM volumes, so /dev/mapper/Ubuntu-root was missing. The fix was to install LVM2 and start it up.

# sudo apt-get install lvm2
# sudo /etc/init.d/lvm start

The /dev/mapper/ entries then appeared and I could run all the fscks I wanted. At this point my fsck checks were coming out clean, so file system corruption was not to blame.