Linux – How to mount partitions in a full disk image (i.e. image with partition table) with fuse

filesystemsfuselinuxloop-devicemount

It's a bit indirect, but it's possible to mount a partition with a disk image using mount or losetup's "offset" parameter.

I'm looking to be able to use fuse to do the same thing in user space

Use Case

My use case is building disk images on an autobuild server where the build job is not allowed to have root permissions, and the server should not need a custom setup for particular build jobs.

Best Answer

It's possible to do with fuse, but would probably be cleaner with custom tools.

Solution

With apt-get-able tools the following kludge is possible:

mkdir mnt
xmount --in dd --out vdi disk.img mnt

mkdir mnt2
vdfuse -f mnt/disk.vdi 

mkdir mnt3
fuseext2 -o "rw" mnt2/Partition1 mnt3

Explanation

The basic idea is that fuse can be used to separate a full disk image in place into files that point to it's partitions. vdfuse does this, but is a VirtualBox tool and requires a VDI or VMDK file to work. xmount uses fuse to make a raw disk image appear as a VDI file.

Finally once the partition file is available via vdfuse, it can be mounted via an ext2/3/4 tool fuseext2.

It's ugly but it works completely in userspace.

Update

vdfuse should be able to mount a raw image without the help of xmount, but there is a bug which ignores the RAW option.

I tracked down and fixed the bug with a patch here:

https://bugs.launchpad.net/ubuntu/+source/virtualbox-ose/+bug/1019075

Related Question