Linux - NewbieThis 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!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
All of my data are on a separate partition. I have Debian "Etch" installed and have added the data partition to fstab so that it is accessible. I'd prefer to have it like Knoppix does - so that it is unmounted, but able to be mounted by clicking an icon. Can somebody point me in the right direction to find out how to do this? Thanks.
There are probably complete solutions for this but just make a small script. $DEV is the partition you want to mount such as /dev/sda3, $MNT is the mount point such as /mnt/misc. replace them in this script.
Code:
#!/bin/bash
#
# This small script mounts and unmounts my partition
#
if [ "$(mount | grep -c $DEV)" -eq "0" ];then
mount $DEV $MNT
else
umount $MNT
fi
Then make the script executable and put it in a launcher or on desktop and set a nice icon for it. At least that's how I usually do these kinds of things.
Put the entry in /etc/fstab, but put in the option "noauto". That means the partition won't be automatically mounted. As for the desktop icon--this depends on what desktop environment you use. Assuming you use the default GNOME interface, then you'll want to put the mountpoint in either /mnt/ or /media/ (I'm not sure which one), and GNOME will automatically put it on the desktop.
Changing the etc/fstab entry to "noauto" stops it automounting.
I've been trying to get the script to work. It will work if I log on as root, but not as user... I changed the ownership of the script file to my user and I've got "user" in the fstab entry. I think it needs to be "told" to make me root so it will "do" the mounting, but I don't know what is required??
I've been trying to get the script to work. It will work if I log on as root, but not as user... I changed the ownership of the script file to my user and I've got "user" in the fstab entry. I think it needs to be "told" to make me root so it will "do" the mounting, but I don't know what is required??
Sorry, forgot about only root being able to mount new stuff. Use 'mount $MNT' instead of 'mount $DEV $MNT' and it should work. If you have declared the device-mountpoint pair in fstab at least.
In KDE, right click on the desktop. You want to create a new link to device. I don't remember the exact details of how to make it work, but the "user" option in fstab certainly can't hurt.
In KDE, right click on the desktop. You want to create a new link to device. I don't remember the exact details of how to make it work, but the "user" option in fstab certainly can't hurt.
Yay, success! Thanks.
Right click on desktop, select create new -> Link to device -> Hard Disc Device, select the "device" tab and choose a device from the drop-down menu in the "device" box, click ok. It mounts by clicking on the icon, unmounts by choosing from the menu that comes up when you right-click on the icon. (I'm not sure whether the "user" option in fstab is significant in this happening without complaint or whether I gave myself ownership of it before when I was trying to get it to mount using the script.)
Quote:
Use 'mount $MNT' instead of 'mount $DEV $MNT' and it should work. If you have declared the device-mountpoint pair in fstab at least.
I gave that a whirl to see what would happen, but it still didn't work. Thanks for the suggestion, but I don't have to persevere with that avenue now that the other one works.
I gave that a whirl to see what would happen, but it still didn't work. Thanks for the suggestion, but I don't have to persevere with that avenue now that the other one works.
Thanks again.
Glad that you got it working. It still bugged me a bit why the script didn't work so I tried it all out myself. In my example I try to mount /dev/sda7 to /mnt/misc. If this partition isn't in the fstab then:
Code:
sander@blunt:~$ cat /etc/fstab | grep sda7
sander@blunt:~$ mount /dev/sda7 /mnt/misc/
mount: only root can do that
sander@blunt:~$ mount /mnt/misc/
mount: can't find /mnt/misc/ in /etc/fstab or /etc/mtab
sander@blunt:~$
If I add it in the fstab with default settings:
Code:
sander@blunt:~$ cat /etc/fstab | grep sda7
/dev/sda7 /mnt/misc ext2 defaults 0 0
sander@blunt:~$ mount /dev/sda7 /mnt/misc/
mount: only root can do that
sander@blunt:~$ mount /mnt/misc/
mount: only root can mount /dev/sda7 on /mnt/misc
sander@blunt:~$
And when I add the 'user' (and your 'noauto') option:
Code:
sander@blunt:~$ cat /etc/fstab | grep sda7
/dev/sda7 /mnt/misc ext2 noauto,user 0 0
sander@blunt:~$ mount /dev/sda7 /mnt/misc/
mount: only root can do that
sander@blunt:~$ mount /mnt/misc/
sander@blunt:~$ mount | grep sda7
/dev/sda7 on /mnt/misc type ext2 (rw,noexec,nosuid,nodev,user=sander)
sander@blunt:~$
It works. Well, doesn't matter, as long as the KDE solution works for you.
Glad that you got it working. It still bugged me a bit why the script didn't work so I tried it all out myself.
I didn't want you to have to spend any more time on it if you had better things to do, but as you have persevered, I gave it another go, and it DID work - so the answer to the question "why didn't the script work last time?" is probably "clueless newb typed something wrong, or did something wrong"
However, it doesn't seem to unmount it - does that work for you? EDIT: tried it again after a reboot and it worked for both mounting and unmounting, so it does work.
Thanks for sticking with it.
Last edited by Honeysuckle; 06-22-2008 at 11:12 PM.
Reason: updated info
I didn't want you to have to spend any more time on it if you had better things to do, but as you have persevered, I gave it another go, and it DID work - so the answer to the question "why didn't the script work last time?" is probably "clueless newb typed something wrong, or did something wrong"
However, it doesn't seem to unmount it - does that work for you? EDIT: tried it again after a reboot and it worked for both mounting and unmounting, so it does work.
Thanks for sticking with it.
No problem. I always try to fix my stuff even when I have other solutions just so I can see how things work.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.