Skip to content

Instantly share code, notes, and snippets.

@Daviteusz
Last active January 19, 2024 21:41
Show Gist options
  • Save Daviteusz/252a1a71214b6b8b2cdc247449b8859e to your computer and use it in GitHub Desktop.
Save Daviteusz/252a1a71214b6b8b2cdc247449b8859e to your computer and use it in GitHub Desktop.
RaspberryPI OS 12 (bookworm) BTRFS

BTRFS on RaspberryPi OS 12 (bookworm)

  • It is best to follow these steps on a PC.
  • If you fresh install your RaspiOS, then boot RPI once to complete OS configuration.

Convert MBR to GPT (optional)

  • mbr2gpt can be found here.
# ./mbr2gpt /dev/sdX

Convert EXT4 to BTRFS

# btrfs-convert /dev/sdX2

Create subvolumes

# mount /dev/sdX1 /mnt/bootfs
# mount /dev/sdX2 /mnt/rootfs

# cd /mnt/rootfs
# btrfs subvolume create @
# btrfs subvolume create @home
# btrfs subvolume create @log
# btrfs subvolume create @archives
# btrfs subvolume create @.snapshots

Remove old ext4 subvolume

# btrfs subvolume delete ext2_saved

Move everything to subvolumes

# cp -P lib @/lib
# cp -P sbin @/sbin
# rm -r lib/ sbin/
# mv home/* @home/
# rm -r home/
# for i in var boot etc opt media mnt srv tmp usr root bin dev proc run sys initrd.img vmlinuz; do mv $i @/$i; done

Update bootfs/cmdline.txt

  • How to get PARTUUID?
# blkid /dev/sdX2
... root=PARTUUID=S0me-P4RTUU1D rootfstype=btrfs rootflags=subvol=@ fsck.repair=no ...

Update rootfs/@/etc/fstab

# rootfs
PARTUUID=S0me-P4RTUU1D   /                       btrfs   noatime,nodiratime,rw,relatime,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@  0 0
PARTUUID=S0me-P4RTUU1D   /home                   btrfs   rw,relatime,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@home                 0 0
PARTUUID=S0me-P4RTUU1D   /var/log                btrfs   rw,relatime,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@log                  0 0
PARTUUID=S0me-P4RTUU1D   /var/cache/apt/archives btrfs   rw,relatime,ssd,discard=async,space_cache=v2,subvolid=260,subvol=/@archives             0 0
PARTUUID=S0me-P4RTUU1D   /.snapshots             btrfs   rw,relatime,ssd,discard=async,space_cache=v2,subvolid=261,subvol=/@.snapshots           0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment