mount img with dolphin

5,775

Solution 1

I found a command line method that works as well. I didn't try Furius ISO as I didn't want to install a program just to mount .IMG files and I also didn't want to run any GTK software on my Qt/KDE system.

First you need add the .img file if it is a full disk like mine was.

sudo losetup -f -P imageFileName.img

Then you need to figure out what loop back device it was mounted as.

lsblk -f

After you figure out which partition you want to mount specifically you use this command. The /dev/loop0p7 is going to be your partition name.

sudo mount /dev/loop0p7 /mnt/

I am not sure if this information changes, but you could easily put this into a script if you needed to.

I should also add that once you do this, you get an entry in Dolphin.

Solution 2

Dolphin context menu services

One would expect this to be achieved from the context menu with a default or custom "Service". Those are Dolphin scripts that can be downloaded (Settings - Configure dolphin - Services - Download new services, search "mount" or "iso"; they are .desktop files tha should go to ~/.local/share/kservices5/ServiceMenus or usr/share/kservices5/ServiceMenus).

enter image description here

That seem very promising but most of those do not work. Many are outdated, the newest ones are not the best rated. Luckily, there are exceptions:

KDE-Services (the best rated at the moment I'm writing is also up-to-date and works in Plasma 5.8): it seem it cannot be installed from the Dolphin-Services button; instead, it can be downloaded as tar.bz2 archive from here, unpacked and, by opening a terminal in the resulting folder, it can be installed by running the command sudo make install. This is a collection of services, installed at system level in /usr/share/kservices5/ServiceMenus/, and also scripts in usr/share/applications.

enter image description here

It will mount the image in a newly created folder inside the same directory as the image; there is also the unmount option that works just fine (as the image is not listed in the Dolphin Devices list, this is not affected by the problem mentioned below for the separate applications).

The only problem I see here is the huge number of services that it installs in this way. It comes with a plethora of tools that may not be needed (they can be hidden if un-checked in Settings - Configure dolphin - Services, but their upper menus remain visible. To fix that, one could carefully remove the unwanted service files from /usr/share/kservices5/ServiceMenus).

It is also better to save the downloaded package in case you want to completely uninstall this tool by unpacking it, opening a terminal in the resulting folder and doing sudo make uninstall.


I have posted a simple context menu service to mount/unmount (HERE) based on the above one, in case one wants to have just the iso mount/unmount option above.

enter image description here

See description at link on how this simple service was created.

Or - to create it manually:

kate ~/bin/iso_manager-mount-image.sh 

With this content (pasting this here in order to avoid the need of installing KDE-Services or uploading the script):

#!/bin/bash

#################################################################
# For KDE-Services. 2012-2017.                  #
# By Geovani Barzaga Rodriguez <[email protected]>      #
# Improved by Victor Guardiola (vguardiola) Jan 5 2014      #
#   -Fixed the problem of [dir|file]name with whitespaces.  #
#################################################################

PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/$USER/bin
MOUNTEXIT=""

##############################
############ Main ############
##############################

cd "${1%/*}"

if [ "$1" == "${1%.*}.iso" ]; then
   fuseiso -p "$1" "${1%.iso}"
   MOUNTEXIT=$?
else
   rename .ISO .iso *
   kdialog --icon=ks-error --title="Mount ISO-9660 Image" \
                   --passivepopup="[Error] Can't mount ${1##*/}: Renamed extension of ISO image, because contain uppercase characters. Please try again."
   exit 1
fi

if [ "$MOUNTEXIT" = "0" ]; then
   kdialog --icon=ks-media-optical-mount --title="Mount ISO-9660 Image" --passivepopup="[Finished] ${1##*/} mounted."
else
   kdialog --icon=ks-error --title="Mount ISO-9660 Image" \
                   --passivepopup="[Error] Can't mount ${1##*/}: Already mount or check image integrity."
   exit 1
fi

exit 0

Then:

kate ~/.local/share/kservices5/ServiceMenus/mount-iso.desktop

with this content:

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=application/x-cd-image;model/x.stl-binary
Actions=mount;unmount;
X-KDE-Priority=TopLevel
X-KDE-StartupNotify=false
Icon=application-x-cd-image
X-KDE-Submenu=Mount/unmount image


[Desktop Action unmount]
Name=Unmount
Icon=edit-redo
Exec=which fuser fusermount; if [ "$?" != "0" ];then kdialog --icon=ks-error --title="Unmount ISO-9660 Image" --passivepopup="[Error] Please install fuser and fusermount command and try again."; exit 1; else fuser -k %f; fusermount -u "$(ls "%f"|sed 's/.iso$//')"; rm -fr "$(ls "%f"|sed 's/.iso$//')"; kdialog --icon=ks-media-optical-umount --title="Unmount ISO-9660 Image" --passivepopup="[Finished] $(basename %f) unmounted.";fi

[Desktop Action mount]
Name=Mount
Icon=circular-arrow-shape
Exec=which fuseiso; if [ "$?" != "0" ];then kdialog --icon=ks-error --title="Mount ISO-9660 Image" --passivepopup="[Error] Please install fuseiso command and try again."; exit 1; else ~/bin/iso_manager-mount-image.sh %F;fi

Considering separate programs:

As the question is labeled under KDE/Kubuntu, I will try to mention only programs that are as KDE/Qt-friendly as possible, that is, which bring few non-kde dependencies.

Acetoneiso comes in Plasma 5 with only three supplementary packages: fuseiso and other two that are qt-based.

sudo apt install acetoneiso

To see it in Dolphin you have to add the program to the file properties of the iso file.

enter image description here

Then, it can be found in Dolphin under the Open with option:

enter image description here

That will mount the image, open it in Dolphin, and also open the Acetineiso window, where you can find the Unmount option.

enter image description here


gnome-disk-utility, in spite of the name comes without non-kde dependencies in Plasma 5.8 (in fact no dependencies at all), and it includes (beside gnome-disks, also called "Disks", default in Ubuntu) a tool called gnome-disk-image-mounter.

sudo apt install gnome-disk-utility

It then can be found in Dolphin under the Open with option.

enter image description here

At this point the image is not automatically opened in Dolphin, but is listed in the Dolphin's left panel under Devices.

This program seems to lack an option to unmount the image: that can be done from the devices list in Dolphin.

There seem to be a sort of Dolphin bug here though: once unmounted, whether from the Acetoneiso button or from the Dolphin devices list, the list entry will remain there (called 'Loop device' in the case of gnome-disks) which, if selected, will again mount the image. That entry will stay there until system restart (logout is not enough).

These programs could be used with a service menu also (but they both lack an unmount command).

For example, instead of the above one could use this with Acetoneiso:

kate ~/.local/share/kservices5/ServiceMenus/acetoneiso-mount-iso.desktop 

with the content:

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=application/x-cd-image
Actions=mount
X-KDE-Priority=TopLevel
X-KDE-StartupNotify=false
Icon=application-x-cd-image
X-KDE-Menu=Mount with Acetoneiso



[Desktop Action mount]
Name=Mount with Acetoneiso
Icon=Acetino2
Exec=acetoneiso %f

enter image description here


Furious ISO Mount (furiusisomount) wants to add a significant number of gnome packages compared to the above, including Nautilus, therefore I leave it aside in this answer.

The following additional packages will be installed:
  fuseiso9660 gnome-desktop3-data libexempi3 libgail-3-0 libgnome-desktop-3-12 libmediaart-2.0-0 libnautilus-extension1a libtracker-sparql-1.0-0
  libunity-protocol-private0 libunity-scopes-json-def-desktop libunity9 libzeitgeist-2.0-0 nautilus nautilus-data

Solution 3

Furius ISO Mount allows you to mount easily want you want.

I hope it will be useful.

Share:
5,775

Related videos on Youtube

Goddard
Author by

Goddard

I love computing, gardening, and cycling.

Updated on September 18, 2022

Comments

  • Goddard
    Goddard over 1 year

    I'm running 16.04 and I am trying to mount a img file, but I have no option to do so.

    How can I add the ability to mount? Preferably something gui based and just either a context menu option, or something similar would be nice so it shows up in dolphin on the left hand side.

    Thanks

  • Goddard
    Goddard almost 8 years
    Was hoping for a more integrated way to accomplish this if you know
  • user.dz
    user.dz over 7 years
    It would be nice, if you include how to cleanly release the image.
  • Admin
    Admin about 6 years
    Synaptic tells me this wants to add a significant number of gnome packages including Nautilus.
  • Admin
    Admin almost 6 years
    I have noticed that in Ubuntu 18.04, in order for a Dolphin context service menu to work for iso files, the desktop file needs model/x.stl-binary for the Mimetype line.