Cloning a PC to a new HD over the network

From Edgar BV Wiki
Revision as of 13:59, 15 April 2013 by Red (talk | contribs)
Jump to navigation Jump to search

This method works if you want to clone a server to a new virtual machine

  1. mount HD in VM (rightclick VM, edit settings, 'add' new device and create a new HD)
  2. ensure rsync is on both machines
  3. ensure ssh allows root logins on machine to back up
  4. recreate the LVM structure on HD. Ensure there is a non-LVM partition for /boot where we can put the MBR on later
  5. also make sure there is an LV or a HD partition for swap
  6. mount the LVs under /mnt/. First mount root, create the subdirs and then mount the rest
  7. Sync the data:
 rsync -a -h --stats --exclude=/home/sites/www.cmtportal.nl/site/zuilen/upload/ --exclude=/home/store/ --exclude=/proc/ --exclude=/sys/ --exclude=/dev/ -e ssh root@192.168.0.9:/ /mnt/

(NB find HD UUID's using blkid)

  1. edit the /mnt/etc/fstab to reflect the new LV names
  2. vi /boot/grub/menu.lst or grub.cfg to reflect the new LV names
  3. mkdir /var/, /sys/, /dev/
  4. unmount the LV's
  5. remove the HD from VM and add this to new VM
  6. start up on rescue disk
vgscan
lvscan
vgchange -ay
mount -a
update-grub
grub-install /dev/sda
update-initramfs -u -k all
sync
exit

reboot (unmount the cd from the VM)

  1. mount all drives
  2. Install grub bootloader
update-grub
grub-install /dev/sda