Enabling UFS r/w support in Ubuntu 12.04 LTS

Continuing my work with servers running Ubuntu, I’ve come across the issue of needing the ability to write to UFS filesystems via libguestfs. I was doing a lot of head-banding against various walls, until I came across this post (thanks a lot Oz Nahum!).

R/W support is *experimental*, you’ve been warned.

First create the build directory and download the source for your kernel:

sudo su -
apt-get build-dep --no-install-recommends linux-image-$(uname -r)
mkdir /usr/local/src/ufs_rw
cd /usr/local/src/ufs_rw
apt-get source linux-image-$(uname -r)
cd linux-3.x.y-z
cp -v /usr/src/linux-headers-3.x.y-z/Module.symvers .
cp -v /boot/config-3.x.y-z .
make EXTRAVERSION=-4 O=/usr/local/src/ufs_rw  oldconfig
sed -i 's/# CONFIG_UFS_FS_WRITE is not set/CONFIG_UFS_FS_WRITE=y/' /usr/local/src/ufs_rw/.config

Continue compiling:

make EXTRAVERSION=-4 O=~/ufs_rw prepare
make EXTRAVERSION=-4 O=~/ufs_rw outputmakefile
make EXTRAVERSION=-4 O=~/ufs_rw archprepare
make EXTRAVERSION=-4 O=~/ufs_rw modules SUBDIRS=scripts
make EXTRAVERSION=-4 O=~/ufs_rw modules SUBDIRS=fs/ufs

You’ll find your module here: /usr/local/src/ufs_rw/linux-[version]/fs/ufs/ufs.ko. From there, you can just copy the file to /lib/modules/3.x.y-z/kernel/fs/ufs — I preferred to rename the original to ‘ufs.ko.ro’ vs. overwriting it.

Now with a modprobe ufs you’ll have UFS support loaded with r/w support!