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:
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:
Once the backup folder and files are moved to the system with VirtualBox installed, perform the following command:
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.
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:
- VirtualBox from Oracle at https://www.virtualbox.org/wiki/Downloads
- 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)
- Clonezilla at http://clonezilla.org/downloads.php placed on bootable media
- Plenty of drive space
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:
- Boot the system with Clonezilla
- At the menu, select “Clonezilla Live”
- Choose your language when prompted
- Select your desired keymap as needed
- At the menu, select “Start_Clonezilla”
- Specify “device-image”
- Select “local_dev” to save the image to a local device (NOTE: if you need to save it somewhere else, make the proper selection)
- When asked to connect USB devices, do so and then press “Enter”
- Choose the desired drive or partition to save the image
- A directory structure will be shown for the selected drive or partition. Select the appropriate folder in which to place the backup image
- A listing of disk space usage for the selected location will be displayed. Press “Enter”
- Choose “Expert” for the backup mode
- 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
- 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
- A listing of existing drives and/or partitions will be listed. Highlight the one to backup, press “spacebar” and then “enter”
- At the next menu, select -q1 for a dd backup
- 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
- When prompted for the compression type, select -z0
- At the next menu when prompted about splitting the file, make sure the size is larger than the drive or partition being backed up
- Select the option to “Skip checking/repairing source file system”, unless you believe it is necessary
- At the next menu select to skip checking the saved image file
- For the action to perform when the backup is completed, select what you prefer
- At this point, the options are set and the command-line should be listed which is being executed to perform the backup. Press “enter”
- You are prompted if you want to continue and perform the backup, so press “y” and then “enter”
- The backup should begin
- 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 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.