Wednesday, February 09, 2011

FreeBSD check disk function

This is a by-product of my portupgrade problem that I posted about yesterday.
As I had initially thought that single-user (SU) mode wasn't available to me, I tried fsck in the GUI mode where all of the slices were actually mounted. Now I know this is not advised in Linux, but apparently it is possible in FreeBSD.
However, once the slices are mounted, any problems detected will NOT be fixed as the slices are not writable to fsck.
I find this useful as you can see what's wrong and what may have caused whatever problems you're seeing.
However, switching from the GUI to a TTY (ctrl-Alt-F1) still doesn't make the slices fixable.
Indeed, in my case I couldn't even unmount them as they all reported a "device is busy" alarm.
Note that I tried to discover which processes are keeping a slice from being unmounted because it's busy by using the fstat command.
So, to see what processes are using the /var slice, just run this command:

$ fstat | grep /var

However, I couldn't get this to work for me.
For example, no processes were shown to be using /tmp and yet when I tried to umount /tmp using
# umount /dev/ad4s3d

I still got the "device is busy" alarm.
Nevertheless, just by rebooting into SU mode, all of my slices, other than the swap slice, were checked and fixed without problem.
Should this problem, or anything similar, happen in the future, I'll certainly include a trip to SU mode and fsck all the slices

No comments:

Post a Comment