Monday, May 04, 2009

Mounting ISO images and creating shell scrips

Problem: Mount an ISO image file
  • Good old terminal
To make a mount point "iso" and mount the CD image "image.iso"
$ sudo mkdir /media/iso && sudo mount -o loop image.iso
To unmount the ISO and clean up the /media directory
$ sudo umount /media/iso && sudo rmdir /media/iso
Always good to know the terminal commands, thanks nixCraft.

  • Add a script to nautilus
$ cd ~/.gnome2/nautilus-scripts && sudo gedit mount
Add this text to make the 'mount' script
# nautilus-mount-iso
gksudo -u root -k /bin/echo "got r00t?"
sudo mkdir /media/"$*"
if sudo mount -o loop -t iso9660 "$*" /media/"$*"
if zenity --question --title "ISO Mounter" --text "$* Successfully Mounted.
Open Volume?"
nautilus /media/"$*" --no-desktop
exit 0
sudo rmdir /media/"$*"
zenity --error --title "ISO Mounter" --text "Cannot mount $*!"
exit 1
Now make the umount script
$ sudo gedit umount
and here is the code
for I in "$*"
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/"
Set the files as executable
$ chmod 755 mount umount
This should have added the two new scripts to the context menu. Thanks to animacide @ ubuntu forums.

  • Install gMount
$ sudo apt-get install gmountiso
While it's good to know the other methods this one is by far the easiest to use. Thanks gMount

No comments:

Post a Comment