BTRFS and Ubuntu Lucid 10.04
May 8th, 2010
Although Ubuntu Lucid 10.04 has native support for BTRFS, it does not like very much auto-mounting a BTRFS volume during start up. The problem seems to be that btrfsctl -a is not invoked during the boot process.
It takes some hacks to udev and initramfs to get this working. I found the solution in HowTO: Btrfs Root Installation:
This initramfs script will make sure the btrfsctl binary gets copied to the RAM disk:
$ cat /usr/share/initramfs-tools/hooks/btrfs
#!/bin/sh -e
# initramfs hook for btrfs
if [ "$1" = "prereqs" ]; then
exit 0
fi
. /usr/share/initramfs-tools/hook-functions
if [ -x "`which btrfsctl`" ]; then
copy_exec "`which btrfsctl`" /sbin
fi
I believe the following is not strictly necessary unless you plan on having a BTRFS-based root filesystem:
$ cat /usr/share/initramfs-tools/modules.d/btrfs # initramfs modules for btrfs libcrc32c crc32c zlib_deflate btrfs
This will load the BTRFS module while the system boots up, and calls btrfsctl -a to prepare the BTRFS volumes:
$ cat /usr/share/initramfs-tools/scripts/local-premount/btrfs
#!/bin/sh -e
# initramfs script for btrfs
if [ "$1" = "prereqs" ]; then
exit 0
fi
modprobe btrfs
if [ -x /sbin/btrfsctl ]; then
/sbin/btrfsctl -a 2>/dev/null
fi
Mark the scripts executable:
chmod +x /usr/share/initramfs-tools/scripts/local-premount/btrfs chmod +x /usr/share/initramfs-tools/hooks/btrfs
Rebuild the initial RAM disks and GRUB environment:
update-initramfs -u -k all update-grub
That should do it.