I am trying to migrate a Linux PC to a virtual machine running in XenServer. Normally I would just create an image of the boot disk (/dev/sda) with dd and use that to overwrite an empty virtual disk image. Unfortunately the boot disk is rather large and therefore I only created an image of the boot partition (/dev/sda1) which is only about 250 GB. I then created a new virtual disk of 500 GB, attached it to an existing Linux virtual machine (/dev/xvdc), partitioned it to create a primary partition (/dev/xvdc1) and dd'd the partition image to that.
I could mount that partition. The files were where I expected them, but of course the grub boot code was missing.
So I used the method described in How to chroot Ubuntu using Live CD to fix GRUB rescue prompt to install grub on /dev/xvdc.
$ sudo su
$ mount /dev/sdax /mnt/newroot
$ mount ‐‐bind /dev /mnt/newroot/dev
$ mount ‐‐bind /proc /mnt/newroot/proc
$ mount ‐‐bind /sys //mnt/newroot/sys
$ chroot /mnt/newroot
$ grub-install /dev/xvdc
It seemed to work fine, no error messages were displayed.
Now I attached the new virtual disk to a new virtual machine as the the only drive and tried to boot it. No such luck. I do not get any error message, no grub prompt, it simply starts and then stops.
EDIT: There was an error message, I just overlooked it:
"The Bootloader for this VM returned an error -- did the VM installation
succeed? INVALID_SOURCE
cdrom repo
/dev/sm/backend/[some long number, probably a GUID]
What am I missing here?
EDIT: Attaching the virtual drive to an existing Linux virtual machine solved the problem. I got it to boot from that drive, made a full copy of that VM and finally reverted the original back to its original boot drive.
That still leaves the question: Why did XenServer insist on trying to boot from a non existing DVD?