Discussion:
[PVE-User] Migrating from LVM to ZFS
Mark Schouten
2018-11-27 11:53:49 UTC
Permalink
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.


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

***@proxmoxlvmzfs:~# zpool create -f rpool /dev/sdb2
***@proxmoxlvmzfs:~# zfs create rpool/ROOT
***@proxmoxlvmzfs:~# zfs create rpool/ROOT/pve-1
***@proxmoxlvmzfs:~# zfs create rpool/data
***@proxmoxlvmzfs:~# zfs create rpool/swap -V 8G
***@proxmoxlvmzfs:~# mkswap /dev/zvol/rpool/swap
***@proxmoxlvmzfs:~# cd /rpool/ROOT/pve-1
***@proxmoxlvmzfs:/rpool/ROOT/pve-1# rsync -avx / ./
***@proxmoxlvmzfs:/rpool/ROOT/pve-1# mount --bind /proc proc
***@proxmoxlvmzfs:/rpool/ROOT/pve-1# mount --bind /dev dev
***@proxmoxlvmzfs:/rpool/ROOT/pve-1# mount --bind /sys sys
***@proxmoxlvmzfs:/rpool/ROOT/pve-1# swapoff -a
***@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 ================
***@proxmoxlvmzfs:/# zpool set bootfs=rpool/ROOT/pve-1 rpool
***@proxmoxlvmzfs:/# grub-install /dev/sda
***@proxmoxlvmzfs:/# grub-install /dev/sdb
***@proxmoxlvmzfs:/# update-grub
***@proxmoxlvmzfs:/# zfs set mountpoint=/ rpool/ROOT/pve-1

Reboot

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

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

Loading...