-
-
Save george-andrei/1d115d343782bb0b60dc3940c989c4a0 to your computer and use it in GitHub Desktop.
Convert root ext4 to btrfs including subvolumes and snapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# on your ext4 distro | |
sudo su | |
apt install btrfs-progs | |
shutdown now | |
# switch to a linux live environment | |
sudo su | |
fsck -f /dev/vda3 | |
# BTRFS convert | |
btrfs-convert /dev/vda3 | |
# Move the Root filesystem from rescue | |
mount /dev/vda3 /mnt | |
btrfs subvol create /mnt/@ | |
btrfs subvolume delete /mnt/ext2_saved | |
mv /mnt/* /mnt/@/ | |
btrfs subvol create /mnt/@home | |
mv /mnt/@/home/* /mnt/@home/ | |
# FSTAB | |
blkid /dev/vda3 | awk '{print $2}' | |
vim /mnt/@/etc/fstab | |
--- comment the / ext4 line | |
UUID=9fb8437d-783c-4f2c-8c38-56290764b1ad / btrfs subvol=/@ 0 1 | |
UUID=9fb8437d-783c-4f2c-8c38-56290764b1ad /home btrfs subvol=/@home 0 2 | |
--- | |
# CHROOT | |
umount -l /mnt/ | |
mount /dev/vda3 /mnt/ -t btrfs -o subvol=@ | |
for fs in proc sys dev dev/pts; do mount --bind /$fs /mnt/$fs; done | |
chroot /mnt /bin/bash | |
# GRUB | |
mount /boot/efi | |
grub-install --no-nvram /dev/vda | |
grub-mkconfig -o /boot/grub/grub.cfg | |
# list subvolumes | |
btrfs subvolume list / -t | |
# finish | |
exit | |
reboot | |
# check | |
sudo su | |
btrfs subvolume list / -t | |
btrfs filesystem df / | |
## SNAPPER: | |
sudo snapper -c root create-config / | |
sudo sed -i 's/^ALLOW_USERS=.*/ALLOW_USERS="pacadmin"/' /etc/snapper/configs/root | |
# Change permissions and ownership to snapshot directory: | |
sudo chmod a=rx /.snapshots/ | |
sudo chown :pacadmin /.snapshots/ | |
# Create snapshots: | |
snapper -c root create --description AfterMigration | |
# List snapshots under root config: | |
snapper -c root list | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fstab example from Manjaro forum: https://forum.manjaro.org/t/default-btrfs-mount-options-and-subvolume-layout/43250/17 | |
# Swap | |
UUID=06686a06-c069-49f7-86e4-7a962740b364 none swap defaults 0 0 | |
# UEFI | |
UUID=447C-E2BC /boot/efi vfat noatime,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8 0 2 | |
# System | |
UUID=26c8751d-2747-4a4d-b857-32c82d67b20a /btrfs btrfs noatime,ssd,compress-force=zstd:5,subvolid=5 0 0 | |
UUID=26c8751d-2747-4a4d-b857-32c82d67b20a / btrfs noatime,ssd,compress-force=zstd:5,subvol=@ 0 0 | |
UUID=26c8751d-2747-4a4d-b857-32c82d67b20a /home btrfs noatime,ssd,compress-force=zstd:5,subvol=@home 0 0 | |
UUID=26c8751d-2747-4a4d-b857-32c82d67b20a /var btrfs noatime,ssd,nodatacow,subvol=@var 0 0 | |
UUID=26c8751d-2747-4a4d-b857-32c82d67b20a /.snapshots btrfs noatime,ssd,compress-force=zstd:5,subvol=@snapshots/root 0 0 | |
UUID=26c8751d-2747-4a4d-b857-32c82d67b20a /home/.snapshots btrfs noatime,ssd,compress-force=zstd:5,subvol=@snapshots/home 0 0 | |
# var/lib mount into subvol=@ | |
/usr/var/lib /var/lib none defaults,bind 0 0 | |
# Backup | |
UUID=d49e1730-5137-473c-8e28-a76cf14e9830 /media/Backups btrfs nofail,noatime,ssd,compress-force=zstd:5,subvol=@backups 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment