Skip to content

Instantly share code, notes, and snippets.

@lisenhatson
Last active October 12, 2024 16:00
Show Gist options
  • Select an option

  • Save lisenhatson/96fa3aa65cef4183b78005b982104d1f to your computer and use it in GitHub Desktop.

Select an option

Save lisenhatson/96fa3aa65cef4183b78005b982104d1f to your computer and use it in GitHub Desktop.
Creating BTRFS system for Linux installation

Checking for available block devices

lsblk

sd*, vd*, nvme*

Edit the disk partition

fdisk /dev/sd* 

delete previous, create sd*1 for +300MiB and sd*2 for the rest of the size

or you could do your usuals that are different from this

setting up swap partition if you're using SSD is not good for your SSD's health, use zramen instead

you could use cfdisk for interactive partitioning

Format partitions

mkfs.fat -F 32 /dev/sd*1 # assuming your boot partition is on the first partition of the disk
mkfs.btrfs /dev/sd*2 # assuming your main partitioning is so

Creating btrfs subvolume (root and home) and mount partitions

mount the btrfs partition

mount /dev/sd*2 /mnt
cd /mnt

creating subvolumes

btrfs su cr @root
btrfs su cr @home

optional subvolumes

btrfs su cr @rootsnaps
btrfs su cr @homesnaps

unmount the btrfs partition

cd
umount -R /mnt

remount btrfs subvolumes with options

mount -o ssd,noatime,autodefrag,compress=lzo,subvol=@ /dev/sd*2 /mnt
mkdir -p /mnt/home
mount -o ssd,noatime,autodefrag,compress=lzo,subvol=@home /dev/sd*2 /mnt/home

mount the optional partitions by your way

mount the boot partition

mkdir -p /mnt/boot # /mnt/boot/efi if EFI 
mount /dev/sd*1 /mnt/boot # mount it to ../efi if EFI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment