Physical To Virtual (P2V) using VirtualBox

J

Jarret W. Buse

Guest
Physical To Virtual (P2V) using VirtualBox

Some people may want to run their existing system on another. Others may want to test an existing environment with specific apps or even updates. There may be many reasons to move an existing environment from one machine to another, or even the same, under VirtualBox.

The process may take a little time and plenty of disk space. For this procedure to work you will need:

  1. VirtualBox from Oracle at https://www.virtualbox.org/wiki/Downloads
  2. Super GRUB 2 ISO at http://www.supergrubdisk.org/category/download/supergrub2diskdownload/super-grub2-disk-stable/ (needed only if your disk or partition does not contain GRUB or some boot loader; leave as an ISO)
  3. Clonezilla at http://clonezilla.org/downloads.php placed on bootable media
  4. Plenty of drive space
VirtualBox should be installed on the system to which you want to run the virtualized Operating System (OS). Super Grub should also be copied to the system with VirtualBox to be used for booting the virtual image if the partition or disk does not contain the boot files.

The drive space needed for the backup must be accessible to Clonezilla for a backup to be performed.

The first step is to boot the system with the OS to virtualize installed with Clonezilla. Once booted, perform a backup as follows:

  1. Boot the system with Clonezilla
  2. At the menu, select “Clonezilla Live”
  3. Choose your language when prompted
  4. Select your desired keymap as needed
  5. At the menu, select “Start_Clonezilla”
  6. Specify “device-image”
  7. Select “local_dev” to save the image to a local device (NOTE: if you need to save it somewhere else, make the proper selection)
  8. When asked to connect USB devices, do so and then press “Enter”
  9. Choose the desired drive or partition to save the image
  10. A directory structure will be shown for the selected drive or partition. Select the appropriate folder in which to place the backup image
  11. A listing of disk space usage for the selected location will be displayed. Press “Enter”
  12. Choose “Expert” for the backup mode
  13. Select savedisk (when backing up a whole disk), or savepart (when backing up a single partition) - for my example, I am using savepart so some prompts may be a little different
  14. A prompt for the name of the backup is required. Remove the existing information and give it a simple name like “LinuxBack”. The name given is the folder name in which the backup files are placed. Remember the name so you know the location of the backup files
  15. A listing of existing drives and/or partitions will be listed. Highlight the one to backup, press “spacebar” and then “enter”
  16. At the next menu, select -q1 for a dd backup
  17. The next menu shows various parameter options to select. By default, the -c and -j2 are checked. The defaults are fine unless you require others
  18. When prompted for the compression type, select -z0
  19. At the next menu when prompted about splitting the file, make sure the size is larger than the drive or partition being backed up
  20. Select the option to “Skip checking/repairing source file system”, unless you believe it is necessary
  21. At the next menu select to skip checking the saved image file
  22. For the action to perform when the backup is completed, select what you prefer
  23. At this point, the options are set and the command-line should be listed which is being executed to perform the backup. Press “enter”
  24. You are prompted if you want to continue and perform the backup, so press “y” and then “enter”
  25. The backup should begin
  26. Exit Clonezilla when the backup is completed and copy the directory specified in option 14 to the system with VirtualBox, if the virtual system will be run on another system, and be sure to include the directory itself (in my example it would be called LinuxBack)

Once the backup folder and files are moved to the system with VirtualBox installed, perform the following command:

  • VboxManage convertfromraw --format VDI source.img target.vdi
The source is the file in the backup folder which should end with .aa. In my example it should be in a folder call LinuxBack. The partition I backed up was partition sda5. The filename was “sda5.dd-img.aa”. The file can be renamed to “sda5.dd-img.img” or any other name, or leave it as it is. The targe.vdi file can be named whatever you like, but try to keep it simple. For example, the command could be “VboxManage convertfromraw --format VDI sda5.dd-img.aa sda5.vdi” to create a VDI file from the backup image.

The conversion from the image to a VDI file can take quite some time. The larger the image file, the longer the conversion can take.

Once done, you can open VirtualBox and create a new session. Set it up according to the physical system you are virtualizing. Set the hard drive to point to the VDI file created. Set the CD/DVD to point to the Super GRUB 2 ISO file. When the system boots select “Everything” and then, on the next menu, select the option for your kernel (should be the second line in the list). The system should start as normal.

If an error occurs similar to “The disk drive for UUID=### is not ready yet or not present.”, press “s” to skip the error until the OS loads. Once loaded, open an editor with root privileges and edit /etc/fstab to comment out with '#' any drive which is not accessible to the OS.
 

Attachments

  • slide.jpg
    slide.jpg
    17.6 KB · Views: 31,950


This is a great article and should be recommended reading for people who are new to Linux. I am going to use this tutorial and make a VM on my current Linux partition (I have a dual boot with Windows 8.1) and whenever I come to a tutorial for tweeking something, I can do it in the VM, rather than my running version. I am afraid of doing something that will make my current system inoperable and have to do a complete re-install. If anything bad should happen, it only happens in the VM and not on my "live" system.
I am not really clear on the use of Super Grub 2. With the dual boot, I have Grub as my boot manager, but my VM's are going to be on a separate drive. (My DVD drive broke and I now use it as an extra HDD - it only have 149GB, but will be replacing it with 1TB next week) Will having my VM on a drive that doesn't have a boot loader make a difference?

My current specs are this
1st and bootable drive =256 GB SSD
175GB -NTFS (Windows "c:")
20GB = "/"
34GB ="/home"
2nd internal 149GB HDD
90GB NTFS (windows "d:")
59GB - extended extra space for Linux

The 59 GB drive/partition is going to change to 500GB and will hold /home and /var and extra space to put VM's. The rest will go to Windows "d:". Will this drive require "Super Grub 2" since it's only holding files and no booting partition (except for what's saved in the VM creation)? I have never created a VM before, but do have Oracle VBox installed.

I am planning on deleting my Linux partition and install a different distro than I currently have. I have Linux Mint and thought about just installing Linux Mint Deb Edition and bypass the layer of "Ubuntu", but still stay with a new user friendly edition of a Deb distro. I also read your article on SSDs and I did not have the information on alignment, so I want to set my SSD up correctly, following your advice in the article. (great one by the way).

Thank you for any advice you can give/recommend. :)
 
This is a great article and should be recommended reading for people who are new to Linux. I am going to use this tutorial and make a VM on my current Linux partition (I have a dual boot with Windows 8.1) and whenever I come to a tutorial for tweeking something, I can do it in the VM, rather than my running version. I am afraid of doing something that will make my current system inoperable and have to do a complete re-install. If anything bad should happen, it only happens in the VM and not on my "live" system.
I am not really clear on the use of Super Grub 2. With the dual boot, I have Grub as my boot manager, but my VM's are going to be on a separate drive. (My DVD drive broke and I now use it as an extra HDD - it only have 149GB, but will be replacing it with 1TB next week) Will having my VM on a drive that doesn't have a boot loader make a difference?

My current specs are this
1st and bootable drive =256 GB SSD
175GB -NTFS (Windows "c:")
20GB = "/"
34GB ="/home"
2nd internal 149GB HDD
90GB NTFS (windows "d:")
59GB - extended extra space for Linux

The 59 GB drive/partition is going to change to 500GB and will hold /home and /var and extra space to put VM's. The rest will go to Windows "d:". Will this drive require "Super Grub 2" since it's only holding files and no booting partition (except for what's saved in the VM creation)? I have never created a VM before, but do have Oracle VBox installed.

I am planning on deleting my Linux partition and install a different distro than I currently have. I have Linux Mint and thought about just installing Linux Mint Deb Edition and bypass the layer of "Ubuntu", but still stay with a new user friendly edition of a Deb distro. I also read your article on SSDs and I did not have the information on alignment, so I want to set my SSD up correctly, following your advice in the article. (great one by the way).

Thank you for any advice you can give/recommend. :)

Thanks for your interest in this article. I hoped someone would find it useful!
You only need the GRUB ISO if your original physical image did not have a boot loader. If GRUB was the bootloader and it was not included in the backup, then you would also need it. The only reason for the GRUB ISO is if the partition or disk you want to virtualize did not contain a bootloader. Basically, perform the steps as described and try to boot from it. If it does not boot, then you will need the GRUB ISO.
Hope this helps. Let me know. There is another article for going from Virtual to Physical. Keep a watch for it.
 
Okay, I think I understand now.
For instance, I have a dual boot with Windows and Linux, and even though Grub is in my MBR and not in my Linux partition , I would need to include the Grub2.iso in order for my VM to be able to boot.
 
I am planing to convert physical machines (Running Windows) to virtual ones to run on VirtualBox.
I believe the steps above will work for me, will they?
 

Members online


Top