Raspberry PI BTRFS root
btrfs on Raspberry Pi
Conversion
- Boot the pi at least once with a normal flash of raspbian
- From the pi:
- Add
btrfs
to /etc/initramfs-tools/modules - Run
update-initramfs -u -k $(uname -r)
- Append
/boot/config.txt
to includeinitramfs initrd.img-$(uname -r) followkernel
- Replace
ext4
withbtrfs
in/etc/fstab
and/boot/cmdline.txt
- Add
- From a different system:
btrfs-convert -L /dev/sd
- From the pi:
btrfs subvol delete /ext2_saved
btrfs fi defrag -r /
btrfs balance start /
Script
#!/bin/bash
set -euo pipefail
grep -q "btrfs" /etc/initramfs-tools/modules || echo btrfs >> /etc/initramfs-tools/modules
update-initramfs -u -k $(uname -r)
sed -i '/followkernel/d' /boot/config.txt
echo "initramfs initrd.img-$(uname -r) follow kernel" >> /boot/config.txt
sed -i 's/ext4/btrfs/g' /etc/fstab
sed -i 's/ext4/btrfs/g' /boot/cmdline.txt
sed -i 's/ quiet//g' /boot/cmdline.txt
sed -i 's/ splash//g' /boot/cmdline.txt
sed -i 's/ rootwait=[^ ]*//;s/$/ rootwait=2/' /boot/cmdline.txt
apt install btrfs-progs
echo "
# default 3000 => 30s , we use 5 minutes = 30000
vm.dirty_expire_centisecs = 30000
vm.vfs_cache_pressure=500
vm.swappiness=100
vm.dirty_background_ratio=1
vm.dirty_ratio=50
" > /etc/sysctl.d/50-sdcard.conf
# Enable zram-swap
apt install zram-tools
sed -i 's/^ALLOCATION=.*$/ALLOCATION=1024/' /etc/default/zramswap
# Disable dphys-swapfile
apt purge dphys-swapfile
Share this post
Twitter
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email