This article shows you step by step how to virtualize an existing Linux partition. Here a physical system installed on a USB stick is converted to a virtual machine.
Create the Virtual Disk Image (VDI)
Open your terminal and run the
dd tool to firtstly create a raw image of your physical system. Then convert with
vboxmanage your raw image to a VirtualBox disk image.
dd if=/dev/sdd of=linux_from_usb.img vboxmanage convertdd linux_from_usb.img linux_from_usb.vdi
Create the virtual machine
Create a new virtual machine as usual.
After defining the machine name and the operating system click on Next and assign your machine a preferred RAM size.
On the next dialog page you’re asked whether to create a new disk or to use an existing one. At this time don’t choose anything but move the created virtual disk image from the first section to the directory of your new virtual machine.
mv linux_from_usb.vdi ~/VirtualBox\ VMs/linux_from_usb/linux_from_usb.vdi
Now choose the disk image which you have just moved to your virtual machine’s directory.
The new virtual machine should appear in the left panel afterwards.
Boot the virtual machine
Now turn on your virtual machine. If your kernel doesn’t boot correctly the reason can be that you had other disks used in your previous system for which you have defined mount points in
/etc/fstab that are no longer available.
In this case boot from a rescue system. You can use an ISO with a bootable linux of your choice, here the Arch Linux ISO was used. You need to add it as a storage in your virtual machine. Therefore right-click linux_from_usb in your virtual machine list and open the settings. In the Storage section you’ll see the storage tree where you have to add your ISO.
When booting from the ISO you need to mount your migrated partition, and edit your file system table.
mount /dev/sda1 /mnt arch-chroot /mnt # edit your mount points vim /etc/fstab
Another fix most probably might be necessary too. Check if there is a SMBus error in your boot log file.
dmesg | grep smbus [ 5.242007] piix4_smbus 0000:00:007.0: SMBus base address unitialized - upgrade BIOS or use force_addr=0xaddr
If you see this, read the article SMBus base address unitialized in order to fix it.