HOWTO: manage VDIs and import native installations

This is for discussing general topics about how to use VirtualBox.
Post Reply
Posts: 731
Joined: 22. Aug 2007, 10:13
Location: Germany

HOWTO: manage VDIs and import native installations

Post by Ingo »

Still working on this.
 Edit: more.

1. Introduction
First of all.
There are some chances to destroy them.

I've decided to migrate completely to Linux and run still needed Windows installations only in VirtualBox. So I have to convert my Windows Installations to Virtual Disk Images and manage these VDIs, e.g. increase, decrease or change their type from dynamically expanding to fixed-size etc. I have summarized my experience and information to this here in the hope it may also be helpful for others.

In my examples below I use a Debian etch host system with Windows XP as guest, so Ubuntu should also work direct with them. But with another environment please adapt them to your needs.

First solutions I have posted here:
modify a VDI
import native WinXP

Here is another solution from rcman80:

litemotiv describes another way with HDClone (freeware 4mb) on this topic page 2:

Aaron_Mason describes an interesting way to convert from vmware to VirtualBox with rsync:

This howto assumes that we already have an image.vdi but don't declare how to get it.

Many thanks to QBikal for his excellent work to the internals of a virtual disk image!

I've tried to use
VBoxManage convertdd <filename> <outputfile>
VBoxManage convertdd stdin <outputfile> <bytes>
with documentation at
I do this:

Code: Select all

$ VBoxManage convertdd raw.img .VirtualBox/VDI/MyImage.fix.vdi
VirtualBox Command Line Management Interface Version 1.5.0
(C) 2005-2007 innotek GmbH
All rights reserved.

Converting VDI: from DD image file="/home/ingo/raw.img" to file=".VirtualBox/VDI/MyImage.fix.vdi"...
Creating fixed image with size 10010165760Bytes (9547MB)...
If I attatch the converted VDI as primary slave disk drive to a running WinXP VM and try to access it I get:

Code: Select all

C:\Documents and Settings\Ingo>dir D:
The volume does not contain a recognized file system.
Please make sure that all required file system drivers are loaded and that the volume is not corrupted.
C:\Documents and Settings\Ingo>
It seems there is only copied a raw image into a virtual disk without any file system information to the virtual machine.

2. Abstract
Independent of the current used operating systems you should be able to adapt my examples below to your needs if you understand the general procedure.

1. Do everything with the target operating system, e.g. partition and format virtual disks, copy data etc.

2. attach the source disks and the target disks as second and third passive devices to your managing virtual machine. So it is ensured that there are no files in access.

3. Modify a Virtual Disk Image
This is the basic procedure. You copy all data from the old VDI to a new one and use that instead of the old one. Dependent on how you create the new one (bigger, smaler, new type) you can increase, decrease or modify the type of the VDI.

1. have a managing WinXP virtual machine
2. create a new VDI of the size and type you want
3. detach your working VDI from your working VM
4. attach your working VDI to the managing VM as primary slave
5. attach the new (modified) VDI to the managing VM as secondary slave
6. start the managing VM
7. partition and format the target drive F: (the new modified one!)
8. don't forget to set it active (set boot flag) in the disk manager if you want to boot from it later
9. to really copy all flags and whistles I use

Code: Select all

xcopy D:\ F:\ /s /e /c /g /h /k /o /x /y >xcopy.log 2>&1
you should get one error message "Access denied" for the "System Volume Information" folder. if you get more then something is going wrong. Check it in xcopy.log (search "Access denied").

10. shut down the managing VM
11. detach the new (modified) VDI from the managing VM
12. attach the new (modified) VDI to your working VM as primary master
13. start your working VM with the modified virtual disk

that's it and only some clicks except the boring wait for xcopy.

4. Import a native installation from a physical disk partition
The trick is to access the physical disk partition in the managing VM through raw hard disk access and copy that data into a virtual disk image.

1. have a managing WinXP virtual machine
2. create a writethrough virtual disk for the physical partition. You must be a member of the group disk (there are NO line breaks!)

Code: Select all

VBoxManage internalcommands createrawvmdk -filename .VirtualBox/VDI/WinXPraw.vmdk -rawdisk /dev/hd[a..z] -partitions [1..9] -relative
Attention! Read carefully VirtualBox User Manual chapter 9.9!
Warning: Raw hard disk access is for expert users only. Incorrect use or use of an outdated con?guration can lead to total loss of data on the physical disk. Most importantly, do not attempt to boot the partition with the currently running host operating system in a guest. This will lead to severe data corruption.
3. create a target disk image that can hold all stored files from the physical partition
4. attach the physical disk as primary slave
5. attach the target disk image as secondary slave
follow step 6. to 11. from section 3.
12. create a new VM with the coppied virtual drive as primary master
13. mount the Windows Setup CD
14. repair your copy, see

that's it and should always work as long as repair does it.

5. Import a native installation from a raw disk image
This is a little bit sophisticated because we can't access the raw image directly in a virtual machine to copy its data into a VDI. A raw disk image is something like made with dd, e.g.

Code: Select all

$ sudo dd if=/dev/hda1 of=raw.img
We have to copy the raw data into a VDI-structure outside a running virtual machine. The post from QBikal is very helpful. Thanks again.

1. have a managing WinXP virtual machine
2. Have the raw image
3. Create a fixed-size virtual disk image a little bit greater than your raw image (e.g. raw image = 10 GB, vdi = 11 GB). For further use it is important to use fixed-size!
4. Attach this new empty VDI to the managing machine as primary slave
5. start the managing VM
6. partition and format the fixed-size drive D: (the empty one!)
7. don't forget to set it active (set boot flag) in the disk manager if you want to boot from it later
8. shut down the managing VM
9. Grep the magic string "eb 52 90 4e 54 46 53" (= ".R.NTFS") with hexdump from the first MB of the VDI to get the offset the raw data starts at. The cryptic options for hexdump are only to get the offset in decimal and not in default hex (there are NO line breaks!).

Code: Select all

$ hexdump -n 1000000 -e '"%08.8_ad  " 16/1 "%02x " "\n"' ".VirtualBox/VDI/MyImage.fix.vdi" | grep "eb 52 90 4e 54 46 53"
Output (example from my VDI):

Code: Select all

00077824  eb 52 90 4e 54 46 53 20 20 20 20 00 02 08 00 00
Here the offset is 00077824

10. Copy your raw image into the VDI at the found offset. This only works with a fixed-size virtual disk image! (there are NO line breaks!)

Code: Select all

$ dd if=raw.img of=.VirtualBox/VDI/MyImage.fix.vdi obs=77824 seek=1
11. Create a working virtual disk image that can hold all data of your raw image. It can be a dynamically expanding image and you can choose a size of your need. It must not be the same size as your raw image.
12. Attach this working VDI to the managing machine as Secondary Slave.
13. Boot into the managing machine and check if the fixed VDI shows the copied data. You should do any check/repair actions on it. For this example I do:

Code: Select all

chkdsk D: /f
follow step 7. to 11. from section 3.
follow step 12. to 14. from section 4.
That's it.

I have tried to repair the fixed-size VDI in the VM after step 10. above and boot it but with no success.

Code: Select all

C:\Documents and Settings\Ingo>diskpart.exe

Microsoft DiskPart version 5.1.3565

Copyright (C) 1999-2003 Microsoft Corporation.
On computer: MyVM

DISKPART> select volume 2

Volume 2 is the selected volume.

DISKPART> extend

DiskPart failed to extend the volume.
Please make sure the volume is valid for extending.

C:\Documents and Settings\Ingo>
I think the reason is that the drive size is greater than the file system size and the disk geometry will not fit.

Hope I haven't made a mistake in my description. For me it works. 
Last edited by Ingo on 8. Jan 2009, 14:02, edited 3 times in total.
Posts: 731
Joined: 22. Aug 2007, 10:13
Location: Germany

Problems and Solutions

Post by Ingo »

Problems and Solutions
P: After cloning an installation from a physical partition (section 4.) the WinXP Setup CD does not provide a repair option.
S: I imported the second partition from a dual boot installation. The essential boot files boot.ini, ntldr, NTDETECT.COM are only reside on the first boot-parttition. I copied these files to the drive (partition) I want to import and copied the drive again into a virtual disk image (section 4.).

P: After cloning an installation from a physical partition (section 4.) I repaired it successful. But he boot process fails with a BSOD complaining about intelppm.sys.
S: Disable intelppm.sys
Posts: 16
Joined: 29. Dec 2008, 20:27

Boot halts on MUP.sys

Post by pacut »


I have followed instruction from manual (9.9.2 Access to individual physical hard disk partitions) and have created the VMDK file from raw phisical partition, then I have created the VM using such file. The fact is....XP halts on MUP.sys driver during the boot.

Linux host: kubuntu 8.10
XP guest already working in dual boot from first HD partition
Vbox 2.10
PC Intel dual core 3GhZ with 2G RAM
1GB ram dedicated to VM

What else you may need ? Please let me know.
I am trying to get rid of this problem. FYI when I create a new VM from scratch (by installing a new XP OP) everything works fine ;(((

Posts: 731
Joined: 22. Aug 2007, 10:13
Location: Germany

Post by Ingo »

Hi Paolo,
it's over a year ago I used it this way and I'm not so familiar with the newest version of VirtualBox. So I'm afraid I can't really help you. But nevertheless let me try to understand your problem.
You have made a VMDK to access a physical partition on your hard drive. Then you created a virtual machine which used the physical partition (not a disk image file) as its hard drive. What is on the partition? Did you install the operating system in your VM to the partition? Or is there an "old" OS installation and you try to boot it with a virtual machine? The latter won't work because there is a completely different (virtual) hardware.
The simplest way to a complex system is to start with a simple system.
Posts: 16
Joined: 29. Dec 2008, 20:27

Post by pacut »

Ingo, thenaks for your quick reply.

Yes, I am trying to use an "old" XP already installed into my PC. I understood it was possible, since paragraph 9.2.2 stated that. I guess I am wrong ;(((

Anyway...thanks !
Posts: 321
Joined: 31. May 2008, 10:00
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WinXP, RedHat, Ubuntu

Post by kebabbert »

I think that "abstract" should summarize what your article is about. Give a high level description so you very quickly can find out if this paper is for you.
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Post by Sasquatch »

Check the sticky in the Windows Guests forum. That has a more recent howto on how to accomplish this.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions

Retired from this Forum since OSSO introduction.
Posts: 1
Joined: 5. Jun 2009, 19:30
Primary OS: Ubuntu 8.04
VBox Version: PUEL
Guest OSses: XP

Re: HOWTO: manage VDIs and import native installations

Post by trefenwyd »

Hi all. Ubuntu host and windows xp guest. Unfortunately I found this guide too late. I used another one found through google and that is what I did:

- create 2 hardware profiles in the windows xp native
- add the ubuntu user to the disk group.
- create vmdk file with VBoxManage
- register it in the virtual disks
- start virtualbox and boot into windows xp

it is working inside virtualbox and it boots. The only problem is that I cannot get the ethernet /internet to work. ANy hint?

The other problem is that if I try to boot windows natively, it freezes at startup screen and not responding in any way (even the reset button or the hardware on/of button), the only way to restart is to unplug power cable.

Any help? thanks in advance
Posts: 5
Joined: 12. Aug 2012, 08:29

Re: HOWTO: manage VDIs and import native installations

Post by musenwoody »

It is very helpful!
Post Reply