Install Debian Linux On Btrfs
You investigate Btrfs. You read the documentation and many blog posts about it.
It has its advantages. It gives you value. Structure.
Then you check some installation guides:
- Escape to shell from the installer to do the partitioning.
- Bootstrap a Debian system while you mount the disk from a live CD.
No. You don’t have to be a magician to install Debian on Btrfs.
The Debian installer can do it for you.
The installer creates a perfectly usable Btrfs filesystem.
You can organize it into subvolumes later, after the first boot.
What Is Btrfs?
Btrfs is a modern filesystem for your computer with volume manager capabilities.
Btrfs gives you advanced features over traditional filesystems.
- Subvolumes
- Compression
- Snapshots
- Checksums
If you’re reading this article, you probably know it already.
The Debian Installer
Use the Debian installer.
Not a live system. You don’t need the full DVD.
You can work with the netinstaller ISO, like this one.
Boot the installer.
Choose the Advanced options.
Go for the Expert install.
Follow it step by step until the disk partitioning.
Backup your data. Read carefully every step you do.
After formatting your drive the data will be erased.
Choose Manual.
- For legacy systems create a 1MB BIOS boot partition.
- For EFI systems create a 500MB FAT32 EFI System Partition (ESP).
From here follow your desired path – LUKS encrypted system or not.
Btrfs Root Without LUKS
I won’t teach you to use the partitioner.
You already know how to use it.
Instead I show you the architecture you can create:
[Disk]
|
|
|--------------|
| |
[EFI or GRUB] [Btrfs]
After the installation you can create the subvolumes.
You can create the swap file too.
Btrfs Root On LUKS With Swap Partition
With LUKS the architecture is a bit more complex:
[Disk]
|
|
|----------|
| |
[EFI or GRUB] [LUKS]
|
|
[LVM VG]
|
|---------------------|
| |
[LVM LV Swap] [LVM LV for Btrfs]
|
|
[Btrfs]
On notebooks the hibernation can work.
The subvolumes can be created and mounted after the installation.
Debian Subvolumes
You can create the usual “partitions” as Btrfs subvolumes.
Mount the root subvolume. Check and use your device.
mount -o subvolid=5 /dev/vda2 /mnt/
Create your desired subvolumes.
We create /var/log and /var/lib here followed by a swap file.
btrfs subvolume create /mnt/@var_logbtrfs subvolume create /mnt/@var_lib
Check the subvolumes and umount the root Btrfs.
btrfs subvolume list /mntumount /mnt
Check the UUID of your disk.
btrfs filesystem show
Create and populate the /var/log
Populate the /var/log.
mkdir /mnt/var_logmount -o subvol=@var_log /dev/vda2 /mnt/var_log
Copy the existing logs (later verify it with ls).
rsync -aHAX /var/log/ /mnt/var_log/
Extend the fstab with the new subvolume.
UUID=0a12056d-d176-434b-b63d-a25a422a2a42 /var/log btrfs subvol=@var_log,compress=zstd:3,noatime 0 0
Rename the original /var/log.
mv /var/log /var/log.oldmkdir /var/log
Mount & test it.
mount -als -al /var/log
Create and populate the /var/lib
Mount & move the data.
mkdir /mnt/var_libmount -o subvol=@var_lib /dev/vda2 /mnt/var_librsync -aHAX /var/lib/ /mnt/var_lib/
Update the fstab with the new entry.
UUID=0a12056d-d176-434b-b63d-a25a422a2a42 /var/lib btrfs subvol=@var_lib,compress=zstd:3,noatime 0 0
Remove the old /var/lib and remount the new data.
mv /var/lib /var/lib.oldmkdir /var/libmount -a
Verify it.
ls -al /var/lib
Create a swap file
I create a 4GB swapfile here.
Adjust it to your system.
btrfs filesystem mkswapfile --size 4g /swapfileswapon /swapfile
Extend the fstab with the new swap file.
/swapfile none swap defaults 0 0
Now reboot the machine.
Final Thoughts
The Debian installer is very flexible.
It’s ready to prepare a system for you using Btrfs.
This installation method is not better or worse. It simply follows a different architecture.
Btrfs gives you the tools to create any traditional “partition” as a subvolume.
Discover more from Tom's IT Cafe
Subscribe to get the latest posts sent to your email.