Monday, July 9, 2012

Checking root filesystem on ArchLinux

My shiny new ArchLinux on the Pogoplug was complaining about root filesystem not being clean. I tried usual approach of placing /forcefsck file in the root folder and rebooting. Although the file was removed at the next boot the filesystem check still complained.

I went to the IRC to the #arch-linux-arm channel which is recommended on the website, but no one appears to know how to do this on the running system. The only recommendation that I got, was to take out the drive and put it in to another Linux box. Well, this being a USB flash drive makes it possible to do so. But imagine an internal disk and this quickly becomes less than practical solution.

So I went to the "Internets" and did a search. As expected someone already asked this question and got a multitude of answers which helped me to put together a procedure. So here it goes:
  • Execute following command:
    fuser -v -m /
    This will give you a list of all processes having files open on the filesystem. Look for the processes that have F or f flags set. For example:
    root        182 .rce. dhcpcd
    root        197 frce. crond
    root        219 .rce. sshd
    ntp         226 Frce. ntpd
    So it looks like the crond and the ntpd have files open.
  • Shutdown these processes by using following command:
    rc.d stop ntpd
    Shutdown all of the processes that have files open on the filesystem.
  • Now you can remount filesystem using following command:
    mount -r -o remount  / 
    If you correctly shutdown all of the processes remount should complete without any error.
  • At this point you should be able to do a filesystem check:
    e2fsck /dev/sda1 or e2fsck -y /dev/sda1 
I hope that you found this post helpful and it saved you some time.

No comments: