HowTo: Mount a disk image file in GoPiGo OS and other Raspberry Pi OS's

Issue:
For whatever reason, you need to and/or want to open adisk image file, (xxx.img), as a normal device.  Maybe it’s a raspbian image you want to pull something out of, or some other image you need to explore.

Question:
How do you do it?

Answer:
There are many ways to do this, but most are fussier than a one-armed paperhanger and require either luck, an elephant’s memory, or both.

There are two simple methods:

  1. losetup:
    This command will interrogate an image file, and allow you to attach it to your system as a mounted loop-device.  You still have to mount the individual partitions within the image, (if more than one, like in a Raspbian disk image.)

    • Advantages:
      • It comes pre-installed on virtually everything.
    • Disadvantages:
      • It’s not trivial to remember, and you still have to actually mount the image partition(s) after they’ve been loop’d.
      • It, (like half of everything else in the world), requires root privileges.  Systems with limited root/sudo support, (like DexterOS), can’t use this method.
         
  2. Disk Image Mounter:
    Most Linux distributions, (or at least the Ubuntu clones), have a right-click option for image files that allow you to automagically mount the individual partition(s) as browseable file-systems.

    • Advantages:
      • It’s soooo trivially easy to do, even I can do it!  Once it is installed, mounting an image is a right-click away.
    • Disadvantages:
      • It does not come pre-installed, so if you’re an installation purist, you may not want this.
      • Distributions with limited root/sudo capabilities like DexterOS don’t support installing packages.
      • Mitigating factor:
        Installation is trivial, the package itself, (and its dependencies), are not that big, and it blends well with the rest of the system.

Option #2 is my go-to of choice as it requires zero memory and zero fussing, (if the image is built correctly).

If the image is NOT built correctly, Disk Image Mounter won’t mount the image.

Unfortunately, many versions of Raspbian, including Raspbian for Robots and GoPiGo OS do NOT include Disk Image Mounter pre-installed.

The solution is to install the Gnome disk utility package, (gnome-disk-utility), which adds this functionality.

Viz.:

sudo apt-get update
sudo apt-get install gnome-disk-utility

That’s it!

Once that is done, you will now have a right-click option to mount, (or mount writable), a disk image file.

1 Like