guestmount(1)

๐Ÿฆ‹ guestmount(1) โ€” the libguestfs girlies' fave ๐Ÿฆ‹

okay so first things first, this is a page from the Virtualization Support manual section, and it's literally called guestmount(1). Buckle up bestie, we're mounting filesystems ๐Ÿ’…


โœจ NAME โœจ

guestmount โ€” mount a guest filesystem on the host using FUSE and libguestfs ๐Ÿซถ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

the three iconic forms, no cap:

guestmount [--options] -a disk.img -m device [--ro] mountpoint

guestmount [--options] -a disk.img -i [--ro] mountpoint

guestmount [--options] -d Guest -i [--ro] mountpoint

๐Ÿšจ WARNING ๐Ÿšจ

bestie. listen to me. Using guestmount in write mode on live virtual machines, or concurrently with other disk editing tools, can be dangerous โ€” potentially causing disk corruption. ๐Ÿ˜ญ The virtual machine must be shut down before you use this command, and disk images must not be edited concurrently.

Use the --ro (read-only) option to use guestmount safely if the disk image or virtual machine might be live. You may see strange or inconsistent results if running concurrently with other changes, but with this option you won't risk disk corruption. ๐Ÿ™

fr fr, --ro is your bestie. write mode on a live VM is giving "chaos main character" and not in a cute way ๐Ÿ’€

๐Ÿ’– DESCRIPTION ๐Ÿ’–

The guestmount program can be used to mount virtual machine filesystems and other disk images on the host. It uses libguestfs for access to the guest filesystem, and FUSE (the "filesystem in userspace") to make it appear as a mountable device. the way that combo works?? iconic ๐Ÿ”ฅ

Along with other options, you have to give at least one device (-a option) or libvirt domain (-d option), and at least one mountpoint (-m option) or use the -i inspection option. How this works is better explained in the guestfish(1) manual page, or by looking at the examples below. ๐Ÿ‘‘

FUSE lets you mount filesystems as non-root. The mountpoint must be owned by you. The filesystem will not be visible to any other users unless you make configuration changes, see "NOTES" below. ๐Ÿ™ˆ

To unmount the filesystem, use the guestunmount(1) command. slash that thing, periodt โญ


๐ŸŒˆ EXAMPLES ๐ŸŒˆ

For a typical Windows guest which has its main filesystem on the first partition:

guestmount -a windows.img -m /dev/sda1 --ro /mnt

For a typical Linux guest which has a /boot filesystem on the first partition, and the root filesystem on a logical volume:

guestmount -a linux.img -m /dev/VG/LV -m /dev/sda1:/boot --ro /mnt

To get libguestfs to detect guest mountpoints for you:

guestmount -a guest.img -i --ro /mnt

For a libvirt guest called "Guest" you could do:

guestmount -d Guest -i --ro /mnt

If you don't know what filesystems are contained in a guest or disk image, use virt-filesystems(1) first:

virt-filesystems -d MyGuest

If you want to trace the libguestfs calls but without excessive debugging information, we recommend:

guestmount [...] --trace /mnt

If you want to debug the program, we recommend:

guestmount [...] --trace --verbose /mnt

To unmount the filesystem after using it:

guestunmount /mnt

๐ŸŽ€ NOTES ๐ŸŽ€

๐Ÿ’œ Other users cannot see the filesystem by default

If you mount a filesystem as one user (eg. root), then other users will not be able to see it by default. The fix is to add the FUSE allow_other option when mounting:

sudo guestmount [...] -o allow_other /mnt

and to enable this option in /etc/fuse.conf. ๐Ÿ“

๐Ÿงš Enabling FUSE

On some distros, you may need to add yourself to a special group (eg. fuse) before you can use any FUSE filesystem. This is necessary on Debian and derivatives. ๐Ÿ“

On other distros, no special group is required. It is not necessary on Fedora or Red Hat Enterprise Linux. ๐Ÿ’…

๐Ÿ’€ fusermount error: "Device or resource busy"

You can see this error when another process on the system jumps into the mountpoint you have just created, holding it open and preventing you from unmounting it. The usual culprits are various GUI "indexing" programs. ๐Ÿ˜ค

The popular workaround for this problem is to retry the fusermount -u command a few times until it works (guestunmount(1) does this for you). Unfortunately this isn't a reliable fix if (for example) the mounted filesystem is particularly large and the intruding program particularly persistent. ๐Ÿ˜ญ

A proper fix is to use a private mountpoint by creating a new mount namespace using the Linux-specific clone(2)/unshare(2) flag CLONE_NEWNS. Unfortunately at the moment this requires root and we would also probably need to add it as a feature to guestmount. ๐Ÿ™ˆ

โญ Race conditions possible when shutting down the connection

When guestunmount(1)/fusermount(1) exits, guestmount may still be running and cleaning up the mountpoint. The disk image will not be fully finalized. ๐Ÿซ 

This means that scripts like the following have a nasty race condition:

guestmount -a disk.img -i /mnt
# copy things into /mnt
guestunmount /mnt
# immediately try to use 'disk.img' ** UNSAFE **

The solution is to use the --pid-file option to write the guestmount PID to a file, then after guestunmount spin waiting for this PID to exit. ๐Ÿ‘‘

guestmount -a disk.img -i --pid-file guestmount.pid /mnt

# ...
# ...

# Save the PID of guestmount *before* calling guestunmount.
pid="$(cat guestmount.pid)"

# Unmount the filesystem.
guestunmount /mnt

timeout=10

count=$timeout
while kill -0 "$pid" 2>/dev/null && [ $count -gt 0 ]; do
    sleep 1
    ((count--))
done
if [ $count -eq 0 ]; then
    echo "$0: wait for guestmount to exit failed after $timeout seconds"
    exit 1
fi

# Now it is safe to use the disk image.

Note that if you use the guestfs_mount_local API directly (see "MOUNT LOCAL" in guestfs(3)) then it is much easier to write a safe, race-free program. ๐ŸŒŸ


part 1 of 3 bestie, don't go anywhere โ€” more coming ๐ŸŽ€๐Ÿ’–

๐Ÿ’… OPTIONS ๐Ÿ’…

Okay bestie, this is the main character section, so grab a snack ๐Ÿ“ โ€” every single flag lives here and you're gonna wanna know them all.

  • -a IMAGE, --add IMAGE โ€” adds a block device or a virtual machine image to the mix. The disk image format is auto-detected, no cap โ€” but if you wanna override that and force a specific format, you reach for the --format=.. option instead. โœจ
  • -a URI, --add URI โ€” same flag, but this time you're adding a remote disk. Go read "ADDING REMOTE STORAGE" in guestfish(1) for the whole story ๐Ÿซถ
  • --blocksize=512, --blocksize=4096, --blocksize โ€” sets the sector size of the disk image. It only affects disks that are explicitly added after this parameter, so order matters, iykyk. If you use --blocksize with no argument at all, it flips the disk sector size back to the default, which is usually 512 bytes. Also go look at "guestfs_add_drive_opts" in guestfs(3). ๐Ÿ”ฅ
  • -c URI, --connect URI โ€” when you use it together with the -d option, this tells guestmount which libvirt URI to use. The default is the default libvirt connection, periodt.
  • -d LIBVIRT-DOMAIN, --domain LIBVIRT-DOMAIN โ€” pulls in the disks from the named libvirt domain. If you also pass --ro, then any libvirt domain works. But in write mode, only libvirt domains that are shut down can be named here โ€” no exceptions, bestie ๐Ÿ’€

Domain UUIDs can be used instead of names, which is lowkey iconic.

  • --dir-cache-timeout N โ€” sets the readdir cache timeout to N seconds, and the default is 60 seconds. The readdir cache (well, actually, there are several semi-independent caches) gets populated after a readdir(2) call with the stat and extended attributes of the files in the directory, in anticipation that they'll be requested real soon after. โœจ

Also important: there's a different attribute cache implemented by FUSE (that's the FUSE option -o attr_timeout), but the FUSE cache doesn't anticipate future requests โ€” it only caches existing ones. She's doing a different job, okay? ๐Ÿ’…

  • --echo-keys โ€” normally, when guestmount prompts for keys and passphrases, it turns echoing off so you can't see what you're typing. If you're not worried about Tempest attacks and there's literally no one else in the room, you can pass this flag and see what you're typing. Very "living dangerously" of you ๐Ÿ™ˆ
  • --fd=FD โ€” gives guestmount a pipe or eventfd file descriptor to work with. When the mountpoint is ready to be used, guestmount writes a single byte to this file descriptor. This pairs beautifully with --no-fork if you wanna run guestmount captive under another process ๐Ÿ‘‘
  • --format=raw|qcow2|.., --format โ€” by default -a auto-detects the format of the disk image. Using this forces the disk format for every -a option that follows on the command line. If you use --format with no argument, it switches back to auto-detection for the subsequent -a options. ๐Ÿฆ‹
Real talk, bestie: if you've got untrusted raw-format guest disk images, you should use this option to specify the disk format. It avoids a possible security problem with malicious guests (CVE-2010-3851). See also "guestfs_add_drive_opts" in guestfs(3). ๐ŸŒธ
  • --fuse-help โ€” displays help on the special FUSE options (the -o ones, below). Super handy.
  • --help โ€” displays brief help and dips. โœŒ๏ธ
  • -i, --inspector โ€” uses virt-inspector(1) code to inspect the disks, looking for an operating system, and mounts the filesystems exactly as they would be mounted on the real virtual machine. It's giving "just do it for me" energy and I respect it.
  • --key SELECTOR โ€” specifies a key for LUKS, so it can automatically open a LUKS device when using the inspection. The selector comes in a few flavours:
    • --key NAME:key:KEY_STRING
    • --key UUID:key:KEY_STRING
    • --key all:key:KEY_STRING

Here NAME is the libguestfs device name (eg. /dev/sda1). UUID is the device UUID. And all means "try the key against any encrypted device." You use the specified KEY_STRING as the passphrase. ๐Ÿ”‘

  • --key NAME:file:FILENAME
  • --key UUID:file:FILENAME
  • --key all:file:FILENAME

This version reads the passphrase from FILENAME. ๐ŸŽ€

  • --key NAME:clevis
  • --key UUID:clevis
  • --key all:clevis

Attempts passphrase-less unlocking for the device with Clevis, over the network. Please refer to "ENCRYPTED DISKS" in guestfs(3) for more info on network-bound disk encryption (NBDE). ๐Ÿงš

Heads up: if any such option is present on the command line, QEMU user networking will be automatically enabled for the libguestfs appliance. No cap.
  • --key NAME:error
  • --key UUID:error
  • --key all:error

Any encrypted device that matches will cause an error. And --key all:error is the icon that lets you reject any disk image that contains an encrypted partition. So dramatic, so effective ๐Ÿ’…

  • --keys-from-stdin โ€” reads key or passphrase parameters from stdin. The default behaviour is to try to read passphrases from the user by opening /dev/tty. If there are multiple encrypted devices, you may need to supply multiple keys on stdin โ€” one per line, bestie โœจ
  • -m dev[:mountpoint[:options[:fstype]], --mount dev[:mountpoint[:options[:fstype]]] โ€” mounts the named partition or logical volume on the given mountpoint in the guest (this has absolutely nothing to do with mountpoints in the host, don't get it twisted ๐Ÿซถ).

If you leave the mountpoint out, it defaults to /. And you have to mount something on / โ€” that's not optional, okay?

The third part of the mount parameter (rarely used, but it's there) is the list of mount options used to mount the underlying filesystem. If you don't give it, the mount options are either the empty string or "ro" โ€” the latter if the --ro flag is used. By specifying the mount options, you override this default choice. Probably the only time you'd use this is to enable ACLs and/or extended attributes, if the filesystem can support them:

-m /dev/sda1:/:acl,user_xattr

The fourth part of the parameter is the filesystem driver to use, like "ext3" or "ntfs". This is rarely needed, but it comes in clutch if multiple drivers are valid for a filesystem (eg: "ext2" and "ext3"), or if libguestfs misidentifies a filesystem. ๐Ÿ‘‘

  • --no-fork โ€” don't daemonize (or fork into the background). Simple as that, periodt.
  • -n, --no-sync โ€” by default, we attempt to sync the guest disk when the FUSE mountpoint is unmounted. If you specify this option, then we don't attempt to sync the disk. See the discussion of autosync in the guestfs(3) manpage. ๐Ÿฆ‹
  • -o OPTION, --option OPTION โ€” passes extra options straight through to FUSE.

Want a list of all the extra options FUSE supports? Run this. Note that only the FUSE -o options can be passed, and only some of them are actually a good idea:

guestmount --fuse-help

Some potentially useful FUSE options, bestie:

  • -o allow_other โ€” allows other users to see the filesystem. This option has no effect unless you enable it globally in /etc/fuse.conf. ๐ŸŒˆ
  • -o attr_timeout=N โ€” enables attribute caching by FUSE and sets the timeout to N seconds. โœจ
  • -o kernel_cache โ€” lets the kernel cache files, which reduces the number of reads that have to go through the guestfs(3) API. Generally a good idea if you can afford the extra memory usage. ๐Ÿ’–
  • -o uid=N -o gid=N โ€” use these to map all UIDs and GIDs inside the guest filesystem to the chosen values. ๐ŸŽ€
  • -o use_ino โ€” preserves inode numbers from the underlying filesystem.

Without this option, FUSE makes up its own inode numbers, so the inode numbers you see in stat(2), "ls -i" etc aren't the inode numbers of the underlying filesystem. ๐Ÿ™ˆ

Careful, bestie: this option is potentially dangerous if the underlying filesystem consists of multiple mountpoints, because you may see duplicate inode numbers appearing through FUSE. Using this option can confuse some software. ๐Ÿ’€
  • --pid-file FILENAME โ€” writes the PID of the guestmount worker process to "filename". Very organized of her ๐Ÿ‘‘
  • -r, --ro โ€” adds devices and mounts everything read-only. Also disallows writes and makes the disk appear read-only to FUSE. ๐Ÿ”’

This is highly recommended if you're not going to edit the guest disk. If the guest is running and this option is not supplied, then there's a strong risk of disk corruption in the guest. We try to prevent that from happening, but it's not always possible โ€” so like, please use it? ๐Ÿ˜ญ

See also "OPENING DISKS FOR READ AND WRITE" in guestfish(1).

  • --selinux โ€” this option is provided for backwards compatibility and does nothing. It's giving decorative. ๐Ÿ’…
  • -v, --verbose โ€” enables verbose messages from the underlying libguestfs. Chatty queen ๐Ÿ—ฃ๏ธ
  • -V, --version โ€” displays the program version and exits. Slay.
  • -w, --rw โ€” this changes the -a, -d and -m options so that disks are added and mounts are done read-write. ๐Ÿ”ฅ

See "OPENING DISKS FOR READ AND WRITE" in guestfish(1).

  • -x, --trace โ€” traces libguestfs calls and entry into each FUSE function. ๐Ÿฆ‹

This also stops the daemon from forking into the background (see --no-fork).


๐Ÿ“ FILES ๐Ÿ“

  • $XDG_CONFIG_HOME/libguestfs/libguestfs-tools.conf
  • $HOME/.libguestfs-tools.rc
  • $XDG_CONFIG_DIRS/libguestfs/libguestfs-tools.conf
  • /etc/libguestfs-tools.conf

This configuration file controls the default read-only or read-write mode (--ro or --rw). ๐ŸŽ€

See libguestfs-tools.conf(5).


๐Ÿšฆ EXIT STATUS ๐Ÿšฆ

This program returns 0 if successful, or non-zero if there was an error. That's it, that's the status. โœจ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

Go show these some love, bestie:

guestunmount(1), fusermount(1), guestfish(1), virt-inspector(1), virt-cat(1), virt-edit(1), virt-tar(1), libguestfs-tools.conf(5), "MOUNT LOCAL" in guestfs(3), http://libguestfs.org/, http://fuse.sf.net/.


โœ๏ธ AUTHORS โœ๏ธ

Richard W.M. Jones ("rjones at redhat dot com") โ€” the icon who made this whole thing happen ๐Ÿ‘‘


Copyright (C) 2009-2025 Red Hat Inc.


๐Ÿ“œ LICENSE ๐Ÿ“œ

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ๐Ÿซถ

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ๐Ÿ’€

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ๐ŸŒธ

๐Ÿ› BUGS ๐Ÿ›

okay so listen โ€” libguestfs is a whole icon but even icons have off days ๐Ÿ’… and when something's busted, the team actually wants to hear about it. no gatekeeping, no "ugh another bug report". they want the tea โ˜•

wanna stalk the existing bug list first? slay, here's the link:

https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools

wanna file a brand new one? periodt, go off bestie:

https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools

๐Ÿซถ when you report a bug, pls pls pls include:

  • the version of libguestfs โ€” like, which one. we can't debug a vibe, we need numbers ๐Ÿ”ข
  • where you got libguestfs from โ€” e.g. which Linux distro, or compiled from source, etc. context is everything fr fr
  • a description of the bug that's actually accurate, plus a way to reproduce it โ€” be specific, not vague. "it's broken" is giving nothing ๐Ÿ˜ญ
  • run libguestfs-test-tool(1) and paste the complete, unedited output into the bug report โ€” and I mean complete and unedited. don't trim it, don't crop it, don't "clean it up". the whole thing. raw. unedited. no cap ๐Ÿ™ˆ
lowkey the last one is the make-or-break one โ€” if you skip it, they're gonna have to ask you for it anyway, so just do it first. save yourself the round trip, queen ๐Ÿ‘‘

that's literally the whole page bestie, you made it to the end ๐ŸŽ€ go forth and mount those guests ๐Ÿ’–

โœจ this was guestmount(1) from libguestfs-1.61.3, dated 2026-09-16 โœจ mwah, bye, love u, see u at the next man page ๐Ÿฆ‹๐Ÿ’œ

๐Ÿ“ฆ where this page comes from