0

I have several external harddrives that I want to mount to the same point: /media/ext_hd

So I have this in my fstab:

# EXTERNAL HDS
LABEL=Elements          /media/ext_hd           ntfs-3g defaults,user,noauto 0 0
LABEL=olddata           /media/ext_hd           auto    rw,user,noauto 0 0
LABEL=Seagate%202T      /media/ext_hd           auto    rw,user,noauto 0 0
UUID=335F-0049          /media/ext_hd           auto    rw,user,noauto 0 0

I would like to just type "mount /media/ext_hd" and have mount find which label or UUID matches whatever is currently connected, and mount that. But, instead it balks that label "Elements" can't be found - the first entry.

Mount doesn't appear to search for a best match. Am I missing something? That would seem like a useful feature.

1

As far as I'm aware mount doesn't scan past the first match. One thing you could do (should consider?) is to set-up udev rules that create the same symlink for all your NTFS disks under /dev ... then a single line in fstab will do for any/all of them.

  • Sorry, should have said - Ubuntu 14.04. Thing is, that's not even the first match. It appears to not look past the first mount point match, disregarding the label. I did udev rules in the past for this exact functionality I'm seeking, but once the OS (or udev?) started keeping /dev/disk/by-uuid, I stopped this since udev rules are often a pain. While it's a good plan B, I'm holding out for a better answer for a bit... – Greg Bell Aug 6 '14 at 6:38
1

Don't know what OS you are using; but FreeBSD best-practice for this sort of thing is to use glabel to attach a label to the file system. Then the labels appear as /dev/ufs/[label] and you use that in your fstab specification. For example, if these are USB devices and they all autoconfig alternatively to /dev/ad0s0a, /dev/ad2s0a, and /dev/ad3s0a, you can use their labels instead:

/dev/ufs/gerbil0    /gerbil            ufs     rw              2      2
/dev/ufs/gerbil1    /gerbil            ufs     rw              2      2
/dev/ufs/gerbil2    /gerbil            ufs     rw              2      2

or

/dev/ufs/gerbil0    /someplace         ufs     rw              2      2
/dev/ufs/gerbil1    /anotherPlace      ufs     rw              2      2
/dev/ufs/gerbil2    /yetanotherPlace   ufs     rw              2      2
  • Yes, ext4 has filesystem labels too, but they're different for my different external HD's... which helps identify them. I think that's what the labels are for. For humans. So I make them all the same I'd be losing that benefit as well as possibly confusing myself as to what disk was what. – Greg Bell Aug 6 '14 at 6:35
  • @GregBell "I think that's what the labels are for. For humans." Yes, they are certainly for humans; however, following the example I gave above, you can see that the machine will read them as well. Which is why they should all have different names. e.g.: olddata0, olddata1, olddata2, etc. I'm somewhat clueless about Ubuntu, but grep thru /dev when one of these beasts is plugged in and see if the name doesn't appear somewhere. Then try that path in /etc/fstab. – ericx Aug 6 '14 at 19:04
  • Yes, filesystems with labels automatically get put in /dev/disk/by-label by Linux, but mount stops checking fstab at the first matching mount point! It seems to me it should keep looking for a mount point and label match. It's so obvious I'm thinking I must be missing something. – Greg Bell Aug 7 '14 at 7:55
  • Agin this may not be linux appropriate; but the trick is to use the path to the label in your fstab rather than the path to the partition's device. This also implies that all the labels are unique even tho the path to their partition device may be identical. So mount still stops with the first-fit; but since it's unique, it's what you want. (I expanded the fstab example above) – ericx Aug 7 '14 at 14:33
  • I apologize, I'm not being helpful. The above example works for external drives on FreeBSD; but typically usdb is also doing an automount for me. Frankly, with the LABEL designations you have, I would have expected it to work. – ericx Aug 7 '14 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.