3

I have a bunch of VirtualBox VMs (Linux and Windows) and would like to know how to transfer any of them to the metal.

tshepang
  • 65,642

2 Answers2

3

I'm not sure if you can do this with windows guests. I'll outline what I would do first to move any VM to physical disk, and some "hints" which may help with windows.

So, in general, you need an image of the virtual hard drive:

  1. Check which drives are available (following is a snippet):

    $ VBoxManage list hdds
    Oracle VM VirtualBox Command Line Management Interface Version 3.2.10_OSE
    (C) 2005-2010 Oracle Corporation
    All rights reserved.
    
    UUID:        d6b9f0a5-98df-48ca-83c8-91a0809ec349
    Parent UUID: base
    Format:      VDI
    Location:    /home/wena/.VirtualBox/HardDisks/Debian 6.vdi
    State:       created
    Type:        normal
    Usage:       Debian 6 (UUID: f070af5c-57b1-47db-9300-f17921dee57d) [1 pristine fresh install (UUID: 90e46b07-07d9-4b81-9b7b-dadd75fc13f4)]
    
    UUID:        dfd7deec-b7a7-4e83-967e-17aa8fb1f602
    Parent UUID: d6b9f0a5-98df-48ca-83c8-91a0809ec349
    Format:      VDI
    Location:    /home/wena/.VirtualBox/Machines/Debian 6/Snapshots/{dfd7deec-b7a7-4e83-967e-17aa8fb1f602}.vdi
    State:       created
    Type:        normal
    Usage:       Debian 6 (UUID: f070af5c-57b1-47db-9300-f17921dee57d)
    
  2. Select UUID above and convert it:

    VBoxManage clonehd d6b9f0a5-98df-48ca-83c8-91a0809ec349 --format RAW Debian6.img
    
  3. Then, just copy this image to a harddrive, using dd.

This should work for most Linux machines.

For windows, chances are, that you may have a lot of troubles. I would start with creating a new hardware profile in the VM before I even try.

tshepang
  • 65,642
Sunny
  • 253
0

Mounting thought loopback device with offset, might be helpful.

VDIfile=VirtData.vdi
mountingpoint=/mnt/VDI
offData=$( VBoxManage internalcommands dumphdinfo "$VDIfile" |grep offData | sed 's:.*offData=\([0-9]*\).*:\1:' )
offset=$(( $offData + 32256 ))
mount -t ext4 -o rw,noatime,noexec,loop,offset="$offset" "$VDIfile" "$mountingpoint"

More details here: https://unix.stackexchange.com/a/45019/9689