Open probonopd opened 3 years ago
I will try in my next stint of free time to see if it will take a lot of effort to change that into 'Volume Names'.
Implementing this feature would be a huge usability improvement imho, both for GUI users as well as for command line users, because it would make it much more obvious what it is that is mounted.
So I have tried to implement it
but two issues I need help with:
(1) The mount command fails because I added quotes around the moint point directory (since the volume name, and hence the mount point directory, can have blanks in its name)
/var/log/automount.log
says:
/dev/da0p1: mount FAIL: 'mount_msdosfs -o longnames -m 777 -M 775 -D cp437 -L en_US.UTF-8 -u 0 -g 0 -o noatime /dev/da0p1 '/media/ESP (8)''
When I execute this exact command hy hand mount_msdosfs -o longnames -m 777 -M 775 -D cp437 -L en_US.UTF-8 -u 0 -g 0 -o noatime /dev/da0p1 '/media/ESP (8)'
then it works fine. There must be something to the escaping in POSIX sh that I am missing?
(2) When one unplugs e.g., a USB device without properly unmounting it, there is no apparent way to find out which mountpoint directory the device was mounted to for REMOVEDIRS="YES"
? So automount would need to keep the state about which device it has mounted to which mountpoint somehow. (Without REMOVEDIRS="YES"
this whole exercise makes little sense imho.)
Hi,
could you send me the modified version in a whole by email?
I am not able to make that diff link work.
Thanks.
Here:
https://github.com/vermaden/automount/blob/master/automount
Use NICENAMES=YES
in the /usr/local/etc/automount.conf config.
This one supports labels as /media dirs with automatic mounting and unmounting.
I needed to change your format of LABEL (2)
into LABEL-2
because of shell string escaping.
I also replace all spaces ' '
to hypens '-'
because of that.
I hope that is not a problem.
Let me know how it worked for you.
I have left NICENAMES=YES
enabled on my desktop so I will also try to catch any issues.
Regards.
Very nice, thank you so much @vermaden.
It would be much nicer if we could have spaces indeed. Are we reaching the end of what is possible with sh
here?
The mount(8)
command output is separated by spaces this having spaces in mount points it PITA to process. Its more error prone.
Also I keep the sates of mounted devices in /var/run/automount.state
file which is also space separated columns - would have to rework/rethink that.
IMHO for the display purposes on the desktop just replace '-' with ' ' and 'technical' mount point can be with spaces.
Regards.
I understand the technical challenges but let's try to treat spaces as first-class citizens, not as an afterthought. Names for disks like "My Photos" or "Macintosh HD" are very common. It's how "mere mortals" often like to name things. In fact, "Macintosh HD" is the default name for the boot disk on the Mac.
The mount(8) command output is separated by spaces this having spaces in mount points it PITA to process. Its more error prone.
Let's use -p Print mount information in fstab(5) format
then, it uses (one or multiple) tabs as the separators, which can be reduced to single tabs like this:
mount -p | sed -e 's|\t\t*|\t|g'
Also I keep the sates of mounted devices in /var/run/automount.state file which is also space separated columns - would have to rework/rethink that.
Would tabs work to separate the columns work for you?
I will think about that.
Roughly:
# FUNCTION: check if device or mountpoint not already mounted
__check_already_mounted() { # 1=DEV 2=MNT
DEVICE=$(mount -p | sed -e 's|\t\t*|@|g' | cut -w -f 1 | grep "^${1}@") # FIXME: Use tabs instead of @
if [ -n "${DEVICE}" ] ; then
MOUNT_POINT=$( mount -p | sed -e 's|\t\t*|@|g' | grep -e "^${DEVICE}@" | cut -d @ -f 2 ) # FIXME: Use tabs instead of @
__log "${DEVICE}: already mounted on '${MOUNT_POINT}' mount point"
exit 1
fi
MOUNT_POINT=$(mount -p | sed -e 's|\t\t*|@|g' | cut -f 2 | grep "@${2}@") # FIXME: Use tabs instead of @
if [ -n "${MOUNT_POINT}" ] ; then
DEVICE=$( mount -p | sed -e 's|\t\t*|@|g' | grep -e "@${MOUNT_POINT}@" | cut -d @ -f 1) # FIXME: Use tabs instead of @
__log "${DEVICE}: already mounted on '${2}' mount point"
exit 1
fi
}
I used @
characters because I could not get it to work with \t
- probably I missed some intricacies of how sed works ;)
Of course this is not ideal because disks could have @
characters in their names, so we should improve upon this.
Check latest version with NICENAMES=yes option.
Thanks.
I would like mount points to be named like the volumes are named, rather than how the device nodes are named. I never know what to make of these. Also, they should be automatically removed when nothing is mounted there anymore.
This is how it currently looks inside
/media
:This is how it looks e.g., on the Mac:
As you can see, the mount points are constructed using the volume name ("NIFTY DRIVE"). If there are multiple disks with the same name,
2
,3
,... is appended.Use case:
On helloSystem, we are displaying the correct disk names on the desktop (blue background in the screenshot; we obtain these names by running
fstyp -l /dev/xxx
; maybe there is a better way) but as soon as the user navigates to/media
, only the cryptic mount points are shown; same on the Terminal.cc @mszoek