guestmount and virt-inspector

I was asked on IRC what the purpose of the $(virt-inspector ...) clause is from the previous example:

$ guestmount $(virt-inspector --ro-fish /dev/vg_trick/Debian5x64) /tmp/rich

Firstly $(...) is the cool modern way to write shell `backquotes`. As well as being cool and modern, it’s also better than using backquotes because you can nest it.

What does the virt-inspector subcommand do? The output of the virt-inspector command is this, split into multiple lines just to make it easier to see:

-a /dev/vg_trick/Debian5x64
-m /dev/debian5x64/root:/
-m /dev/sda1:/boot
-m /dev/debian5x64/home:/home
-m /dev/debian5x64/tmp:/tmp
-m /dev/debian5x64/usr:/usr
-m /dev/debian5x64/var:/var

Just for comparison I want to run the guestfish commands list-partitions and lvs on the same virtual machine:

$ guestfish -a /dev/vg_trick/Debian5x64 \
    run : echo Partitions : list-partitions : echo Logical volumes : lvs
Logical volumes

virt-inspector has used libguestfs to examine each mountable partition in the guest, has looked at /etc/fstab and other clues, and has decided on how the Debian guest, if running, would mount those partitions.

It then prints the guestfish-compatible -a and -m options to add the disk and mount the partitions up. guestmount uses a broadly compatible set of options, so it works too.

And finally I’d like to note that this also works well with libvirt domain names, so we could equally have written:

$ guestmount $(virt-inspector --ro-fish Debian5x64) /tmp/rich

Leave a comment

Filed under Uncategorized

Leave a Reply

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

You are commenting using your 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.