Mount image-files in UbuntuNov 23, 2008, tags: tips
Ubuntu is really great, it has alot of smart things that makes me more productive.
But a not so simple thing is mounting an image-file. There are a few ways to do it, but I was surprised that this solution worked as good as it did.
By using fuseiso and creating scripts which are saved in Nautilus’s script-folder this is easy to achieve. I got the idea of using fuseiso through this guide at Ubuntu Unleashed, but I took the concept further and made it clickable. Nothing advanced but I know how hard it is to find this information when you need it.
Fuseiso is the utility that actually will mount your file. It’s in Ubuntu’s official repositories, install fuseiso either by clicking the link or typing
sudo apt-get install fuseiso
Create a folder where you want the contents of your iso-file to be found. It is important to remember that you should not use this folder for anything, don’t put files or so here. It is merely for displaying the contents of image-files which are somewhere else.
I chose /media/Isofolder but anything should work. Since /media is owned by the root I must create the folder by preceding mkdir /media/Isofolder with sudo, like this:
sudo mkdir /media/Isofolder
If you create the folder in your home-folder, sudo won’t be necessary. When creating the folder with “sudo”, root will be the owner of the folder. I’ll change owner to myself. It’s more easy that way, but not entirely necessary. I think read-rights is enough…
Anyway, to make myself owner, I’ll use
sudo chown username /media/Isofolder
Once again, this should not be necessary if Isofolder is placed in your own home-folder. But then no other user would be able to see the contents of the image-file.
Now it is time to create the scripts that will call mountiso and umount.
First, open Gedit or any other text editor and paste this text:
#!/bin/bash # Script to mount image-files like img or iso. # Uses fuseiso # Before use, create the isofolder: # “sudo mkdir/media/Isofolder” and “sudo chown username /media/Isofolder” # first clear the Isofolder gksu umount /media/Isofolder # Load the iso! fuseiso “$*” /media/Isofolder
Everything after # is a comment. Take care when copying the code, the citation signs might not copy properly.
A short explanation of the commands:
umount: unmounts the Isofolder (if there already was something mounted). It must be performed as root, so I preceed it with gksu which creates a popup where I can enter my password. After that, fuseiso tries to mount what I clicked on to /media/Isofolder. Save this file in ~/.gnome2/nautilus-scripts/ and name it Mount. (~ means your homefolder). Scripts in this folder will pop-up in Nautilus when right-clicking.
#!/bin/bash # See mount for details gksu umount /media/Isofolder
Save this file in the same folder as Unmount.
Make the scripts executable, either by right clicking them and modifying their properties, or by typing
cd ~/.gnome2/nautilus-scripts/ chmod +x Mount chmod +x Unmount
Chmod +x adds executable (x) rights to the files.
It should now be done, just right click any image-file and choose Scripts->Mount to mount it to /media/Isofolder.
Edit: I added a part about not using the Isofolder and changed a few formulations. Edit: Confirmed to work in Ubuntu 9.10 Karmic Koala.