- It is best to have a GUI install of RaspiOS on your SDCard and your storage drive
- Fresh install RaspiOS to your storage drive and boot it once
- Make sure to run
sudo apt update && sudo apt upgrade
before rebooting back to your SD card
All these steps are done from your SD card install
- mbr2gpt can be found here. Look for usb-boot.zip
# ./mbr2gpt /dev/sdX
# btrfs-convert /dev/sdX2
# 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
# mv home/* @home/
# rm -rf home/
# rm -rf lost+found
Run the following script to move all other folders/files
#!/bin/bash
# Usage: ./move_into_subvol.sh @
# Moves everything except items starting with '@', 'ext2_saved', and the script itself into the target subvolume
TARGET_SUBVOL="$1"
if [[ -z "$TARGET_SUBVOL" ]]; then
echo "Usage: $0 <target-subvolume>"
exit 1
fi
SCRIPT_NAME="$(basename "$0")"
for item in *; do
# Skip the target subvolume, ext2_saved, any subvolumes starting with @, and the script itself
if [[ "$item" != "$TARGET_SUBVOL" && "$item" != "ext2_saved" && "$item" != @(@*) && "$item" != "$SCRIPT_NAME" ]]; then
echo "Moving $item -> $TARGET_SUBVOL/"
mv "$item" "$TARGET_SUBVOL"/
fi
done
- How to get PARTUUID?
# blkid /dev/sdX2
Inside bootfs/cmdline.txt, add the following:
... root=PARTUUID=S0me-P4RTUU1D rootfstype=btrfs rootflags=subvol=@ fsck.repair=no ...
# Root
PARTUUID=Some-PARTUUID / btrfs noatime,ssd,discard=async,space_cache=v2,compress=zstd:3,subvol=@ 0 0
PARTUUID=Some-PARTUUID /home btrfs relatime,ssd,discard=async,space_cache=v2,compress=zstd:3,subvol=@home 0 0
PARTUUID=Some-PARTUUID /var/log btrfs relatime,ssd,discard=async,space_cache=v2,compress=zstd:3,subvol=@log 0 0
PARTUUID=Some-PARTUUID /var/cache/apt/archives btrfs relatime,ssd,discard=async,space_cache=v2,subvol=@archives 0 0
PARTUUID=Some-PARTUUID /.snapshots btrfs relatime,ssd,discard=async,space_cache=v2,compress=zstd:3,[email protected] 0 0
# btrfs subvolume delete ext2_saved
# sudo raspi-config