Monday, October 27, 2008

Mount iso file in Ubuntu

This post will show you 4 ways to mount an iso file like a normal cd/dvd drive in Ubuntu. By using these you don't have to write the iso file to a cd or dvd. They are ordered from the easiest to the hardest.



Mount iso using Gmount-iso.
This is a great program that i found recently. To install it just type:

sudo apt-get install gmountiso
The best thing with this program is that you can mount the image anywhere you want. You can even mount it on the cdrom folder. (if you execute it with sudo )
sudo Gmount-iso


Mount iso using nautilus.

This is the easiest and fastest way i know.

Step: 1
With this way you only have to install a .deb package. This package is called nautilus-mount-image and it can be found
http://launchpadlibrarian.net/18219053/nautilus-mount-image_0.2.0-1_all.deb
or
https://edge.launchpad.net/%7Ezootropo/+archive/+files/nautilus-mount-image_0.2.0-1_all.deb

After
installing the package when you right click on an iso file you will see the option to Mount.
The only problem that i found with this way is that you cannot mount it where you want (in a folder of your choise) .


Mount iso using nautilus scripts.

To make this way work you need to create two nautilus scripts and put them in the correct folder.

Step:1

Create a new file named mount in the folder ~/.gnome2/nautilus-scripts. This file will mount the image file you want.
gedit .gnome2/nautilus-scripts/mount.sh
and copy the following and save the file
#!/bin/bash

gksudo -u root -k /bin/echo "got r00t?"

sudo mkdir /media/"$*"

if sudo mount -o loop -t iso9660 "$*" /media/"$*"
then
if zenity --question --title "ISO Mounter" --text "$* Successfully Mounted.

Open Volume?"
then
nautilus /media/"$*" --no-desktop
fi
exit 0
else
sudo rmdir /media/"$*"
zenity --error --title "ISO Mounter" --text "Cannot mount $*!"
exit 1
fi

Step:2
Create a new file named unmount in the folder ~/.gnome2/nautilus-scripts. This file will unmount the image file you previously mounted.
gedit .gnome2/nautilus-scripts/unmount.sh
and copy the following and save the file
#!/bin/bash

for I in "$*"
do
foo=`gksudo -u root -k -m "enter your password for root terminal
access" /bin/echo "got r00t?"`

sudo umount "$I" && zenity --info --text "Successfully unmounted /media/$I/" && sudo rmdir "/media/$I/"
done
done
exit0
and copy the following and save the file
#!/bin/bash

gksudo -u root -k /bin/echo "got r00t?"

sudo mkdir /media/"$*"

if sudo mount -o loop -t iso9660 "$*" /media/"$*"
then
if zenity --question --title "ISO Mounter" --text "$* Successfully Mounted.

Open Volume?"
then
nautilus /media/"$*" --no-desktop
fi
exit 0
else
sudo rmdir /media/"$*"
zenity --error --title "ISO Mounter" --text "Cannot mount $*!"
exit 1
fi

Step:3
Now we just have to give execution rights to the files we created.
sudo chmod +x .gnome2/nautilus-scripts/mount.sh
sudo chmod +x .gnome2/nautilus-scripts/unmount.sh
The only problem that i found with this way is that you cannot mount it where you want (in a folder of your choise) .

If you want some more nautilus script visit:
http://mundogeek.net/nautilus-scripts/


Using loop Kernel Module

This is the hardest way but the only one if you don't want to use a graphical interface.

Step:1
The first thing you need to do is create the directory that the iso is going to be mounted.
sudo mkdir /media/image_folder
Step:2
Now you have to load the loop mode to your kernel:
sudo modprobe loop
Step:3
Now we can mount the image file (
image_file.iso) to the folder we created.
sudo mount image_file.iso /media/image_folder/ -t iso9660 -o loop
Step:4
When we want to unmount the image file
sudo umount /media/image_folder/



No comments: