I wanted to convert to my physical home use Xubuntu machine to virtual machine so that I can have the exactly same environment on another machine.
The physical machine has 512G SSD, 50G used disk space. I want to have a virtual machine with a 80G hard disk.
- 3 USB drivers (one for GParted Live CD, one for CloneZilla Live CD and another one for storing the images), the first two can be small, the third one should be bigger than 80G.
- GParted (https://gparted.org/download.php)
- CloneZilla (https://clonezilla.org/downloads.php)
- Tuxboot (https://tuxboot.org/download/)
So here are the steps:
- Create a GParted Live CD using Tuxboot. (https://gparted.org/liveusb.php#linux-method-a)
- Create a CloneZilla Live CD using Tuxboot. (https://clonezilla.org/liveusb.php#linux-method-a)
- [Important] Boot into GParted Live CD, shrink your physical machine partition to 80G (in my case, 80G, 81920M) because CloneZillar cannot restore bigger image to smaller disk.
- Boot into CloneZilla Live CD, backup your partition to your . (https://clonezilla.org/show-live-doc-content.php?topic=clonezilla-live/doc/01_Save_disk_image) Beginner mode is enough, choose partition instead of whole disk.
- Create an empty virtual machine with disk size 81G (a little bit bigger thant 80G, just to be safe).
- Boot the virtual machine with GParted Live CD and create a partition 80G (should be exactly 80G which is 81920M).
- Boot the virtual machine with CloneZilla Live CD and restore the partition from the USB to new created partition in VM. Beginner mode is enough, choose partition instead of whole disk.
- At this point, partition data should be all restored in VM. But VM won’t boot because we need to fix the Grub bootloader. (https://www.fosslinux.com/4477/how-to-repair-the-grub-bootloader-using-a-ubuntu-live-usb-drive.htm)
- Use a Xubuntu Live CD to boot up the Virtual Machine, follow the steps in #8. Basically the commands are:
sudo mount /dev/sda1 /mnt sudo grub-install --boot-directory=/mnt/boot /dev/sda
- [If you are using VMWare] At this point, the vm may boot but maybe there’s some graphical issue like black screen because the VM drivers are not installed. In my case, I need to install open-vm-tools-desktop. (https://linuxhint.com/install-vmware-tools-ubuntu/). Just boot into recovery mode of your vm and enable network and:
sudo apt update sudo apt install open-vm-tools-desktop
- Reboot the VM and everything should work. 🙂