How can I mount partitions in a full disk image (i.e. image with partition table) with fuse?
Solution 1
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
Solution 2
There is pmount utility that is a wrapper around the standard mount program which permits normal users to mount removable devices without a matching /etc/fstab entry.
The only thing you need to allow user to use it is to add user to plugdev
group.
Related videos on Youtube
Catskul
Updated on September 18, 2022Comments
-
Catskul over 1 year
It's a bit indirect, but it's possible to mount a partition with a disk image using
mount
orlosetup
'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.
-
Admin almost 12 yearsI do not understand why you want to mount the image that has been generated.
-
Admin almost 12 yearsTo copy files over, chroot, rsync or otherwise backup, etc.
-
Admin almost 12 yearsAlso, deboostrap.
-
-
Catskul almost 12 yearsIt seems that some/all of that would require root permission.
-
Nils almost 12 years@Catskul set set up the above, yes. To use it no. But same is true for your image. How do you create root-owned files if you do not have root permissions?
-
Catskul almost 12 yearsfakeroot will allow such a thing.
-
Catskul almost 12 yearsActually, after more reading and experimentation, it appears that fuse mounting allows you to modify files as if you were root without the use of fakeroot.
-
dacoinminster almost 11 yearsAddition: it should also be possible to make a simple
vmdk
file which references the disk image asRW 55296000 FLAT "disk.img" 0
or something like that (with extra headers and the correct size in 512-byte blocks) (I don't know if there's a tool to easily generate those). -
Catskul over 9 yearsOnly works if the "device" lives in
/dev/
-
Jakob Bennemann over 9 yearsOne or two line answers are often not the most helpful. Consider expanding your answer with links, elaboration or documentation which support your suggested solution.