Writing a script to mount and umount a drive in Linux

I have a 1 GB jazz drive. The jazz disk is used daily, both at home and at work on my Win 98 Server. So, I have to keep it in vfat format, which is fine because Linux rocks and will read it no problem. :slight_smile: However, I can't just stick the disk in the drive and open up the jazz folder in my mnt directory. I have to "mount" the drive using this command, mount -t vfat /dev/sda4 /mnt/jazz No big deal, and I even wrote a small script file to run that command. Only one problem, you have to login in as root on the command line for Linux to "mount" or "umount" a drive. I am lazy and want to click the icon and have it login in as the root for me. Now, some might say that is a security risk since my password will be stored in the file, but I don't care because this computer is at home and I just don't care. I don't have any friends that run Linux so they are not going to have a clue anyway. :slight_smile:

Then, I would want to "umount" the drive with another icon. :slight_smile: Make sense?

So, how do you write a login script?


Have the script do something like this:

su -c "mount -t vfat /dev/sda4 /mnt/jazz"

You will be prompted for the root password.

Also, recent version of mount allow you to add the "user" option to the corresponding /etc/fstab entry which will allow any user to mount the filesystem. So, you could put something like:

/dev/sda4 /mnt/jazz vfat user 1 1

in your /etc/fstab to allow a normal user to mount the filesystem.

Its also important to note that the "user" option implies "noexec,nodev,nosuid" unless subsequently overridden. See the man pages for fstab and mount.


Thanks, I want it to be totally automated so I don't want to even have to type my password. :smiley:

I will check out the leads you gave me. Thanks again.