11 Mar 2019 Installing Ubuntu 18.04 with bcache support (Ubuntu SSD cache)

For this tutorial, I have created a virtual machine with two hard drives. First one, 10GB “SSD” for cache, and the second one 30GB for OS and data.

Before we start

We need to boot our live iso into “Try mode”. Just click “Try Ubuntu” instead of “Install Ubuntu”. This tutorial is valid only for fresh installations on computers with EFI support. Here are the main steps:

  1. Create partitions
  2. Create bcache device
  3. Install Ubuntu 18.04 into it.
  4. chroot into the new installation
  5. Install bcache-tools from the repository
  6. Regenerate initramfs
  7. Reboot into installed system

Our disks:

/dev/sda – our SSD (it will be used for cache)
/dev/sdb – our HDD (it will be used for system and user data)


Now we have to remove any unnecessary partitions and create new ones. You can use one of the preinstalled tools (like fdisk or gparted).

/dev/sda1 – our cache [any size, any type]
/dev/sdb1 – EFI partition [256MB, fat32]
/dev/sdb2 – our data [any size, any type]

Installing bcache support

Connect your computer to internet and open terminal. Now type

sudo apt update
sudo apt install bcache-tools

Creating bcache device

Wipe filesystems on created partitions

sudo wipefs -a /dev/sda1
sudo wipefs -a /dev/sdb2

Create a backing device (our /dev/sdb2, HDD) and our cache device (/dev/sda1, SSD)

sudo make-bcache -B /dev/sdb2 -C /dev/sda1

Format our bcache device to ext4 (or something else you want)

sudo mkfs.ext4 /dev/bcache0

Installing Ubuntu

Now, open the Install Ubuntu 18.04 and start installing Ubuntu as normal. At the partitioning screen, we have to do custom partitioning:

Use /dev/bcache0 as / and format it as ext4
Use /dev/sdb1 as EFI

Install bootloader on /dev/sdb.

Note: if you got an error with mounting EFI partition. Go back to partitioning screen, remove EFI partition and create a new one via installer.

When the installation is complete (and installer dosen’t crash) DO NOT RESTART COMPUTER.

Chroot time

Now, we need to chroot into a new installation, install bcache-tools on it and generate new initramfs (we need it to boot newly installed OS) First, mount our bcache device into /mnt folder.

sudo mount /dev/bcache0 /mnt
sudo mount /dev/sda1 /mnt/boot

Now chroot into newly installed system.

sudo chroot /mnt

Install bcache-tools in chrooted system

sudo apt update
sudo apt install bcache-tools

Exit chrooted shell using exit and umount mounted devices

sudo umount /mnt/boot
sudo umount /mnt

And finally, reboot the system (using reboot)