Yes, this is just another post about raspberry pi. However, other instructions seemed over-complicated to me, so I decided to make this small instruction.
But why not default ext4?
Because btrfs can detect data corruption, it has zero-cost atomic snapshots and compression. But as another option you can use F2FS, anyway there is nothing worse than ext4 on SD card.
Step 1
Follow the instructions from https://archlinuxarm.org for your device, however make a btrfs root system (not ext4) (compression & subvolume supported). Don’t forget to mount your subvolumes (/home, /var/log, whatever you created)!
Step 2
Edit etc/fstab, add root entry and other subvolumes. This is my fstab, for example:
# <file system> <dir> <type> <options> <dump> <pass>
/dev/mmcblk1p1 /boot vfat defaults 0 0
/dev/mmcblk1p2 / btrfs rw,noatime,ssd_spread,space_cache=v2,subvol=@root,compress-force=zstd:3 0 0
/dev/mmcblk1p2 /home btrfs rw,noatime,ssd_spread,space_cache=v2,subvol=@home,compress-force=zstd:3 0 0
/dev/mmcblk1p2 /var/log btrfs rw,noatime,ssd_spread,space_cache=v2,subvol=@var_log,compress-force=zstd:3 0 0
/dev/mmcblk1p2 /.swap btrfs rw,noatime,ssd_spread,space_cache=v2,subvol=@swap 0 0
/.swap/swapfile none swap defaults 0 0
Step 3
Add rootflags=subvol=@root
to boot/boot.txt
. You can probably edit root=PARTUUID=...
kernel parameter to boot from usb, but i never tested it.
Step 4
Install uboot tools on your PC (pacman -S uboot-tools
on ArchLinux) and run ./mksrc (in boot directory)
That’s all. Now you can boot your raspberry pi and enjoy btrfs features.
UPD
In the same way I was able to move root partition to hdd + bcache + btrfs raid1. Just added bcache to initcpio hooks (between block and filesystems) & modules and changed bootargs to root=UUID=<bcache UUID>
. Also changed fstab