[PVE-User] Migrating from LVM to ZFS

Mark Schouten mark at tuxis.nl
Tue Nov 27 12:53:49 CET 2018


Hi,

one of my colleagues mistakenly installed a Proxmox node with LVM instead of ZFS, and I want to fix that without reinstalling. I tested the following steps, which seem to be working as it should. But maybe somebody can think of something that I forgot. So I thought I'd share it here.

Feel free to comment!

/dev/sdb is the unused device, /dev/sda is the currently in-use device.


root at proxmoxlvmzfs:~# apt install parted
root at proxmoxlvmzfs:~# parted -s /dev/sdb mktable gpt
root at proxmoxlvmzfs:~# parted -s /dev/sdb mkpart extended 34s 2047s
root at proxmoxlvmzfs:~# parted -s /dev/sdb mkpart extended 2048s 100%
root at proxmoxlvmzfs:~# parted -s /dev/sdb set 1 bios_grub on

root at proxmoxlvmzfs:~# zpool create -f rpool /dev/sdb2
root at proxmoxlvmzfs:~# zfs create rpool/ROOT
root at proxmoxlvmzfs:~# zfs create rpool/ROOT/pve-1
root at proxmoxlvmzfs:~# zfs create rpool/data
root at proxmoxlvmzfs:~# zfs create rpool/swap -V 8G
root at proxmoxlvmzfs:~# mkswap /dev/zvol/rpool/swap 
root at proxmoxlvmzfs:~# cd /rpool/ROOT/pve-1
root at proxmoxlvmzfs:/rpool/ROOT/pve-1# rsync -avx / ./
root at proxmoxlvmzfs:/rpool/ROOT/pve-1# mount --bind /proc proc
root at proxmoxlvmzfs:/rpool/ROOT/pve-1# mount --bind /dev dev
root at proxmoxlvmzfs:/rpool/ROOT/pve-1# mount --bind /sys sys
root at proxmoxlvmzfs:/rpool/ROOT/pve-1# swapoff -a
root at proxmoxlvmzfs:/rpool/ROOT/pve-1# chroot .
================ fstab fix ================
Change swap partition to /dev/zvol/rpool/swap
Remove / mount entry
================ fstab fix ================
================ grub fix ================
In /etc/default/grub, set:
GRUB_CMDLINE_LINUX="root=ZFS=rpool/ROOT/pve-1 boot=zfs"
================ grub fix ================
root at proxmoxlvmzfs:/# zpool set bootfs=rpool/ROOT/pve-1 rpool
root at proxmoxlvmzfs:/# grub-install /dev/sda
root at proxmoxlvmzfs:/# grub-install /dev/sdb
root at proxmoxlvmzfs:/# update-grub
root at proxmoxlvmzfs:/# zfs set mountpoint=/ rpool/ROOT/pve-1

Reboot

root at proxmoxlvmzfs:~# lvchange -an pve
root at proxmoxlvmzfs:~# sgdisk /dev/sdb -R /dev/sda
root at proxmoxlvmzfs:~# sgdisk -G /dev/sda
root at proxmoxlvmzfs:~# zpool attach rpool /dev/sdb2 /dev/sda2

--
Mark Schouten <mark at tuxis.nl>
Tuxis, Ede, https://www.tuxis.nl
T: +31 318 200208 
  




More information about the pve-user mailing list