Linux

Using libguestfs to mount a Disk Image.

Recently, the opensource community and Red Hat are not supporting NTFS filesystem to mount images using libguestfs. You can read the official documentation accessing the specific section: “mount: unsupported filesystem type” with NTFS in RHEL ≥ 7.2. There is another bug raised at the bugzilla explaining the decision: guestfish fails to mount the ntfs filesystem.

Many developers and users are having problems to mount Windows (NTFS) images to read and backup important files. Here, some suggestions to avoid this problem and mount disk images with Windows (NTFS) or any other file system using Fuse.

First, there is a Python script that uses the module python-libguestfs and mount an image as Read-Only.

#/usr/bin/python
import guestfs

g = guestfs.GuestFS(python_return_dict=True)

# You can specify the right file name.
disk = "disk.img"

g.add_drive_opts(disk, format="qcow2")
g.launch()

# You specify your rules to choose the right partition to mount.
partitions = g.list_partitions ()
assert (len (partitions) == 1)

# Here we are assuming that this is the right partition
g.mount (partitions[0], "/")

g.mount_local("/mnt/", options="allow_other", readonly=True)
g.mount_local_run()

This code will freeze when you run g.mount_local_run(), but if you umount the directory “/mnt/” this code will be freed.

You can use guestfish commands or the guestfish terminal to mount this images using the same process. See the script with the guestfish commands. You can use each command inside guestfish shell.

add disk.img
run
mount "/dev/sda1" "/"
mount-local /mnt/ readonly:true
mount-local-run

This two options are a workaround to mount images with NTFS file systems, but it can be used to mount all file systems such as ext3, ext4, FAT, etc.

Advertisements
Standard