Mounting a big ext2fs partition on a USB drive in FreeBSD

Originally posted on December 14, 2008.

I have a Maxtor OneTouch 4 Plus external USB drive, 750gb, that I wanted to connect to my home server running FreeBSD 7.0. I planned on using the drive for holding music and media, using the FreeBSD server as a media hub running Mediatomb and NFS/SMB shares.

In planning the venture, I needed the hard drive’s format to be as universally compatible and as universally stable as possible. I needed to be able to reliably interact with the drive under FreeBSD and Linux, as well as OS X and Windows (should the need ever arise, I want to be ready).

After some thought, I ended up settling on ext2 for the drive’s file system. I chose ext2 because:

So, I plugged the drive into an Ubuntu Ibex box, formatted it into one ext2 partition and plugged it in to the FreeBSD box.

mount -t ext2fs /dev/da0s1 /mnt/media

So far, so good. The output of the mount command shows that the drive is there and mounted. But then:

cd /mnt
ls -la
ls: media: Bad file descriptor

For some reason, the mount point could not be listed.

After some research, I came across this bug report that described the problem in greater detail. Basically, newer versions of Linux seem to format ext2fs partitions using a 256-byte inode size, versus the previous default of 128 bytes, which is what the FreeBSD ext2fs driver expects it to be.

Fixing The Problem

To fix it, you’ll apply a patch by Josh Carroll, who posted it in the bug report linked above. Under a standard FreeBSD 7.0 installations, the commands will be something like this (as root):

cd /usr/src/sys/gnu/fs
cp -R ext2fs ext2fs.orig
cd ext2fs
fetch https://neveradudelikethisone.com/files/ext2fs.diff
patch <ext2fs.diff
cd /usr/src
make buildkernel KERNCONF=GENERIC && make installkernel KERNCONF=GENERIC

If all goes well, you should then be able to restart, mount the drive, and have it work as expected. Good luck!