I have a job to P2V a physical Linux machine to a Hyper-V virtual machine. In preparation for this as a test, I installed Ubuntu on a physical PC and then cloned it with clonezilla to a USB hard drive.
In an attempt to clone back to a machine in Hyper-V I did the following:
I plugged the USB hard drive into my Windows 10 laptop (running Hyper-V).
Copied the cloned files folder onto the laptop and created a Windows share
Created a new VM in Hyper-V as a Version 1 Hyper-V machine
Added a virtual hard drive VHDX to the Hyper-V machine that was several GB larger than the original cloned drive
Inserted the clonezilla CD to the VM
Booted the VM to clonezilla and restored from the share
On completion of the restore Clonezilla just says remove the disk and press Enter. When I press Enter it does nothing but scroll a line at a time, i.e. it accepts input but does nothing. I had to hard power off the VM. When it boots again it just gets a black screen with a blinking cursor and will not boot to Ubuntu. I have tried this with 'stable - 2.5.2-31' and 'alternative testing - 20180119-artful' and get the same results.
Am I doing something completely wrong here or is there an obvious reason this is not working?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No. However, looks like the boot loader was not restored or reloaded correctly. You can boot Clonezilla live again, then run:
sudo ocs-install-grub auto
If it does not work, then try to boot Ubuntu installation CD and find the tool from Ubuntu to fix the boot loader.
Steven
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So, finally resolved. The physical box cloned ok, but was the booting that was the issue. I don't claim to fully understand the issue and why it occurred but this is how I fixed it. I have verified that this works on a couple of separate attempts. Also had the same issue with Ubuntu that I fixed in a similar manner.
This might help others with a similar issue.
Cheers,
Tim.
P2V of a CentOS box
PC set disk to legacy BIOS boot (unsure of whether this is required with the latest Clonezilla image as I think it manages UEFI)
Installed CentOS machine on physical PC
Create a Gen 1 Hyper-V machine (not sure Gen 1 is definitely required)
a. Identify disk size on physical box, VM disk needs to be larger
b. Insert Clonezilla ISO, set boot order to CDROM first
c. Disable Checkpoints (won't boot if using a passthrough USB hard drive for this)
d. Attach USB hard drive, ' offline' the disk in disk management, and add it to the VM
Capture machine with Clonezilla to external disk
Restore with Clonezilla
Fails to boot, but sees grub, attempts to boot, goes through the OS progress bar at the bottom of screen, drops to a dracut prompt
Shutdown
Boot to CentOS ISO
a. Select Troublehooting
b. Select Rescue a Centos System
i. Select option 1
Select recovery option 1
a. # chroot /mnt/sysimage # to make the system use the root environment, as per instruction on screen
b. # cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
c. # dracut -f
d. # exit
e. # shutdown
All appears to be working
Power off VM
Resize disk with partition editor in Ubuntu
Done
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You’ll need to boot from a live CD or USB drive, as in the graphical method above. Ensure the version of Ubuntu on the CD is the same as the version of Ubuntu installed on your computer. For example, if you have Ubuntu 14.04 installed, ensure you use a Ubuntu 14.04 live CD.
Open a terminal after booting into the live environment. Identify the partition Ubuntu is installed on using one of the following commands:
sudo fdisk -l
sudo blkid
In the fdisk -l command, the Ubuntu partition is identified by the word Linux in the System column. In the blkid command, the partition is identified by its ext4 file system.
If you have multiple Linux ext4 partitions, you can get an idea of which is which by viewing the size of the partitions and their order on the disk here.
Run the following commands to mount the Ubuntu partition at /mnt/ubuntu, replacing /dev/sdX# with the device name of your Ubuntu partition from the above commands:
sudo mkdir /mnt/ubuntu
sudo mount /dev/sdX# /mnt/ubuntu
sda1 means the first partition on the first hard disk device.
Important: If you have a separate boot partition, skip the above command and mount the boot partition at /mnt/ubuntu/boot instead. If you don’t know whether you have a separate boot partition, you probably don’t.
Run the following command to reinstall grub from the live CD, replacing /dev/sdX with the device name of the hard disk above. Omit the number. For example, if you used /dev/sda1 above, use /dev/sda here.
I have a job to P2V a physical Linux machine to a Hyper-V virtual machine. In preparation for this as a test, I installed Ubuntu on a physical PC and then cloned it with clonezilla to a USB hard drive.
In an attempt to clone back to a machine in Hyper-V I did the following:
On completion of the restore Clonezilla just says remove the disk and press Enter. When I press Enter it does nothing but scroll a line at a time, i.e. it accepts input but does nothing. I had to hard power off the VM. When it boots again it just gets a black screen with a blinking cursor and will not boot to Ubuntu. I have tried this with 'stable - 2.5.2-31' and 'alternative testing - 20180119-artful' and get the same results.
Am I doing something completely wrong here or is there an obvious reason this is not working?
Thanks.
No. However, looks like the boot loader was not restored or reloaded correctly. You can boot Clonezilla live again, then run:
sudo ocs-install-grub auto
If it does not work, then try to boot Ubuntu installation CD and find the tool from Ubuntu to fix the boot loader.
Steven
Thanks Steven, I will try this and update with the outcome.
So, finally resolved. The physical box cloned ok, but was the booting that was the issue. I don't claim to fully understand the issue and why it occurred but this is how I fixed it. I have verified that this works on a couple of separate attempts. Also had the same issue with Ubuntu that I fixed in a similar manner.
This might help others with a similar issue.
Cheers,
Tim.
P2V of a CentOS box
a. Identify disk size on physical box, VM disk needs to be larger
b. Insert Clonezilla ISO, set boot order to CDROM first
c. Disable Checkpoints (won't boot if using a passthrough USB hard drive for this)
d. Attach USB hard drive, ' offline' the disk in disk management, and add it to the VM
a. Select Troublehooting
b. Select Rescue a Centos System
i. Select option 1
a. # chroot /mnt/sysimage # to make the system use the root environment, as per instruction on screen
b. # cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
c. # dracut -f
d. # exit
e. # shutdown
Ubuntu was fixed via the commands at the bottom of this post
https://www.howtogeek.com/114884/how-to-repair-grub2-when-ubuntu-wont-boot/
Ubuntu not booting, no Grub:
You’ll need to boot from a live CD or USB drive, as in the graphical method above. Ensure the version of Ubuntu on the CD is the same as the version of Ubuntu installed on your computer. For example, if you have Ubuntu 14.04 installed, ensure you use a Ubuntu 14.04 live CD.
Open a terminal after booting into the live environment. Identify the partition Ubuntu is installed on using one of the following commands:
sudo fdisk -l
sudo blkid
In the fdisk -l command, the Ubuntu partition is identified by the word Linux in the System column. In the blkid command, the partition is identified by its ext4 file system.
If you have multiple Linux ext4 partitions, you can get an idea of which is which by viewing the size of the partitions and their order on the disk here.
Run the following commands to mount the Ubuntu partition at /mnt/ubuntu, replacing /dev/sdX# with the device name of your Ubuntu partition from the above commands:
sudo mkdir /mnt/ubuntu
sudo mount /dev/sdX# /mnt/ubuntu
sda1 means the first partition on the first hard disk device.
Important: If you have a separate boot partition, skip the above command and mount the boot partition at /mnt/ubuntu/boot instead. If you don’t know whether you have a separate boot partition, you probably don’t.
Run the following command to reinstall grub from the live CD, replacing /dev/sdX with the device name of the hard disk above. Omit the number. For example, if you used /dev/sda1 above, use /dev/sda here.
sudo grub-install --boot-directory=/mnt/ubuntu/boot /dev/sdX
Restart your computer and Ubuntu should boot properly.