From f9686217b57b061d41f96ef2f75e378e6dd20e5e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 10 Feb 2016 11:03:53 +0000 Subject: [PATCH] docs: Add recipe for FUSE-mounting a Windows guest with drive letters. Thanks: Pino Toscano, Hilko Bengen. --- docs/guestfs-recipes.pod | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/docs/guestfs-recipes.pod b/docs/guestfs-recipes.pod index f958ed062..73f9a25f8 100644 --- a/docs/guestfs-recipes.pod +++ b/docs/guestfs-recipes.pod @@ -202,6 +202,57 @@ L to list the available systemd services like this: virt-ls -a /tmp/fedora-19.img -R /lib/systemd/system +=head1 Drive letters over FUSE + +You have a Windows guest, and you want to expose the drive letters as +FUSE mountpoints (F, F etc). Instead of +L, use this Perl script: + + #!/usr/bin/perl -w + use strict; + use Sys::Guestfs; + $| = 1; + die "usage: $0 mountpoint disk.img" if @ARGV < 2; + my $mp = shift @ARGV; + my $g = new Sys::Guestfs; + $g->add_drive_opts ($_) foreach @ARGV; + $g->launch; + my @roots = $g->inspect_os; + die "$0: no operating system found" if @roots != 1; + my $root = $roots[0]; + die "$0: not Windows" if $g->inspect_get_type ($root) ne "windows"; + my %map = $g->inspect_get_drive_mappings ($root); + foreach (keys %map) { + $g->mkmountpoint ("/$_"); + eval { $g->mount ($map{$_}, "/$_") }; + warn "$@ (ignored)\n" if $@; + } + $g->mount_local ($mp); + print "filesystem ready on $mp\n"; + $g->mount_local_run; + $g->shutdown; + +You can use the script like this: + + $ mkdir /tmp/mnt + $ ./drive-letters.pl /tmp/mnt windows7.img + filesystem ready on /tmp/mnt + +In another window: + + $ cd /tmp/mnt + $ ls + C D + $ cd C + $ ls + Documents and Settings + PerfLogs + ProgramData + Program Files + [etc] + $ cd ../.. + $ guestunmount /tmp/mnt + =head1 Dump raw filesystem content from inside a disk image or VM You can use the L C command to extract the raw