| View previous topic :: View next topic |
| Author |
Message |
Fred Krogh l33t

Joined: 07 Feb 2005 Posts: 657 Location: Tujunga, CA
|
Posted: Sun Jul 17, 2011 5:26 pm Post subject: Mount Point Idiocy |
|
|
Perhaps this belongs in "Off the Wall", but that forum doesn't seem to have much to do with Linux. This rant is more of a Unix rant, but since I use Gentoo, it has hit me. I have more than once (at widely spaced times) failed to mount a drive and written to the directory the drive was supposed to be mounted on. After being fooled into thinking that the data had been safely written to the desired place (partition or dvd), I have had trouble tracking down exactly what was causing the problems that inevitably resulted. So I'm an idiot, but software should not be designed to punish idiots.
Why do we need a mount point for a drive? Much safer would be to specify a mount point in fstab or as part of the mount command, and if that corresponds to a directory that already exists to give a diagnostic or fail. The former if the mount command were changed, but since that probably isn't going to happen, make it fail for a new command, "mnt". An option at boot could indicate whether "mount" or "mnt" should be used when reading fstab. If the directory already exists when the mnt command is executed then it would fail to do the mount. Clearly the user would get a diagnostic if they try to access a directory for which no mnt has been given. It may be desirable to insist that the mnt point be in an already existing directory. Thus one might mnt /mnt/dvd, and while /mnt would need to exist, /mnt/dvd would exist only after execution of the "mnt /mnt/dvd".
In case it isn't obvious, I don't know enough about the internals of mount to know if a mnt (and umnt) command is feasible. If someone knows why this can't work, I'd appreciate a response. Thanks,
Fred |
|
| Back to top |
|
 |
aidanjt Veteran


Joined: 20 Feb 2005 Posts: 1096 Location: Rep. of Ireland
|
Posted: Sun Jul 17, 2011 6:20 pm Post subject: |
|
|
Umm, you can already do that. In fact, Gentoo already has a default /mnt/cdrom fstab entry so you can just type mount /mnt/cdrom to load a cd/dvd/bluray/whateveropticaldisc. The full `mount /dev/storagedevicenode /mnt/somewhere` syntax is only needed when a device doesn't have a /etc/fstab entry. Further, if you use a DE like Gnome/KDE/whatever, they use udev to automount axillary storage devices on /media/${device label}. If a mount fails, then mount should be outputting an error message. _________________
| drizek wrote: | | Here in America, we are like a bunch of shit-slinging monkeys. |
|
|
| Back to top |
|
 |
Dr.Willy Apprentice

Joined: 15 Jul 2007 Posts: 259 Location: NRW, Germany
|
Posted: Sun Jul 17, 2011 6:28 pm Post subject: |
|
|
| AidanJT wrote: | | Umm, you can already do that. In fact, Gentoo already has a default /mnt/cdrom fstab entry so you can just type mount /mnt/cdrom to load a cd/dvd/bluray/whateveropticaldisc. |
That's not what he wants.
He wants to 'mount /dev/foo /mnt/foo/' without an existing /mnt/foo/ directory. |
|
| Back to top |
|
 |
Fred Krogh l33t

Joined: 07 Feb 2005 Posts: 657 Location: Tujunga, CA
|
Posted: Sun Jul 17, 2011 6:36 pm Post subject: |
|
|
| In response to AidanGT: In my latest case, I had changed /boot in fstab to be noauto, seemed like a good idea (and I think it is). But then I forgot about it as this was a new way of doing things for me. So I have a problem, write things to /boot and /boot/grub, and all looks correct. But somehow when I boot, things don't happen as they should. In the case of the dvd years ago, I forgot to mount /mnt/dvd. Still I could write backups to the dvd and check that all was written correctly. And it all looks good as long as the dvd has noauto, and I consistently fail to mount it. |
|
| Back to top |
|
 |
aidanjt Veteran


Joined: 20 Feb 2005 Posts: 1096 Location: Rep. of Ireland
|
Posted: Sun Jul 17, 2011 7:13 pm Post subject: |
|
|
| Fred Krogh wrote: | | In response to AidanGT: In my latest case, I had changed /boot in fstab to be noauto, seemed like a good idea (and I think it is). But then I forgot about it as this was a new way of doing things for me. So I have a problem, write things to /boot and /boot/grub, and all looks correct. But somehow when I boot, things don't happen as they should. In the case of the dvd years ago, I forgot to mount /mnt/dvd. Still I could write backups to the dvd and check that all was written correctly. And it all looks good as long as the dvd has noauto, and I consistently fail to mount it. |
If you're not using a DE and you want that kind of automagic mounting, you can use autofs. _________________
| drizek wrote: | | Here in America, we are like a bunch of shit-slinging monkeys. |
|
|
| Back to top |
|
 |
Fred Krogh l33t

Joined: 07 Feb 2005 Posts: 657 Location: Tujunga, CA
|
Posted: Sun Jul 17, 2011 7:18 pm Post subject: |
|
|
| I don't know what a DE is, but this sounds like it comes close to doing what I want. But for example, with mnt, if I have not got /boot mounted, instead of stuff getting stored or deleted there, it just doesn't happen. With autofs it seems that it would, and thus that level of protection would be lost. Am I missing something? |
|
| Back to top |
|
 |
avx Veteran


Joined: 21 Jun 2004 Posts: 1831
|
Posted: Sun Jul 17, 2011 8:00 pm Post subject: |
|
|
DE=DesktopEnvironment, aka a window manager + a lot of tools, for example KDE/GNOME/XFCE/LXDE/... All these automount devices to /media/something without (much) user interaction.
What about simply writing a script as wrapper for mount? _________________ Want to thank me for something? Send me a nice postcard(ask per pm for my address), thank you! |
|
| Back to top |
|
 |
Fred Krogh l33t

Joined: 07 Feb 2005 Posts: 657 Location: Tujunga, CA
|
Posted: Sun Jul 17, 2011 9:27 pm Post subject: |
|
|
If I understand what you are suggesting, the script would behave something like this.
For mnt:
1. If the directory is mounted does nothing. (I don't know a clean way to test for this.)
2. If the directory exists it prints a warning and exits without mounting anything.
3. Does a mkdir and then mounts the directory.
For umnt:
1. If the device is not mounted does nothing
2. Unmounts the device and then removes the directory.
I kind of like this. BUT is still doesn't help with directories that are mounted on system boot. I guess if I had a way to have mnt called at boot time, I'd have what I want.
A nice suggestion. Thanks. |
|
| Back to top |
|
 |
disi Veteran


Joined: 28 Nov 2003 Posts: 1202 Location: Out There ...
|
Posted: Sun Jul 17, 2011 9:58 pm Post subject: |
|
|
| Fred Krogh wrote: | | I don't know what a DE is, but this sounds like it comes close to doing what I want. But for example, with mnt, if I have not got /boot mounted, instead of stuff getting stored or deleted there, it just doesn't happen. With autofs it seems that it would, and thus that level of protection would be lost. Am I missing something? |
For the autofs part. Let's say you define /boot in your /etc/auto.misc, as soon as you enter the directory use ls or cp or whatever, the partition is mounted and gets unmounted when it is not used anymore (you can define the timeout). _________________ Gentoo on Uptime Project - Larry is a cow |
|
| Back to top |
|
 |
Fred Krogh l33t

Joined: 07 Feb 2005 Posts: 657 Location: Tujunga, CA
|
Posted: Sun Jul 17, 2011 10:31 pm Post subject: |
|
|
| Thanks, I may give that a try. I have a disk drive that is not used much. Is it possible this could be used to shut it down, and then spin it back when a directory on that disk is accessed? (In this case I don't care if there is a bit of a wait for that to happen.) |
|
| Back to top |
|
 |
disi Veteran


Joined: 28 Nov 2003 Posts: 1202 Location: Out There ...
|
Posted: Sun Jul 17, 2011 10:42 pm Post subject: |
|
|
Look here: http://en.gentoo-wiki.com/wiki/Autofs
I use it for network drives that are disconnected if not used. So technically the drives are not mounted until used, the same happens to dvd drives used with autofs.
To configure when drives should spin down you can look at hdparm. This is a driver setting and it should also spin down even if it's mounted normally and not used. Some file managers lock drives and probably index all the time, so the drive will not spin down.
I have the same experience with autofs, that desktop file managers permanently do stuff on the drive so it never disconnects. PCManFM is pretty nice to drives and leaves them alone if not used. _________________ Gentoo on Uptime Project - Larry is a cow |
|
| Back to top |
|
 |
PaulBredbury Watchman


Joined: 14 Jul 2005 Posts: 6609
|
Posted: Mon Jul 18, 2011 2:38 am Post subject: Re: Mount Point Idiocy |
|
|
| Fred Krogh wrote: | | software should not be designed to punish idiots. |
I just checked, and a reasonable safeguard can be done with permissions:
| Code: | brebs:~$ ll /mnt
total 28
drwxr-xr-x 2 root root 4096 Jan 26 2010 blackberry
brebs:~$ cp testfile /mnt/blackberry/
cp: cannot create regular file `/mnt/blackberry/testfile': Permission denied |
However, I can mount /mnt/blackberry/ thanks to this entry in /etc/fstab:
| Code: | | /dev/blackberry1 /mnt/blackberry vfat noauto,noatime,users,flush,gid=100,umask=007 |
And then write to it.
Although, the root user is still assumed to be an infallible god. |
|
| Back to top |
|
 |
Fred Krogh l33t

Joined: 07 Feb 2005 Posts: 657 Location: Tujunga, CA
|
Posted: Mon Jul 18, 2011 3:25 am Post subject: |
|
|
| I don't think this would have saved me when I was trying to update things in /boot and /boot/grub without mounting /boot. But then my root user is a fallible idiot. |
|
| Back to top |
|
 |
PaulBredbury Watchman


Joined: 14 Jul 2005 Posts: 6609
|
Posted: Mon Jul 18, 2011 4:10 am Post subject: |
|
|
Then write a BASH script to do it, and have the script take care of such tedious details as checking whether an intended mount point is mounted first.
Personally, I hate the idea of /boot being a mount point, and weep for its popularity. |
|
| Back to top |
|
 |
Dr.Willy Apprentice

Joined: 15 Jul 2007 Posts: 259 Location: NRW, Germany
|
Posted: Mon Jul 18, 2011 10:03 am Post subject: |
|
|
| PaulBredbury wrote: | | Personally, I hate the idea of /boot being a mount point, and weep for its popularity. |
Why? |
|
| Back to top |
|
 |
PaulBredbury Watchman


Joined: 14 Jul 2005 Posts: 6609
|
Posted: Mon Jul 18, 2011 10:14 am Post subject: |
|
|
It just confuses people, and is one more bizarre "gotcha" for people to be wary of.
Being a bizarre "gotcha" outweights its advantages.
It would be less nasty if a sensible error message were shown, rather than /boot being treated as a normal directory when it's been set up as an intended mount point, which the user has forgotten to mount before using. |
|
| Back to top |
|
 |
BitJam Advocate

Joined: 12 Aug 2003 Posts: 2248 Location: Silver City, NM
|
Posted: Mon Jul 18, 2011 4:52 pm Post subject: |
|
|
I solved this problem for myself a couple of years ago by adding a transparent aterm to my desktop that shows the output of df -h, updated every second. The primary purpose was to make sure usb sticks are unmounted before I remove them but it also works to help me ensure a partition is mounted before I write to it.
If you don't want to clutter your desktop or if you are working in a virtual console then simply run df -h after you think you've mounted something but before you write to it. That's what I do when I'm on a different machine. |
|
| Back to top |
|
 |
Ant P. Veteran

Joined: 18 Apr 2009 Posts: 1295 Location: UK
|
Posted: Tue Jul 19, 2011 9:01 am Post subject: |
|
|
| PaulBredbury wrote: | | It would be less nasty if a sensible error message were shown, rather than /boot being treated as a normal directory when it's been set up as an intended mount point, which the user has forgotten to mount before using. |
Then mount it read-only at boot. _________________ sig temporarily out of order |
|
| Back to top |
|
 |
PaulBredbury Watchman


Joined: 14 Jul 2005 Posts: 6609
|
Posted: Tue Jul 19, 2011 9:20 am Post subject: |
|
|
| If I was gonna mount it at bootup, I would mount it read/write, and spare myself the occasional annoyance when I wanted to add some command-line options to the grub config. |
|
| Back to top |
|
 |
|