Mounting ISO in Linux/KDE
The best answer to your problem is to add contextual menus for Mount/Unmount in Dolphin, or service menus as they are called in KDE.
To do this, you need to:
- create the folder where the ISO will be mounted. (for this example I will use /mnt/iso)
- navigate to
/usr/share/kde4/services/ServiceMenus
- create a new file with
.desktop
extension (I used iso.desktop) add the following lines:
[Desktop Entry] Type=Service ServiceTypes=KonqPopupMenu/Plugin MimeType=application/octet-stream; Actions=mountISO;umountISO; [Desktop Action mountISO] Name=Mount Icon=utilities-terminal Exec=kdesu 'sudo mount -o loop,ro -t iso9660 "%f" /mnt/iso/' [Desktop Action umountISO] Name=Unmount Icon=utilities-terminal Exec=kdesu 'sudo umount "%f"'
If kdesudo is available on you system instead of kdesu, then add the following lines instead:
[Desktop Entry] Type=Service ServiceTypes=KonqPopupMenu/Plugin MimeType=application/octet-stream; Actions=mountISO;umountISO; [Desktop Action mountISO] Name=Mount Icon=utilities-terminal Exec=kdesudo 'mount -o loop,ro -t iso9660 "%f" /mnt/iso/' [Desktop Action umountISO] Name=Unmount Icon=utilities-terminal Exec=kdesudo 'umount "%f"'
OBSERVATIONS:
- mounting to /media/iso instead of /mnt/iso will cause the mounted iso to conveniently appear as a read-only drive in Dolphin places.
- in the
ServiceMenus
directory you can find other examples of how the file should be formatted. - the syntax is pretty so i will not describe it (please comment if you have questions).
- this method works for only one ISO at a time, as they are all mounted in the same directory and I could not yet find a way to overcome this.
- you will be prompted for password each time you mount/unmount
- in the end it should look like this:
Here is an app that does all of the above.
Simple service menu based on KDE-Services and Mount ISO image (more details here):
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
It will mount the image in a newly created folder inside the same directory as the image, and that folder will be deleted when the unmount option is selected for the iso.
fuser
, fusermount
, fuseiso
and kdialog
are needed."
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.
Then, it can be found in Dolphin under the Open with option:
That will mount the image, open it in Dolphin, and also open the Acetineiso window, where you can find the Unmount option.
There is also gnome-disk-utility
which, 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-get install gnome-disk-utility
After that, a Dolphin context menu entry is created, accessible by selecting 'Open with' - 'Disk Image mounter'.
These programs could be used with a service menu also (but they both lack an unmount command).
For example, 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
There seem to be a sort of bug here when using this programs with Dolphin: unmounting 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). (The first script is not affected by this.)