Terry : Upgrade VM file layout to 4.0

VirtualBox 4.0.0 new settings/disk file layout

VirtualBox introduces new settings/disk file layout for VM portability; see chapter 10.1, Where VirtualBox stores its files, see the manual for more information.

Virtualbox itself does NOT provide the feature to upgrade file layout of VMs created by earlier versions. Here are the steps to upgrade to 4.0 new layout for portability.

Upgrade VM file layout to 4.0^

  1. Create a new VM by using the same or similar settings
  2. Copy the vdi from Harddisk folder to the newly created VM folder under default machine folder (VirtualBox VMs)
  3. Manually overwrite the newly created vdi (just mv on Linux or Unix)
  4. Run the following command to get the uuid of the vdi (source and destination VDIs have different uuid)
    VBoxManage showhdinfo vm.vdi
    Because the 2 .vdi files have different uuid, you'll see mismatch when running showhdinfo
    terry@tux:~/VirtualBox VMs/Windows XP$ vboxmanage showhdinfo Windows\ XP.vdi
    UUID:                 f4443d2f-bcd7-43a9-b66b-87c8e91e87eb
    Accessible:           no
    Access Error:         UUID {d84e98ab-3017-4807-9f1b-b3e471af8ce2} of the medium '/home/terry/VirtualBox VMs/Windows XP/Windows XP.vdi' does not match the value {f4443d2f-bcd7-43a9-b66b-87c8e91e87eb} stored in the media registry ('/home/terry/.VirtualBox/VirtualBox.xml')
    Logical size:         10737418240 MBytes
    Current size on disk: 0 MBytes
    Type:                 normal (base)
    Storage format:       VDI
    Format variant:       dynamic default
    In use by VMs:        Windows XP (UUID: 08008830-08ae-4499-8bc2-1410e4117403)
    Location:             /home/terry/VirtualBox VMs/Windows XP/Windows XP.vdi
    
    Example on Mac OS X:
    terry$ VBoxManage showhdinfo Windows\ XP.vdi
    UUID:                 a1e1f859-87ca-4541-b557-5ce514e4e286
    Accessible:           yes
    Logical size:         10737418240 MBytes
    Current size on disk: 1734 MBytes
    Type:                 normal (base)
    Storage format:       VDI
    Format variant:       dynamic default
    In use by VMs:        Windows XP (UUID: 16aaed54-e3d5-4e90-aace-2003ffd74f38)
    Location:             /Volumes/Data/Data/virtualbox/Machines/Windows XP/Windows XP.vdi
    
  5. Manually edit the VM's .vbox (XML) file to update the HardDisk uuid (2 entries)
    showhdinfo after updating .vbox
    terry@tux:~/VirtualBox VMs/Windows XP$ vboxmanage showhdinfo Windows\ XP.vdi
    UUID:                 d84e98ab-3017-4807-9f1b-b3e471af8ce2
    Accessible:           yes
    Logical size:         10737418240 MBytes
    Current size on disk: 1795 MBytes
    Type:                 normal (base)
    Storage format:       VDI
    Format variant:       dynamic default
    In use by VMs:        Windows XP (UUID: 08008830-08ae-4499-8bc2-1410e4117403)
    Location:             /home/terry/VirtualBox VMs/Windows XP/Windows XP.vdi
    
  6. Done, start the VM

Export and Re-import the VM (OVA) also does the job. However, the virtual HardDisk format will turn to VMDK instead of native VDI.

To migrate to the new 4.0 locations and filetypes you can perform a one-time export/import. You can either do this manually ("File -> Export Appliance" and "File -> Import Appliance), or automate the process using script. On Linux/Solaris/Mac it would look like this:

VBoxManage list vms | sed 's/.*{ *//;s/}//' | while read UUID; do VBoxManage export $UUID -o /tmp/$UUID.ova; VBoxManage import /tmp/$UUID.ova; done

Reference

Chapter 10. Technical background