Monday, April 9, 2012

HowTo: fsck an ext2 partition in FreeBSD

The fsck available in FreeBSD's base system doesn't work on Linux file formats such as ext2 and ext3. For that end one first needs to install sysutils/e2fsprogs.

Bellow I'll explain how to install sysutils/e2fsprogs and use the supplied fsck.ext2 on a ext2 partition.

First, install the port:
$ su
# cd /usr/ports/sysutils/e2fsprogs
# make install clean
# rehash

Now the fsck.ext2, fsck.ext3 and fsck.ext4 commands are available. Assuming the /dev/ad4s1 as being the faulty partition, run:

# fsck.ext2 /dev/ad4s1
e2fsck 1.42 (29-Nov-2011)
/dev/ad4s1 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/ad4s1: 37/10040 files (13.5% non-contiguous), 13062/40128 blocks

And that's it ;)

No comments: