Archive

Posts Tagged ‘vdi.offset’

How to Convert VirtualBox image to RAW and Mount It under Linux

The good thing about using virtualBox is it allows us to convert to different types of images by itself. We do not require any other tools for it. And if we can convert any image to RAW we can simply mount it under linux as any other Harddisk Drive.Well that  is a very handy TIP right?

Now How to do it, Its a little complicated and the information regarding this is not widely available in Internet as far as I know. I used IRC help channels for these products,and I got help form there.

Converting a VDI image to RAW:

For this we can use 2 techniques.

  1. VBoxManage internalcommands converttoraw srcname dstname
  2. VBoxManage clonehd srcname dstname –format raw

Both will work almost all the time. But usage offirst one is not recomenteeeed as “internalcommands” parameter is not meant for normal use and its not recommended. Now the 2 one will always work. With no issues.

Another point to remember before the conversion:

If you ‘ve created a snapshot, it’s expected behaviour that the “base” image contains the state as of the snapshot. So you actually have to use clonehd, and you have to dig out the filename for the changes after the snapshot (or the uuid of that). You only need the name/uuid of the “current state”.  For that go to the VM config pane, select the disk you want to see the details for and tick “Differencing disks”.T he “Information” section will then show the filename you need.



Use this name as the source disk. It may be having less size but It will work.

Mounting The RAW image:

Since this is a RAW diskimage we will have to use it as a loopback device for mounting it. Also we have to specify the offset for the disk.

so the mount command will be,

sudo mount -o loop,offset=32256 <raw_img_file> <pth_to_the_dir_where_the filesystem_should_be_mounted>

Now you will have mounted device mounted with raw image you’ve given.