Skip to content

Instantly share code, notes, and snippets.

@Daviteusz
Last active March 19, 2024 21:59
Show Gist options
  • Save Daviteusz/5cfd1685ae172c0a7235c817d4e85b0d to your computer and use it in GitHub Desktop.
Save Daviteusz/5cfd1685ae172c0a7235c817d4e85b0d to your computer and use it in GitHub Desktop.
ALARM_BTRFS

BTRFS on ArchLinux | ARM

Convert MBR to GPT (optional)

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

Convert EXT4 to BTRFS

btrfs-convert /dev/sdX2

Mount

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

Remove old ext4 subvolume

cd /mnt/rootfs
btrfs subvolume delete ext2_saved

Create subvolumes

btrfs subvolume create @
btrfs subvolume create @home
btrfs subvolume create @log
btrfs subvolume create @pkg
btrfs subvolume create @.snapshots

Move everything to subvolumes

rsync -axHAWXS --numeric-ids --info=progress2 --exclude={@,'@*',lost+found,home} --remove-source-files ./ ./@
rsync -axHAWXS --numeric-ids --info=progress2 --remove-source-files ./home/* ./@home/

Remove orphaned folders

find . -mindepth 1 -type d ! -path './@*' -exec rm -rf {} +

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,subvol=/@  0 0
PARTUUID=S0me-P4RTUU1D   /home                  btrfs   rw,relatime,ssd,discard=async,space_cache=v2,subvol=/@home                 0 0
PARTUUID=S0me-P4RTUU1D   /var/log               btrfs   rw,relatime,ssd,discard=async,space_cache=v2,subvol=/@log                  0 0
PARTUUID=S0me-P4RTUU1D   /var/cache/pacman/pkg  btrfs   rw,relatime,ssd,discard=async,space_cache=v2,subvol=/@pkg                  0 0
PARTUUID=S0me-P4RTUU1D   /.snapshots            btrfs   rw,relatime,ssd,discard=async,space_cache=v2,subvol=/@.snapshots           0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment