Cloning a PC to a new HD over the network
Jump to navigation
Jump to search
This method works if you want to clone a server to a new virtual machine
- mount HD in VM (rightclick VM, edit settings, 'add' new device and create a new HD)
- ensure rsync is on both machines
- ensure ssh allows root logins on machine to back up
- recreate the LVM structure on HD. Ensure there is a non-LVM partition for /boot where we can put the MBR on later
- also make sure there is an LV or a HD partition for swap. Then
mkswap /dev/vg/swap
- mount the LVs under /mnt/. First mount root, create the subdirs and then mount the rest
- 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)
- edit the /mnt/etc/fstab to reflect the new LV names
- vi /boot/grub/menu.lst or grub.cfg to reflect the new LV names
mkdir /var/, /sys/, /dev/
- give the temp dir the right names:
chown root:root /mnt/tmp/ chmod 1777 /mnt/tmp/
- unmount the LV's
- remove the HD from VM and add this to new VM
- 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)
- mount all drives
- Install grub bootloader
update-grub grub-install /dev/sda
- swapon /dev/vgname/swap