Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Neil Bothwick believes he
was a supercomputer in a former life.
Q Going virtual
I have a WinXP SP3 installation with all the updates on a hard disk from a PC that has broken down. Is it possible somehow to import that installation into a virtual machine on VirtualBox?
Of course, I could reinstall WinXP and SP3 in a virtual machine, but the above solution would benefit from having all updates (and settings) in place.
Jørn Pedersen
A It is possible to boot a virtual machine from a real hard drive. VirtualBox expects to find virtual disks in VMDK or VDI files, so you have to create a special one of these to point to the real hard disk. Assuming the Windows disk is connected as /dev/sdb, run this command: $ VBoxManage createmedium disk --filename /path/to/winxp.vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/sdb
The --filename option gives the name of the VMDK file to be created – this must be an absolute path. Then add this disk to your list of virtual disks from the Media submenu of the Tools button in the left pane of VirtualBox. Now you can create a WinXP virtual machine in VirtualBox using this ‘virtual disk’. It should work whether the XP disk is internally connected to a SATA port on your computer’s motherboard or put into an enclosure and plugged in externally via USB or eSATA.
You should be able to boot, but there are some potential issues. First, Windows will see that the drive is in a different PC and will probably require re-registration, which should still be possible via the phone option. You may also find you’re missing drivers for some of the virtual hardware. As long as your display and network are available, you can install anything else you need. The display should be fine as it falls back to VESA if nothing else is supported, and the VirtualBox network card is based on generic kit.
If you don’t want to keep a second hard drive connected to your computer, or if you decide to install Windows from scratch and copy over your data and settings, it is possible to mount a virtual drive outside of the virtual machine and copy over any files you want. You first need to install the qemu package; this contains utilities to access virtual disk files. Then run these commands: $ sudo rmmod nbd $ sudo modprobe nbd max_part=8 $ sudo qemu-nbd --connect /dev/nbd0 / path/to/image/vmdk $ sudo partprobe /dev/nbd0 $ sudo mount /dev/nbd0p1 /mount/point