Cloning a PC to a new HD over the network

From Edgar BV Wiki
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. Then
mkswap /dev/vg/swap
  1. mount the LVs under /mnt/. First mount root, create the subdirs and then mount the rest
  2. Sync the data (NB don't forget --numeric-ids):
 rsync -a -h --stats --numeric-ids --exclude=/var/www/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. give the temp dir the right names:
chown root:root /mnt/tmp/
chmod 1777 /mnt/tmp/
  1. unmount the LV's
  2. remove the HD from VM and add this to new VM
  3. 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
  1. swapon /dev/vgname/swap