Getting Lubuntu 22.04 to install with BTRFS

Those of you who are both Lubuntu and BTRFS users have almost certainly noticed that installing Lubuntu 22.04 with BTRFS results in a broken system. Thankfully, we’ve figured out the problem, and have developed a few solutions to it. One of these will make a new installation work out of the box, while the other two will fix an already installed (and broken) system.

NEW INSTALLATIONS:

First, boot up your Lubuntu 22.04 ISO using your method of choice. Open a terminal with Ctrl+Alt+T, and run the command featherpad /etc/calamares/modules/fstab.conf.

This will open up a configuration file. This file is used by the Lubuntu installer when setting up your system. It also isn’t quite configured right.

Change the third line from this:

btrfs: defaults,noatime,space_cache,autodefrag

To this:

btrfs: defaults,noatime,autodefrag

Save the file, and close it. You can now install Lubuntu with BTRFS as you see fit.

(Special thanks to @kc2bez and @tsimonq2 for this solution!)

EXISTING INSTALLATIONS:

If you already have a broken Lubuntu 22.04 installation with BTRFS, you don’t have to reinstall it to fix it. The fix is easiest to do with a live ISO, but you don’t need one.

If you have a Lubuntu installation disk or USB stick handy, boot the broken system from it, and follow these steps:

  1. Open a terminal by pressing Ctrl+Alt+T, and run lsblk. This will tell you information about the disks in your system. Find the disk that you installed Lubuntu onto. You will see the disk itself (something like sda), and one or more entries under it (like sda1). These entries underneath the disk are the disk’s partitions. One of these partitions will be the BTRFS partition. You should be able to tell which disk and partition you installed Lubuntu onto based off of the partition’s size.

  2. Now that you know what partition contains your BTRFS file system, run sudo mount <BTRFS_part> /mnt. Replace <BTRFS_part> with the path to your BTRFS partition. For instance, if you installed Lubuntu with BTRFS onto /dev/sda1, replace <BTRFS_part> with /dev/sda1. This will give you access to your BTRFS partition.

  3. Now, run sudo nano /mnt/@/etc/fstab. You will see a lot of rather confusing-looking lines. This file contains vital configuration info for your system’s partitions. Due to the BTRFS installation bug, this file isn’t quite right, and that’s why BTRFS installs are broken. Thankfully, the fix is rather easy.

  4. Press Ctrl+W to do a search, and search for space_cache. Press Enter. Remove the space_cache option entirely. Repeat this process until all of the space_cache entries in the file have been removed.

(Notice: If you’re using many file systems on your disk, it’s theoretically possible that you might have non-BTRFS file systems that also have a space_cache option. If you’re using many file systems, make sure to only remove the space_cache options on the BTRFS file systems.)

In case these instructions are confusing, here’s a sample configuration file from a brand-new, not-yet-fixed BTRFS installation:

UUID=<big long ID code> /     btrfs subvol=/@,defaults,noatime,space_cache,autodefrag     0 1
UUID=<big long ID code> /home btrfs subvol=/@home,defaults,noatime,space_cache,autodefrag 0 2
UUID=<big long ID code> /swap btrfs subvol=/@swap,defaults,noatime,space_cache,autodefrag 0 2
/swap/swapfile          swap  swap  defaults                                              0 0

And here’s the file after fixing it:

UUID=<big long ID code> /     btrfs subvol=/@,defaults,noatime,autodefrag     0 1
UUID=<big long ID code> /home btrfs subvol=/@home,defaults,noatime,autodefrag 0 2
UUID=<big long ID code> /swap btrfs subvol=/@swap,defaults,noatime,autodefrag 0 2
/swap/swapfile          swap  swap  defaults                                  0 0

Note that you don’t have to get the spacing all pretty like I did - there only has to be one space between each entry in each line. I just formatted it nice for the sake of readability.

Once you’ve fixed this file, press Ctrl+O, Enter, then Ctrl+X. This will save the file and close it. Finally, reboot, and enjoy your functioning Lubuntu 22.04 system with BTRFS!

(If this solution is too confusing, there’s an easier way. In step 2, you can run sudo mount <BTRFS_part> /mnt -o clear_cache,space_cache=v1, replacing <BTRFS_part> with the path to your BTRFS partition. This will fix the problem immediately, and you can reboot and use your system. The downside to this solution is that certain workloads and very large drives may not perform at optimal speeds.)

If you are an advanced Lubuntu user, and don’t want to boot into a live ISO, you can boot into recovery mode to do the repair. To do this, power on the broken system, and for the initial BIOS boot to complete. The moment the initial BIOS boot is complete, press Esc if you’re on a UEFI system, or press Shift if you’re on a legacy BIOS system. (If one key doesn’t work for you, try the other.) This will get you into a boot menu. Select Advanced Options for Ubuntu, and select the second entry (it’s the one that says (recovery mode) in it). Press Enter to boot into recovery mode.

At the recovery mode screen, use your arrow keys to select root, and press Enter twice.

Now we need to get your main partition mounted as as read/write. To do this, type lsblk. One of your partitions will be mounted at /. Make note of this partition.

Now, type mount <root_partition> / -o remount,rw. Replace <root_partition> with the path to your root partition. For instance, if your root partition is on /dev/sda1, type mount /dev/sda1 / -o remount,rw.

Finally, type nano /etc/fstab. This will allow you to edit the messed-up configuration file. You can now fix the file as described above, and reboot when you’re done.

That’s it! Your system should now function as expected! I hope this was helpful! Thanks for using Lubuntu, and have a nice day!

5 Likes