Mounting UFS partitions in Linux

My desktop machine at work is now running RHEL 4, but before that it ran FreeBSD 4.10 for a number of years and had three hard drives with UFS filesystems. When my box was converted over to Linux, I backed up the critical files on the main hard drive and then reformatted the drive with ext3. The other two hard drives with UFS filesystems sat there collecting dust, which was unfortunate, because I could use the disk space. Today, I decided to mount the UFS partitions and look through the files and see if there’s anything worth keeping, before formatting these drives for Linux and getting myself a whole lot more disk space. Here’s how I did it.

The first task was to build the UFS kernel module, as my kernel did not have UFS support built-in, nor did my install have the UFS kernel module available. Already, having installed the proper kernel-devel RPM a while back, I did the following:

$ uname -r
$ rpm -qa | grep kernel-devel
$ cd ~/rpm/BUILD/kernel-2.6.9/linux-2.6.9
$ make menuconfig
$ make modules
$ make modules_install
$ depmod
$ sudo modprobe ufs

At this point, I had built the UFS kernel module and loaded it. Now it was time to mount the filesystems.

$ sudo mkdir /mnt/hdc1 /mnt/hdd1
$ sudo mount -t ufs -o ufstype=44bsd,ro /dev/hdc1 /mnt/hdc1
$ sudo mount -t ufs -o ufstype=44bsd,ro /dev/hdd1 /mnt/hdd1

That’s it! I now had read-only access to my two UFS partitions. Now I have to look through these files and see what’s worth keeping.