Your rating has been changed, thanks for rating!

You have already rated this page, you can only rate it once!

Thank you for rating!

This article shows how to use system utility fsck to repair file system in few simple steps.

Boot the system into a single-user mode

This must be selected in the boot menu:

Press 4 to select single-user mode in FreeBSD 8;

Press 6 then Enter to select single-user mode in FreeBSD 9.

Similar step is described in the article How to reset root password in FreeBSD, but with illustration.

While the system loads in a single-user mode the following message is shown:

Enter full pathname of shell or RETURN for /bin/sh:

Press Enter to run the shell.

Check which file systems are mounted

The following command is especially designed for this purpose:

mount

The output should look something like this:

/dev/ada0s1a on / (ufs, local, read-only) devfs on /dev (devfs, local)

Make sure that only "/" (root file system) and devices under "/dev" are mounted. Also the root file system must be mounted in the read-only mode.

Read-only is the simplest and safest possible mode for the system.

Since the file systems are not mounted, the system utility fsck ("file system check") can be run on them.

Have a look at the list of normally mounted partitions

Now have a look at the partitions which are normally mounted. The /etc/fstab file contains this information.

cat /etc/fstab

Output:

/dev/ada0s1a / ufs rw 1 1 /dev/ada0s1b none swap sw 0 0 /dev/ada0s1d /var ufs rw 2 2 /dev/ada0s1e /tmp ufs rw 2 2 /dev/ada0s1f /usr ufs rw 2 2

Run fsck for the needed partitions

Choose one of these partitions, and run fsck on it. For example, to check the partition "/dev/ada0s1a", run the following command:

fsck -y /dev/ada0s1a

The -y option gives fsck permission to carry out any repairs it suggests.