Raw disk format supported?

Discussions related to using VirtualBox on Linux hosts.
Post Reply
shadowbox
Posts: 23
Joined: 29. Dec 2011, 08:26
Primary OS: Other
VBox Version: OSE Fedora
Guest OSses: Ubuntu

Raw disk format supported?

Post by shadowbox »

I've been trying to find a way to mount VM hard disks in the host OS for some time now without success. Virtualbox doesn't have any built in function to do so, vdfuse won't work on CentOS, and guestfish on CentOS won't support vdi OR vmdk or pretty much any format that virtualbox supports. I'm *really* regretting using CentOS at this point, but trying to find a way to salvage the work I've put into setting it up. Guestfish WILL mount raw disk images, but virtualbox won't allow me to attach a raw disk image to a VM, so I'm stuck again. Vboxmanage must understand the format on some level because it can convert to/from RAW. Is there anyway to attach a raw disk to a VM and boot off it?
stefan.becker
Volunteer
Posts: 7639
Joined: 7. Jun 2007, 21:53

Re: Raw disk format supported?

Post by stefan.becker »

Raw Disc Access is described in the Manual. And in the tutorial section there are some howtos to start a native installed OS with VBOX.

I have not tried this for myself, so i cant help you further.

Mostly people do not use this because of:
- new activation for windows guests
- double hardware profiles
- data damage, if partition is mounted on the host
shadowbox
Posts: 23
Joined: 29. Dec 2011, 08:26
Primary OS: Other
VBox Version: OSE Fedora
Guest OSses: Ubuntu

Re: Raw disk format supported?

Post by shadowbox »

Ah, raw disk access is a different thing altogether than a raw disk image. I am NOT trying to give access to my physical disk. Raw disk image is basically a dd of a physical disk. It usually uses the IMG extention. Is that supported?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Raw disk format supported?

Post by mpack »

It is supported, but you will find life much simpler if you convert it to a non-raw virtual HD format first. IMHO the best tool for that is CloneVDI - simply give the file a .raw extension then clone it using CloneVDI, selecting the "Compact" option, and you'll have a much smaller VDI to build a new VM around, or attached to an existing VM. CloneVDI is a Windows app, but it runs well on Linux hosts under Wine.

If you don't want to use CloneVDI then you can use the "VBoxManage convertfromraw" command (see user manual). You'll get a VDI (or other format if you specify one), but it will not be compacted.

A final possibility is to manually create a VMDK descriptor for the raw file.


btw, I'm assuming that your starting point is a raw image of an entire disk, as partition dumps will usually not work.
shadowbox
Posts: 23
Joined: 29. Dec 2011, 08:26
Primary OS: Other
VBox Version: OSE Fedora
Guest OSses: Ubuntu

Re: Raw disk format supported?

Post by shadowbox »

Oh, no, that's not what I'm wanting to do. I know I can convert from raw to vdi. What I want to do is boot from the raw disk image without converting. Is that possible? I need to be able to mount my disk images from the host and the only tool to do that in centos is guestfish and the only formats its supports is qcow and raw. I don't really want to have to convert my vdi to raw every time I want to mount it on the host and then convert it back to vdi to boot.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Raw disk format supported?

Post by mpack »

Create a VMDK descriptor for it. I'm sure you can lay your hands on another VMDK you can use as a reference.
shadowbox
Posts: 23
Joined: 29. Dec 2011, 08:26
Primary OS: Other
VBox Version: OSE Fedora
Guest OSses: Ubuntu

Re: Raw disk format supported?

Post by shadowbox »

I'm not sure I know how to do that. Can you provide a reference? I converted one of my vdi hard disks to a vmdk, but it is not 2 files but only one, so the descriptor must be merged with the disk itself. The only instructions I can find on creating a vmdk descriptor are VMware specific. If I'm understanding you, you are suggesting I can have a separate vmdk descriptor for the raw disk image which will allow Vbox to read the disk image, right?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Raw disk format supported?

Post by mpack »

Yes, as you've guessed, the VMDK standard supports two descriptor types. One type is embedded in the image file itself (obviously not suitable for raw images), and the other version is a separate little text file, and can be used to describe raw files or raw access to physical disks.

Here's an example :-
Disk.vmdk wrote:

Code: Select all

# Disk DescriptorFile
# IDEALLY THE CID SHOULD BE DIFFERENT FOR EVERY DISK. ITS AN OLD RELATIVE OF UUID.
# NOTHING SPECIAL, JUST INVENT ONE. MAKE SURE VBOX DOESN'T SEE TWO DISKS WITH
# THE SAME CID.
version=1
CID=ad885fa2
parentCID=ffffffff
createType="fullDevice"

# Extent description
# THE FILESIZE HERE MUST BE THE RAW IMAGE SIZE EXPRESSED IN 512BYTE SECTORS.
# NOTE THE FILENAME TOO, WHICH YOU MUST CORRECT.
RW 123456789 FLAT "/yourfolder/rawfilename" 0

# The Disk Data Base 
#DDB

ddb.virtualHWVersion = "4"
ddb.geometry.cylinders = "16383"
ddb.geometry.heads = "16"
ddb.geometry.sectors = "63"
ddb.adapterType = "lsilogic"
ddb.toolsVersion = "7240"
ddb.geometry.biosCylinders="1024"
ddb.geometry.biosHeads="255"
ddb.geometry.biosSectors="63"
shadowbox
Posts: 23
Joined: 29. Dec 2011, 08:26
Primary OS: Other
VBox Version: OSE Fedora
Guest OSses: Ubuntu

Re: Raw disk format supported?

Post by shadowbox »

Thanks, that helps. The VMware instructions for making a vmdk descriptor call for creating another disk image of the same size and copying the geometry settings as that is rather important. I did "head /myimage.vmdk" to see the settings then "vboxmanage clonehd --format RAW" to create a copy of the vmdk in raw form so I could use the same settings. However the raw file created is significantly different in size, ie 10G rather than 12G so I don't think I can use those geometry settings. Any suggestions?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Raw disk format supported?

Post by mpack »

Geometry doesn't matter for disks >8GB, which is when the CHS address maxes out, as in the example. Just leave the geometry stuff alone, just provide filename, and image size in sectors, again as the example mentions.
shadowbox
Posts: 23
Joined: 29. Dec 2011, 08:26
Primary OS: Other
VBox Version: OSE Fedora
Guest OSses: Ubuntu

Re: Raw disk format supported?

Post by shadowbox »

Yes! It works! You have no idea how happy this makes me. I've been working on a solution for 6 months now and was seriously considering switching to another distro. I want to convert the hard disks of all my VMs, but before I do I should ask if there are any known issues I should be aware of with using a split vmdk format this way? IDE or SATA? Normal or immutable disks? dynamic or static? Last thing I want is some kind of disk corruption because I screwed up some setting. For some reason "vboxmanage showhdinfo" shows the "format variant" as "fixed unknown" on my new disk where the original vmdk before conversion was "dynamic default".
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Raw disk format supported?

Post by mpack »

Why would you want to convert all your VMs to this? It has its uses, e.g. accessing a physical drive or "dd" dump, but in general a fixed sized drive is an inferior choice, and VMDK is not as well supported in VBox as VDI is (naturally not, the latter being the native format).

To your question: "split VMDK" meaning the header separate from the image? There's nothing unusual about that. All "raw" VMDKs must be that way by definition. As for VBox displaying it as "fixed unknown", well it definitely is a fixed sized drive. "Unknown" probably means that the header is missing the UUID (and possibly other things) which VBox would have put there. Harmless.

The only thing you must remember is that the geometry can't be ignored if you ever create an image of 8GB or smaller. It isn't hard to calculate a new geometry though.

And incidentally: remember that since the disk is now in a recognized format, you can do anything with it that you can with any other VMDK. For example, clone it to another image format using VBoxManage or CloneVDI. Or loop mount it on the host, view the contents with certain archive managers etc.
shadowbox
Posts: 23
Joined: 29. Dec 2011, 08:26
Primary OS: Other
VBox Version: OSE Fedora
Guest OSses: Ubuntu

Re: Raw disk format supported?

Post by shadowbox »

Well, I want to do AV/malware scans with the VM powered down, so I mount the HD from the host for this. RAW is the only compatible disk format Centos understands unfortunately. When you say "not well supported" what does that mean? Doesn't support all the features? Will it make my VM crash?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Raw disk format supported?

Post by mpack »

"Not as well supported" means that all the basics work, the VM will not crash, but some additional features (such as disk resize) will not work.
Post Reply