The scenario is that you’ve installed a guest in some host logical volume (or partition or iSCSI or whatever). Now you want to dump out the raw filesystem data for any filesystem from that guest.
It’s easy with guestfish …
$ sudo guestfish --ro -a /dev/vg/f14 \ run : download /dev/sda1 /tmp/diskimage
- I’m using “sudo” because guestfish needs root in order to read the guest’s disk (
/dev/vg/f14). I could run the same command as non-root if I was accessing a guest disk that didn’t need root permissions, eg. from a file.
- Use the
--rooption because I’m just reading out the contents.
- The run command launches the libguestfs back end. This is followed by the download command.
/dev/sda1is a filesystem inside the guest disk image, in this case, the
/bootfilesystem of a Fedora 14 guest. Use virt-filesystems or the guestfish list-filesystems command to list out filesystems in a random disk image.
/tmp/diskimageis the target where I want to download the filesystem to
/tmp/diskimage is a filesystem, I can also open it with guestfish …
$ guestfish --ro -a /tmp/diskimage -m /dev/sda ><fs> ll / total 56831 dr-xr-xr-x. 5 root root 1024 Oct 15 11:19 . drwxr-xr-x 23 500 500 4096 Jan 4 19:49 .. -rw-r--r--. 1 root root 2022930 May 6 2010 System.map-184.108.40.206-85.fc13.x86_64 -rw-r--r--. 1 root root 2228083 Sep 15 03:02 System.map-220.127.116.11-28.fc14.x86_64 -rw-r--r--. 1 root root 2154391 Oct 13 22:28 System.map-18.104.22.168-43.fc14.x86_64 [...]
In this case because I used the
-m option to mount up the whole disk image, I don’t need the run command. (See this explanation for exactly why).