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
$(...) is the cool modern way to write shell
`. 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:
--ro -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
$ guestfish -a /dev/vg_trick/Debian5x64 \ run : echo Partitions : list-partitions : echo Logical volumes : lvs Partitions /dev/sda1 /dev/sda2 Logical volumes /dev/debian5x64/home /dev/debian5x64/root /dev/debian5x64/swap_1 /dev/debian5x64/tmp /dev/debian5x64/usr /dev/debian5x64/var
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.
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