Slackware on external (USB) harddisk with btrfs root

I recently installed Slackware 1337 on my external USB hard disk. While doing so I decided to have a btfs filesystem for my root. Btrfs is being touted as next gen filesystem for linux, ZFS-killer blah blah… The following are my notes. I read many online articles mainly Archlinux wikis and the following two in particular as they deal with installing Slackware itself.

Infact they seem to be more knowledgeable guys and anybody reading this blog better contact them for any doubts. I’m writing this because it serves as my online notes, my words being more understandable for me. Also, it is easier to find my own blog than to search for others’.

LILO cannot (it seems) boot a btrfs root (/). So we need to create a separate /boot with other filesystems that LILO can boot like ext2/3/4.

I made GPT partitions on my ext HD. The partitions are as below.
/dev/sdb1 BIOS boot 2MB
/dev/sdb2 /boot 500MB
/dev/sdb3 / 20G (btrfs with subvolumes 'system' and 'home')
/dev/sdb4 swap

Boot up with Slackware DVD before we start ‘setup’ we need to create btrfs root ourselves. The mentioned articles do not recommend using installer’s ‘btrfs’ choice for formatting root.

1. mkfs.ext4 /dev/sdb2
2. mkfs.btrfs /dev/sdb3
3. mount /dev/sdb3 /mnt
4. btrfs subvolume create /mnt/system
5. btrfs subvolume create /mnt/home # more if we want like var, usr etc
6. btrfs subvolume list /mnt # to confirm, not necessary step
7. umount /mnt
8. mount -t btrfs -o subvol=system /dev/sdb3 /mnt # we are mounting subvolume of sdb3 not sdb3 itself.
9. mkdir -p /mnt/{boot,home}
10. mount -t btrfs -o subvol=home /dev/sdb3 /mnt/home # again mounting subvolume of sdb3 not sdb3 itself.
11. mount /dev/sdb2 /mnt/boot

Configuring btrfs partitions for installation is complete here. Now, we can run ‘setup’ to install but we are warned not to format our btrfs partition when installer asks i.e., we have to choose option ‘No’ at that stage. I did not choose any partition (read /dev/sdb3) to mount for /home even though I have separate subvolume, the partition shown is only /dev/sdb[123..]. There is no options for subvolume etc in the installer. So thought, it’s better to simply choose /dev/sdb3 for ‘/’.

I chose ‘full’ install option. After installation, we are not supposed to reboot. We have three work to do.
1. create initrd (and use generic kernel).
2. edit /etc/lilo.conf and then run /sbin/lilo reflecting the above.
3. edit /etc/fstab to mount our btrfs partitions.

First, change to different console (Alt+F2, Alt+F3…), hit Enter to get into shell and chroot to /mnt
chroot /mnt

Now, the above mentioned three tasks.
1. create initrd.
I we are not already good enough with mkinitrd options especially the modules part, it is better and simpler to use AlienBob’s script located in /usr/share/mkinitrd/ directory.

I was suggested mkinitrd -c -k -f btrfs -r /dev/sdb3 -m usb-storage:ehci-hcd:usbhid:btrfs -u -o /boot/initrd.gzwhich I promptly used 🙂

2. edit /etc/lilo.conf
I edited the lilo.conf to reflect using generic kernel with initrd and also rootflags to tell LILO that we have a btrfs subvolume as root. The following is my lilo.conf.# LILO configuration file
boot = /dev/sdb
bitmap = /boot/slack.bmp
bmp-colors = 255,0,255,0,255,0
bmp-table = 60,6,1,16
bmp-timer = 65,27,0,255
append=" rootdelay=20 vt.default_utf8=0"
timeout = 50
vga = 773

# Linux bootable partition config begins

image = /boot/vmlinuz-generic-
append = “root=UUID=77e2cc1c-c66d-445e-8173-84335fd02ae3 rootflags=subvol=system”
initrd = /boot/initrd.gz
label = Slackware
read-only # Partitions should be mounted read-only for checking

# Linux bootable partition config ends

LILO does not seem to like to be installed on root partition (atleast on external harddisk). boot=/dev/sdb2 or boot=/dev/sdb3 did not work for me. I had to install it on MBR itself with boot=/dev/sdb. Also, I chose to use UUIDs instead of device nodes like /dev/sdb3 etc.

3. edit /etc/fstab
The following is my /etc/fstab. UUID=c9b7a516-3661-4332-a970-aac7c4c599cd /boot ext4 defaults 0 0
UUID=77e2cc1c-c66d-445e-8173-84335fd02ae3 / btrfs defaults,subvol=system 0 1
UUID=77e2cc1c-c66d-445e-8173-84335fd02ae3 /home btrfs defaults,subvol=home 0 1
UUID=f2379c41-a142-4d01-91f2-70f0b83794d7 swap swap defaults 0 0
#/dev/cdrom /mnt/cdrom auto noauto,owner,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
/dev/mapper/crypt-data /mnt/Data ext4 defaults,user,auto,rw,sync 0 0

Once, these changes are done, we can reboot the sytem and enjoy slackware on a btrfs root.

Please note, although I have a working slackware installation, I have two problems during boot-up as mentioned in my LQ post. I’ll update regarding that later.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s