Cloning ZFS root: Difference between revisions

From Jan's Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 33: Line 33:
  mount /dev/sda1 /mnt/boot/grub
  mount /dev/sda1 /mnt/boot/grub


* chroot /mnt
* Setuo chroot env
chroot /mnt
  mount -t sysfs sys /sys
  mount -t sysfs sys /sys
  mount /proc
  mount /proc
  mount /dev
  mount /dev


* replace /etc/zfs/zpool.cache  
* Create new zpool.cache  
  zpool set cachefile=/etc/zfs/zpool.cache rpool
  zpool set cachefile=/etc/zfs/zpool.cache rpool



Latest revision as of 21:47, 3 June 2017

  • List partitions
parted
unit s
p
  • Clone start of disk
dd if=/dev/sdb bs=512 of=80gb.img count=22527 conv=nocreat,notrunc
  • Create loop device for partitions
kpartx -a 80gb.img
  • Create new pool
zpool create apool /dev/mapper/loop0p2
  • Create snapshot on source pool
zfs snapshot -r rpool@cptovm
  • Send to new pool
zfs send -R rpool@cptovm | pv | zfs receive -Fd apool
  • Export new pool
zpool export apool
  • Convert to VMWare image
qemu-img convert -O vmdk ~/VirtualBox\ VMs/zolnascp/80gb.img 80gb.vmdk
  • Replace new image in .vmx
  • Use Debian ZFS LiveCD in VM to boot from image
  • Import apool as rpool
zpool import apool rpool -R /mnt
  • mount grub partition
mount /dev/sda1 /mnt/boot/grub
  • Setuo chroot env
chroot /mnt
mount -t sysfs sys /sys
mount /proc
mount /dev
  • Create new zpool.cache
zpool set cachefile=/etc/zfs/zpool.cache rpool
  • set bootfs
zpool set bootfs=rpool/ROOT/ubuntu-1 rpool 
  • Update initramfs (should use new cache file) [1]
update-initramfs -c -k all
update-grub
grub-install /dev/sda

That's it...