How can I mount partitions in a full disk image (i.e. image with partition table) with fuse?

5,641

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.

Share:
5,641

Related videos on Youtube

Catskul
Author by

Catskul

Updated on September 18, 2022

Comments

  • Catskul
    Catskul over 1 year

    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.

    • Admin
      Admin almost 12 years
      I do not understand why you want to mount the image that has been generated.
    • Admin
      Admin almost 12 years
      To copy files over, chroot, rsync or otherwise backup, etc.
    • Admin
      Admin almost 12 years
      Also, deboostrap.
  • Catskul
    Catskul almost 12 years
    It seems that some/all of that would require root permission.
  • Nils
    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
    Catskul almost 12 years
    fakeroot will allow such a thing.
  • Catskul
    Catskul almost 12 years
    Actually, 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
    dacoinminster almost 11 years
    Addition: it should also be possible to make a simple vmdk file which references the disk image as RW 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
    Catskul over 9 years
    Only works if the "device" lives in /dev/
  • Jakob Bennemann
    Jakob Bennemann over 9 years
    One or two line answers are often not the most helpful. Consider expanding your answer with links, elaboration or documentation which support your suggested solution.