Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-16-2005, 07:59 PM   #1
Registered: Apr 2004
Location: France
Distribution: Debian Sid (Kanotix)
Posts: 237

Rep: Reputation: 30
How to create script to mount / unmount drive

I would like to make mounting and unmounting my USB Zip drive just a bit less baroque.

I've put an entry in /etc/fstab, but still to mount the thing requires opening a console and typing the 'mount /media/zip' 'umount /media/zip' etc

What's the easiest way to automate this? A script I guess, but I can't find anything provided by Suse.

Apparently something like

mount /media/zip
would do the job.

1. So - newbie question, this - how do you get the text file recognised as a script for clicking on in KDE?

2. Also, I came across this script, which apparently works for mounting and unmounting. Does it look possible for a USB device?

affichage=`/bin/mount | grep /dev/hdd4`
if test -z $affichage
mount /dev/hdd4
umount /dev/hdd4
Thanks for advice.
Old 07-16-2005, 08:48 PM   #2
Registered: Feb 2005
Distribution: Debian 3.x & Fedora Core 3, Debie on IBM Thinkpad
Posts: 68

Rep: Reputation: 15
yes, the script would work just fine, just make sure that "/dev/hdd4" is your usb device's actual mount-point, otherwise you'd be mount/unmounting other devices.
Old 07-16-2005, 09:27 PM   #3
Registered: Jul 2003
Location: Pennsylvainia
Distribution: Slackware / Debian / *Ubuntu / Opensuse / Solaris uname: Brian Cooney
Posts: 503

Rep: Reputation: 30
and chmod+x the script so the system knows its allowed to run it

dont forget the # in #!/bin/bash
Old 07-16-2005, 09:42 PM   #4
Registered: Apr 2004
Location: France
Distribution: Debian Sid (Kanotix)
Posts: 237

Original Poster
Rep: Reputation: 30
Thumbs up

Well it didn't seem to work, but that's okay as I found a much better solution - a 'script' provided by KDE in the form of the app KDiskFree, which I didn't know existed.

Let's face it, you shouldn't really need to write scripts to mount a drive anyway...

Thanks for the help anyway, I did learn something for the future occasion when it really is necessary.
Old 07-16-2005, 09:48 PM   #5
Senior Member
Registered: Oct 2002
Distribution: Slackware, Windows 7
Posts: 1,253

Rep: Reputation: 55
You could always just make a desktop icon which mounts the drive when you click it.

Right-click the desktop
Create New
Link to device
Choose fstab entry from dropdown.
Old 07-16-2005, 10:08 PM   #6
LQ Newbie
Registered: Jul 2005
Location: Lock Haven, PA, USA
Distribution: Redhat 7.3, 9 and Fedora 3
Posts: 9

Rep: Reputation: 0
^ is there a way to do that in fedora?
Old 07-17-2005, 08:04 AM   #7
Senior Member
Registered: Oct 2002
Distribution: Slackware, Windows 7
Posts: 1,253

Rep: Reputation: 55
Since the OP was using KDE, I did not specify in my reply that my suggestion was for KDE.

In FC4 (or any distro) the solution is dependent on the window manager or desktop environment.
In other words, if it works it should work in all distros.

That being said, FC4 uses Gnome by default (I believe) and this is a bit different. One method would be to do what was suggested above and use the disk mounter applet which will park itself on the gnome-panel. I am far more familiar with KDE than Gnome. XFCE4 seems much easier in this regard as well.

The zip drive has been troublesome for some people using 2.6.X kernels in some distros in that if a disk is not in the drive (mine is an internal ide drive - paralell may differ) at boot, a device node is not created. I have seen fixes for this described in many places which involve creating a permanent device node for the drive. This appears to be a simple process, but I use 2.4.31 still and cannot tell you from experience as I do not have the problem (yet).

Old 07-17-2005, 11:01 AM   #8
Registered: Feb 2004
Distribution: Slackware 10.2
Posts: 669

Rep: Reputation: 32
You could try dbus hal if they have that in suse. I installed that in slackware it worked except it caused cd ripping to take forever. I think mabye a kernel or configuration problem.
Old 08-01-2005, 05:39 AM   #9
Simon Bridge
LQ Guru
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
For FC4 - there is a user mount tool.
Launchers can be created the same way in GNOME as in KDE.
The zip drive must be mentioned in /etc/fstab in order to be mounted by any user. However - FC4 is very good at autodetecting removeable media. I have not the zip drive, but my usb memory stick is detected and an icon appears on the desktop... I barely have to twitch.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mount and unmount Hargibi Linux - Software 9 09-26-2005 07:11 AM
mount and unmount d1l2w3 Linux - Hardware 4 05-15-2005 07:32 AM
Bash Script to Detect USB drive mount status nutthick Programming 6 02-02-2005 08:17 AM
Drive imaging or Linux installation script to create clones? uk_dave Linux - Distributions 6 08-20-2004 10:21 AM
Mount/Unmount Network Drive Before/After Logrotate Archive GMcFall Linux - General 0 03-31-2004 03:15 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:43 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration