Skip to content

Instantly share code, notes, and snippets.

@pandada8
Created August 23, 2021 16:11
Show Gist options
  • Save pandada8/c7fefbdba8d19564a4ab5b03fe1b52a7 to your computer and use it in GitHub Desktop.
Save pandada8/c7fefbdba8d19564a4ab5b03fe1b52a7 to your computer and use it in GitHub Desktop.
Convert A ZFS root proxmox to btrfs
#!/bin/bash
from=sda
to=sdb
set -ex
apt -y install parted
sgdisk /dev/${from} -R /dev/${to}
sgdisk -G /dev/${to}
mkfs.btrfs -f /dev/${to}3
mkfs.vfat /dev/${to}2
mkdir -p /mnt/newroot
mount /dev/${to}3 /mnt/newroot
btrfs subvolume create /mnt/newroot/root
umount /mnt/newroot
mount /dev/${to}3 -o subvol=root,compress=zstd /mnt/newroot
rsync -qiavP --one-file-system / /mnt/newroot
echo $(blkid -p -s UUID -o value /dev/${to}2) > /mnt/newroot/etc/kernel/proxmox-boot-uuids
echo $(grep -Po 'initrd=\S*' /etc/kernel/cmdline) root=UUID=$(blkid -p -s UUID -o value /dev/${to}3) rootflags=subvol=root > /mnt/newroot/etc/kernel/cmdline
partprobe /dev/${to}3
genfstab -U /mnt/newroot | tee /mnt/newroot/etc/fstab
arch-chroot /mnt/newroot update-initramfs -u
arch-chroot /mnt/newroot pve-efiboot-tool init /dev/sdb2
arch-chroot /mnt/newroot pve-efiboot-tool refresh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment