Mounting a big ext2fs partition on a USB drive in FreeBSD

Posted: December 14th, 2008 | Author: Jacob Hammond | Filed under: Uncategorized | 2 Comments »

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:

  • It is fairly universal, in that it can be mounted and used reliably from most OSs.
  • I did not want to use FAT32; plus, FreeBSD’s msdosfs driver could not mount the drive properly (even with the -o large switch).
  • Did not want to use NTFS because of general shakiness on any non-Windows platform.
  • I initially tried UFS, but gave up after repeated failed attempts to get FreeBSD to partition and label it properly. (Not sure why; suspect the drive’s detected geometry may have been an issue.)
  • Considered ZFS but decided I don’t want to be that cutting-edge; plus I wouldn’t have a use for most of its extended functionality. (I just need a basic filesystem.)
  • Considered HFS+ but FreeBSD support is shaky (old driver, could not get it to compile on 7.0).

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 http://pflog.net/~floyd/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!


2 Comments on “Mounting a big ext2fs partition on a USB drive in FreeBSD”

  1. 1 Fernando F. said at 12:28 pm on August 17th, 2009:

    Thanks a lot for this solution.

  2. 2 Jindrich said at 12:48 pm on October 22nd, 2009:

    Thank you very much! (Děkuji mockrát :)


Leave a Reply