Page 1 of 3 123 LastLast
Results 1 to 10 of 94

Thread: HOWTO: Nautilus Script to mount .iso files

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Beans
    14

    HOWTO: Nautilus Script to mount .iso files

    I recently found a nautilus shell script on an older post to the forum that could mount .iso files, but it couldn't handle spaces in filenames or mount more than one file at once. After some struggle I've come up with these scripts which handle multiple concurrent mounts and filenames with spaces. You'll want to save these under ~/.gnome2/nautilus-scripts/ and make them executable:

    Mount:
    Code:
    #!/bin/bash
    #
    # nautilus-mount-iso
    
    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
    Unmount:
    Code:
    #!/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
    To use either one just right click on the .iso file and use scripts -> mount. Hope someone finds this useful. Does anyone know if there's a way to make nautilus just unmount by right clicking on the volume icon on the desktop and selecting unmount volume?
    Last edited by animacide; December 22nd, 2005 at 12:59 PM. Reason: Improved mounting script

  2. #2
    manicka Guest

    Re: HOWTO: Nautilus Script to mount .iso files

    I have added these scripts to the Ubuntu Document Storage Facility

  3. #3
    Join Date
    Nov 2004
    Beans
    213

    Re: HOWTO: Nautilus Script to mount .iso files

    Great script man! Thank you for posting it!

  4. #4
    Join Date
    Aug 2005
    Location
    Oslo, Norway
    Beans
    225

    Re: HOWTO: Nautilus Script to mount .iso files

    One problem with this script, is, that if it is not possible to mount the iso file, it still creates a directory in /media. And it is not deleted. This can lead to heavy "clutter" after a while.

  5. #5
    Join Date
    Oct 2005
    Location
    Louisville KY (USA)
    Beans
    179
    Distro
    Ubuntu Breezy 5.10

    Re: HOWTO: Nautilus Script to mount .iso files

    I am going to see if I can use this to get a LIVE USB setup working that we are trying in thread 71567



    DAVE
    ( If you don't care who gets the credit ... great things can be accomplished. )
    Setup Guide: "Installing Ubuntu on an external USB Drive"
    Good Starter Book: "Linux Desktop Pocket Guide"

  6. #6
    Join Date
    Sep 2005
    Beans
    1

    Re: HOWTO: Nautilus Script to mount .iso files

    This doesn't work with any ISO file that is outside your home directory, other than that, great script

  7. #7
    Join Date
    Aug 2005
    Location
    North of the Artic
    Beans
    85
    Distro
    Ubuntu Intrepid Ibex (testing)

    Re: HOWTO: Nautilus Script to mount .iso files

    Thanks I needed this .

    -Ounas
    I forgot that love existed - Van Morrison

  8. #8
    Join Date
    Mar 2006
    Location
    Toronto, Canada
    Beans
    855

    Re: HOWTO: Nautilus Script to mount .iso files

    How to mount ISO BIN/CUE IMG/CCD NRG:
    http://ubuntuforums.org/showthread.php?t=144236

  9. #9
    Join Date
    Nov 2004
    Beans
    5

    Re: HOWTO: Nautilus Script to mount .iso files

    No, those are defective
    gksu segfaults with -k root, i don't think it needs it anyway. also, it attempted for me to create directories with the full path, which is not what i want. so, here's a quick fix and a cleanup.
    Mount:
    Code:
    #!/bin/bash
    #
    # nautilus-mount-iso
    
    gksudo -k /bin/echo "got r00t?"
    BASENAME=`basename "$*"`
    sudo mkdir /media/"$BASENAME"
    echo $BASENAME
    
    if sudo mount -o loop -t iso9660 "$*" /media/"$BASENAME"
    then
            if zenity --question --title "ISO Mounter" --text "$BASENAME Successfully Mounted.
    
            Open Volume?"
            then
                    nautilus /media/"$BASENAME" --no-desktop
            fi
            exit 0
    else
            sudo rmdir /media/"$BASENAME"
            zenity --error --title "ISO Mounter" --text "Cannot mount $BASENAME!"
            exit 1
    fi
    Unmount:
    Code:
    #!/bin/bash
    #
    BASENAME=`basename "$*"`
    foo=`gksudo -u root -k -m "enter your password for root terminal access" /bin/echo "got r00t?"`
    sudo umount /media/"$BASENAME" && zenity --info --text "Successfully unmounted /media/$BASENAME/" && sudo rmdir "/media/$BASENAME/"
    cleaned up the unmount code, BTW.

  10. #10
    Join Date
    May 2006
    Beans
    30

    Re: HOWTO: Nautilus Script to mount .iso files

    Quote Originally Posted by Nightwish View Post
    No, those are defective
    gksu segfaults with -k root, i don't think it needs it anyway. also, it attempted for me to create directories with the full path, which is not what i want. so, here's a quick fix and a cleanup.
    Mount:
    Code:
    #!/bin/bash
    #
    # nautilus-mount-iso
     
    gksudo -k /bin/echo "got r00t?"
    BASENAME=`basename "$*"`
    sudo mkdir /media/"$BASENAME"
    echo $BASENAME
     
    if sudo mount -o loop -t iso9660 "$*" /media/"$BASENAME"
    then
            if zenity --question --title "ISO Mounter" --text "$BASENAME Successfully Mounted.
     
            Open Volume?"
            then
                    nautilus /media/"$BASENAME" --no-desktop
            fi
            exit 0
    else
            sudo rmdir /media/"$BASENAME"
            zenity --error --title "ISO Mounter" --text "Cannot mount $BASENAME!"
            exit 1
    fi
    Unmount:
    Code:
    #!/bin/bash
    #
    BASENAME=`basename "$*"`
    foo=`gksudo -u root -k -m "enter your password for root terminal access" /bin/echo "got r00t?"`
    sudo umount /media/"$BASENAME" && zenity --info --text "Successfully unmounted /media/$BASENAME/" && sudo rmdir "/media/$BASENAME/"
    cleaned up the unmount code, BTW.

    Here's an easy fix to get rid of the .iso from mounted images.
    Replace:
    Code:
    BASENAME=`basename "$*"`
    with:
    Code:
    BASENAME=`basename "${1%.*}"`
    That's just string chopping. It tells the shell to cut off anything after the (.).

    Edit: The umount script does'nt work if the directory name does'nt have the .iso on it so here's the fix.

    Code:
    #!/bin/bash
    #
    ImgDir="${1%.*}"
    for I in "$1"
    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/$ImgDir"
    done
    done
    exit0
    Last edited by chollis888; August 5th, 2006 at 11:35 PM.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •