Friday Jan 29, 2010

Split VirtualBox VM disk images

Problem: I have a laptop with opensolaris installed. I have a portable hard disk with FAT32 which I used to store media so that I can use it in Solaris/Linux/Windows. I want to store OS images (to run them as VMs using VirtualBox ) which generally are >4G and FAT32 cannot have a single file exceeding this size.

One way to get around this was to zip them which reduces the size drastically to <=4G and hence be stored on the USB disk. This way I would have to unzip it, save somewhere to use it, zip it back when done and store the updated one. This was cumbersome and time consuming.

Recently, while running through the help output of VBoxManage, I noticed that VBoxManage's createhd takes a --variant option which can take Split2G as option!

$ VBoxManage createhd
VirtualBox Command Line Management Interface Version 3.1.0
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Usage:

VBoxManage createhd         --filename <filename>
                            --size <megabytes>
                            [--format VDI|VMDK|VHD] (default: VDI)
                            [--variant Standard,Fixed,Split2G,Stream,ESX]
                            [--type normal|writethrough] (default: normal)
                            [--comment <comment>]
                            [--remember]

I didn't notice this before. I knew something like this was available for VMWare. Then I thought I would give this a try:

So, I created a new 10G hard disk image using VBoxManage,

VBoxManage createhd --filename /space/vdis/ubuntu9.10.vmdk --size 10000 --format VMDK --variant Split2G -remember
VirtualBox Command Line Management Interface Version 3.1.0
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: f96d6fd9-a9b4-4383-8429-8c794d48370a

And what you get is: 

ls -1 /space/vdis/ubuntu9.10\*
/space/vdis/ubuntu9.10-s001.vmdk
/space/vdis/ubuntu9.10-s002.vmdk
/space/vdis/ubuntu9.10-s003.vmdk
/space/vdis/ubuntu9.10-s004.vmdk
/space/vdis/ubuntu9.10-s005.vmdk
/space/vdis/ubuntu9.10.vmdk

The disk image file is broken into 2G individual pieces, which can now be stored on FAT32. The image to use inside VirtualBox would be /space/vdis/ubuntu9.10.vmdk

Note that the Split2G variant seems to only work with --format VMDK, probably to be compatible with VMWare VMDK images. It doesn't seem to work with the VDI format.

The next part was to convert my existing disk images to this variant so that I can happily store them on my USB disk. This way, I can run VMs from the disk images directly!

To convert the existing disk images to this format,

  • I had to create another disk (with Split2G variant)
  • attach this disk as the secondary disk to the existing VM (with the old VDI as the primary)
  • use gparted or any partition manager, and make a copy of the older disk onto the new one.

P.S: sometimes one would need to setup the boot loader to find this new disk, and/or make the partition active before booting from it.

And you should be done!

About

ravee

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today