Tip: Open VirtualBox VDI file using libguestfs

Not much of a tip, but I was playing with VirtualBox today and I noticed that qemu supports VirtualBox’s native disk format, VDI. This means you can just open, mount etc these *.vdi files directly using guestfish, guestmount and the other libguestfs tools.

$ guestfish --ro -i -a fedora-test.vdi

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

Type: 'help' for a list of commands
      'man' to read the manual
      'quit' to quit the shell

Operating system: Fedora release 13 (Goddard)
/dev/mapper/vg_fedoravbox-lv_root mounted on /
/dev/vda1 mounted on /boot

><fs> cat /etc/issue
Fedora release 13 (Goddard)
Kernel \r on an \m (\l)
><fs> exit
$ virt-df -h fedora-test.vdi
Filesystem                                Size       Used  Available  Use%
fedora-test.vdi:/dev/sda1               484.2M      27.0M     432.2M    6%
                                          2.6G       2.0G     616.3M   76%
$ virt-tar -xz fedora-test.vdi /home /tmp/home.tar.gz
$ zcat /tmp/home.tar.gz | tar tf -
$ cd /tmp
$ mkdir mnt
$ guestmount --ro -a fedora-test.vdi -m /dev/vg_fedoravbox/lv_root mnt/
$ ls mnt/
bin   dev  home  lost+found  mnt  proc  sbin     srv  tmp  var
boot  etc  lib   media       opt  root  selinux  sys  usr
$ fusermount -u /tmp/mnt

I like it when stuff just works for free!

1 Comment

Filed under Uncategorized

One response to “Tip: Open VirtualBox VDI file using libguestfs

  1. Pingback: Mounting Virtual Box Machine Images on a Host

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.