Accessing raw partitions with VMDK (VirtualBox 1.4)

This is for discussing general topics about how to use VirtualBox.

Postby BrianC » 2. Jul 2007, 20:45

Hi all,

I followed the instructions in this thread and am still failing to get my Windows XP partition to load in VirtualBox. After creating a vmdk for the whole disk (ide), LILO loads and I can select my Windows install, but the console just prints "Loading Windows" and then nothing else happens. When trying with a vmdk with only the two FAT/NTFS partitions, I get a whole bunch of "99"s printing and then nothing.

I have run the MergeIDE utility and changed the name of agp440.sys. I have tried every combination of io acpi. I did not try with the -mbr option, which is probably why the partition-only vmdk didn't work?

Could anyone help me with this? I'm happy to post the logs if necessary.

Posts: 1
Joined: 2. Jul 2007, 20:37

Postby klaus » 3. Jul 2007, 09:25

You're right with your suspicion. If you just give the guest OS access to the windows partitions and you have lilo/grub in the MBR, they fail to load their main part, as this is in one of the not accessible partitions. There is not much VirtualBox can do except providing the -mbr option which allows replacing the MBR which the guest OS sees.

Windows guest hangs (only for existing installations from raw partitions) at a very early stage are sometimes caused by not enabling the IO-APIC in VirtualBox. But that's described in the migration howto in our wiki.
Oracle Corporation
Posts: 573
Joined: 10. May 2007, 14:57

partition problem

Postby tocer » 12. Jul 2007, 15:39

Hi all,

I followed the instructions in this thread and create a vmdk file refer a partition with option "-partitions 2,7" . it success. But when I install winXP guest in my Ubuntu. I found XP list all partitons in my disk. I wish it list a sepcial partition like sda7 only. I don't know what's wrong.

Does anybody help me?
Posts: 3
Joined: 12. Jul 2007, 15:24

Postby klaus » 12. Jul 2007, 20:00

The partitions are all visible, but only the configured ones are writable (for the others writes are ignored and reads just give zero data). This is done deliberately as guest OSes cannot deal with disks that have holes in them. Also it's not possible to "compact" such a disk, because otherwise sector references wouldn't be correct any more.

Making partitions invisible would potentially change the drive letters (windows guests) or partition numbering (linux guests), so this is the only option.

If you want you can change the partition table (in the guest only of course) at your will. The host won't notice - as long as you really configured raw partition and not raw disk access.
Oracle Corporation
Posts: 573
Joined: 10. May 2007, 14:57

Postby tocer » 13. Jul 2007, 10:26

thank your help.

if I configured raw partition, I could do anything include delete and add partition in guest, and the data in other partition don't be destroyed, isn't it?

btw, how much using raw partition speed? 1x or 2x. I'm thinking if it is worth to run risk of losing data to use raw partition
Posts: 3
Joined: 12. Jul 2007, 15:24

Postby klaus » 13. Jul 2007, 16:25

Sorry, answering repartitioning questions is way too risky with your apparent skill level (my impression might be wrong, though). You can easily destroy the contents of the partitions made available to the guest.

And just doing raw partitions for getting rid of the filesystem overhead seems excessive to me. In normal situations raw partitions definitely won't double your performance. More likely is a few percent improvement.
Oracle Corporation
Posts: 573
Joined: 10. May 2007, 14:57

Postby tocer » 14. Jul 2007, 03:20


Thank you very much. I decide not to use raw patition.
Posts: 3
Joined: 12. Jul 2007, 15:24

Postby kengrome » 31. Jan 2008, 12:38

Hi Klaus,

I want to run a CGI script in WinXP guest, then edit it in Linux host, then run it again in WinXP guest to see how my changes work, then edit it again in Linux host, etc.

I thought that setting up raw disk access or raw partition access might be the solution I need, but now I am not so sure. Can you suggest the best solution for me? Thanks in advance ... :)
Posts: 2
Joined: 31. Jan 2008, 03:06

Can not boot WinXP raw partition on Linux host.

Postby woomg » 21. Feb 2008, 10:05

I 'm failed to tart VirtualBox on Linux host. I followed all of instruction in this thread and still failing to get my WinXP partition to load. I think this is harddisk problem. Would you please help me to solve this?(Sorry for ugly english, I am not native of English)

System : HP NX6330 Notebook
CPU : Centrino Duo
HDD : SATA2 250GB Western Digital
Host : Ubuntu Gusty 7.10 AMD64

Here is my partition table.
Code: Select all   Expand viewCollapse view
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00026b3f

 Device   Boot   Start      End       Blocks    Id  System
/dev/sda1            1       28       224878+   83  Linux
/dev/sda2  *        29     2830     22507065     7  HPFS/NTFS
/dev/sda3         2831     5630     22491000     7  HPFS/NTFS
/dev/sda4         5631    30401    198973057+    5  Extended
/dev/sda5         5631     7000     11004493+   83  Linux
/dev/sda6         7001    18000     88357468+    7  HPFS/NTFS
/dev/sda7        18001    29500     92373718+    7  HPFS/NTFS
/dev/sda8        29501    30360      6907918+    7  HPFS/NTFS
/dev/sda9        30361    30401       329301    82  Linux swap

I am using GRUB with chain loading.
sda1 is Linux /boot partition
sda2 is Windows XP partition
sda3 is Windows Vista partition

My goal is make VM setup file with raw partitons like:
Code: Select all   Expand viewCollapse view
VBoxManage internalcommands createrawvmdk -filename ** -rawdisk /dev/sda -partitions 2,6,7,8 -relative -mbr winxp.mbr

But, first I am tried with whole /dev/sda disk to use GRUB loader because I haven't winxp mbr file yet.

BTW, I'm failed!!!! VirtualBox showup the GRUB screen, and I select and enter the WinXP than VirtualBox just showed BLACK SCREEN. No more messages or screen. If I select the Vista partition, VirtualBox showup the 'detect the hardware chaged' messages, and error about 'system does not support the 64 bit operation system'(because I am installed Vista 64bit edition).

Of course, I am enabled the "ACPI" and "IO APIC" options and modified the WinXP harddisk settings by MergeIDE utility. And, my system do not load the AGP440 driver at boot time.

Strange point: VMDK does not recorgnized the number of cylinders over than 1024.

Posts: 1
Joined: 21. Feb 2008, 09:30

Postby gandalf » 5. Mar 2008, 17:55

I had the very same problem and came to the conclusion it's caused by the DOS MBR code having trouble accessing the hard disk on VirtualBox.
I circumvented this by creating a floppy disk image with a self-contained grub install and use this for booting my native WinXP Pro install into a virtual machine running on a linux host. The menu.lst needs an entry for chainloading the ntldr. This way I'm able now to do both natively boot the XP and boot it in the virtual machine.
I may post some details in case there is any interest.

Posts: 2
Joined: 5. Mar 2008, 17:42

Using a grub floppy image for booting raw partitions in vbox

Postby gandalf » 20. Mar 2008, 15:41

There were some requests to post detailed information about what I did to boot a raw windows partition using a self contained grub floppy image. I was booting a raw Windows XP install into a vbox VM running on RHEL5.

Here is what I did:

1. Create an empty floppy image:
Code: Select all   Expand viewCollapse view
dd if=/dev/zero of=grub_floppy.img bs=1440k count=1
losetup -f grub_floppy.img
mkfs -V -t msdos /dev/loopX (use losetup -a to figure out which loop device the image got connected to)

2. Copy the Grub files to it
Code: Select all   Expand viewCollapse view
mount /dev/loopX /mnt
mkdir -p /mnt/boot/grub
cp -a /boot/grub/* /mnt/boot/grub/

3. Create a new (blank) menu.lst at /mnt/boot/grub/ and add a entry for booting the ntldr from your windows partition to boot. Mine looks as follows:
Code: Select all   Expand viewCollapse view
title Windows running in Virtual Box
        root (hd0,0)
        chainloader /ntldr

The only thing you may have to change is the root partition to match your configuration.

4. Unmount the floppy image
Code: Select all   Expand viewCollapse view
umount /mnt

5. Install grub in the MBR of the floppy image
Code: Select all   Expand viewCollapse view
echo "(fd0) /dev/loopX" > device_map.tmp
grub --device-map=device_map.tmp

In the grub shell that comes up enter the following commands:
Code: Select all   Expand viewCollapse view
root (fd0)                                                                                 
install /boot/grub/stage1 d (fd0) (fd0)/boot/grub/stage2 0x8000 p (fd0)/boot/grub/menu.lst

6. Configure the created image as floppy for your Virtual Box VM. You may also create an ISO using the floppy image for the Eltorito image thus creating a bootable CD.

I hope those short instructions are of any help. Let me know if I'm missing something.

Have fun,
Posts: 2
Joined: 5. Mar 2008, 17:42

Postby Isahn » 16. Apr 2008, 22:30

nuudles wrote:Like I said, you should try this:

chmod 666 /dev/sda*

I think your problem is the permissions on /dev/sda and not /dev/sda2

thanks dude!! you give me the right clue!

However is not necessary to change ALL the dev file permissions with sda*. If you want vbox access, for example, /dev/sda2 should be enough

chmod 666 /dev/sda

Or, at least, that's works for me
Posts: 1
Joined: 16. Apr 2008, 22:20

Postby guyr » 14. Jul 2008, 07:21

I'm actually running 1.6.2 now on a Windows XP host, but thought I'd continue on with this thread. Good news is that in 1.6.2, rawdisk seems to be available to Windows hosts.

Code: Select all   Expand viewCollapse view
C:\Program Files\Sun\xVM VirtualBox>VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
VirtualBox Command Line Management Interface Version 1.6.2
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.

Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)
1       0xce  0   /1  /1   6   /254/63            54           63
2       0x07  7   /0  /1   1022/254/63         35000       112455
3       0xcb  1022/0  /1   1022/254/63          3090     71794485
5       0x0b  1022/1  /1   1022/254/63         10001     78124158
6       0x83  1022/1  /1   1022/254/63           101     98607033
7       0x83  1022/1  /1   1022/254/63         26897     98815878
8       0x82  1022/1  /1   1022/254/63          1145    153902763

Code: Select all   Expand viewCollapse view
C:\Program Files\Sun\xVM VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename "e:\Virtual Machines\virtualbox\vdi\gentoo-raw.vmdk" -rawdisk \\.\PhysicalDrive0 -partitions 6,7,8
VirtualBox Command Line Management Interface Version 1.6.2
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.

RAW host disk access VMDK file e:\Virtual Machines\virtualbox\vdi\gentoo-raw.vmdk created successfully.

So everything appears to be created successfully. Gentoo Linux is the guest, with boot on 6, root on 7 and swap on 8. However, when I associate this VMDK with a new virtual machine and attempt to start it, I get the following:

Code: Select all   Expand viewCollapse view
----Boot error: @-00

Partition 0  id=CE (other)
Partition 1* id=07 (NTFS)
Partition 2  id =CB (other)
Partition 3 id=0F (other)
Selection partition to boot, 0-3:

This looks like it's just giving me the option to boot from the stadard 4 primary partitions. Where are the partitions I entered into the VMDK? (which are all logical drives in an extended partition). Just for fun I manually typed in 6, but it just hung.

Guy Rouillier
Posts: 34
Joined: 14. May 2007, 06:55

Postby TerryE » 14. Jul 2008, 08:38

Search for "MBR code" in the user guide :-)
Read the Forum Posting Guide
Google your Q or search for the answer before posting.
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS

Postby guyr » 20. Jul 2008, 08:28

Huh! mbr does the trick, I'm now accessing my physical Linux installation from within VirtualBox on Windows XP. Thanks. I thought I would have to turn on paravirt in the kernel, but apparently not.

Now for some pesky details. eth0 is configured for the actual device in my computer (Intel Pro 100), not the virtual PCnet-FAST III that VirtualBox is presenting. Similar issues exist with video, although that I think I know how to fix (install Guest Additions and set up one xorg.conf for physical operation and a second for virtual operation.)

I imagine this is a common issue. A pointer to a howto would be greatly appreciated. Thanks.
Guy Rouillier
Posts: 34
Joined: 14. May 2007, 06:55


Return to Using VirtualBox

Who is online

Users browsing this forum: No registered users and 15 guests