Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have filesystem problems on a machine running Ubuntu 8.04 machine in a colocation facility. What was once a directory now looks like this:

b--xr-SrwT 52 825452087 876163170 56, 97 2021-10-10 05:43 58

This was cache data, so I don't mind the data loss, I just want to fix the filesystem. The problem is, this is the root filesystem, so I can't unmount it to run fsck.

So my question is: How do I run fsck on the root filesystem without having to drive all the way to the colocation center?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted
shutdown -rF now

Should force a fsck of all disks in /etc/fstab on reboot. link: man shutdown

Alternatively, if you want a fsck on every reboot:

cd /
touch forcefsck
reboot
share|improve this answer
    
The -F option is not mentioned in the shutdown man page on my Ubuntu. Does this also fix all problems without prompting? I'd hate for it to get stuck waiting for user input. –  itsadok Sep 7 '09 at 9:18
    
mmmm, I unfortunately don't have a Ubuntu box open for this sort of test. I assume that the forced fsck would be like any other fsck check after X reboots in which it will automatically fsck without user input. Perhaps, you could install it in a VM and test the functionality. –  David Rickman Sep 7 '09 at 10:10
    
I did a glance over on the differences in shutdown in Ubuntu 8.04 and Ubuntu 9.04. It was quite large: manpages.ubuntu.com/manpages/intrepid/en/man8/shutdown.8.html manpages.ubuntu.com/manpages/jaunty/man8/shutdown.8.html Two totally different packages provide everything now. –  David Rickman Sep 7 '09 at 10:12
    
I should have read the man page you linked to, it specifically says that the -F flag simply creates the forcefsck file on the root directory. –  itsadok Sep 7 '09 at 10:45
    
Ubuntu has no -F flag, so do it manually: sudo touch /forcefsck ; sudo shutdown -r now –  jeckyll2hide Apr 17 at 5:04
add comment

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.

also, just in case something like happens again, it's worthwhile having a rescue partition that you can boot (e.g. temporarily set grub's default), ssh into, and run fsck on your real rootfs. if you don't currently have a spare partition free for this, you can shrink a swap partition to give yourself enough space to make a rescue partition (which you can populate with debootstrap).

and if you can't use a swap partition, you can set up a grub entry to boot into a live cd image (using the kernel and initrd from the iso)...but you'll have to modify the initrd filesystem to have your correct IP address etc and make sure that sshd is running. clonezilla, gparted or systemrescuecd would make good live systems to use as a base for this. your /boot partition/directory needs to be big enough to hold these files.

share|improve this answer
    
I'm making note of that. I know a small debian install can be less than 512MB, so it is easily do-able without much loss to the hard drive space. –  David Rickman Sep 7 '09 at 11:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.