General TC > Programming & Scripting - Unofficial

Feature Suggestion: Descriptive Mount Points

<< < (2/2)

ixbrian:

--- Quote from: curaga on November 27, 2010, 12:09:21 PM ---IMHO naming it by the label is less descriptive to me. I know /mnt/sda1 is my usb stick, but what the heck is /mnt/asdf_asdf_fasd? Or /mnt/data, FWIW. Maybe the label could be a symlink to the main dir?

Then there's the issue of cd/dvd media. If there's a disc in at boot, the dir shall be /mnt/TheDayAfterTomorrow, even after it has been changed.

--- End quote ---

I updated rebuildfstab to auto create symlinks from the label to the device name in /mnt.   However, this won't really work because if you try to mount the symlink label, mount just says it can't find the symlink label in /etc/fstab.  I guess it would be possible to have 2 entries per filesystem in /etc/fstab (one for device name, one for label name), but that doesn't seem like a good idea to me.  

Anyway, I updated the rebuildfstab patch so that it will exclude CD/DVD devices from using a label name for the mount point due to the very good point you brought up about changing media.  

Here is the updated patch.


--- Code: ------ rebuildfstab_orig
+++ rebuildfstab_updated
@@ -41,13 +41,15 @@
   DEVMAJOR="$(cat $i|cut -f1 -d:)"
   FSTYPE=""
 
+  CDROM=no
+
   case "$DEVMAJOR" in
     2|98)
       FSTYPE="auto"
       ;;
     3|8|11|22|33|34)
       case "$FDISKL" in *"$DEVROOT/$DEVNAME "*) FSTYPE="$(fstype $DEVROOT/$DEVNAME)" ;; esac
-      case "$CDROMS" in *"$DEVROOT/$DEVNAME"*) FSTYPE="auto" ;; esac
+      case "$CDROMS" in *"$DEVROOT/$DEVNAME"*) FSTYPE="auto"; CDROM=yes ;; esac
       ;;
     179|9|259) # MMC or MD (software raid)
       FSTYPE="$(fstype $DEVROOT/$DEVNAME)"
@@ -63,8 +65,15 @@
     ext2|ext3) OPTIONS="${OPTIONS},relatime" ;;
     swap) OPTIONS="defaults"; MOUNTPOINT="none" ;;
   esac

+  LABEL="$(blkid $DEVROOT/$DEVNAME -o udev 2>/dev/null | grep ID_FS_LABEL= | cut -f2 -d= )"
+
+  if [ -n "$LABEL" -a "$CDROM" = "no" ]; then
+    MOUNTPOINT="/mnt/$LABEL"
+  fi

   if [ "$MOUNTPOINT" != "none" ]; then
-    mkdir -p "/mnt/$DEVNAME" 2>/dev/null >/dev/null
+    mkdir -p "$MOUNTPOINT" 2>/dev/null >/dev/null
   fi
   printf "%-15s %-15s %-8s %-20s %-s\n" "$DEVROOT/$DEVNAME" "$MOUNTPOINT" "$FSTYPE" "$OPTIONS" "0 0 $ADDEDBY" >>"$TMP"
 done



--- End code ---

maro:
Just a quick question: What happens if a LABEL is not unique amongst the set of devices? I could quite easily imagine to have a file system labeled 'DATA' on two different devices (e.g. a USB hard disk and a USB pendrive).

Another quick thought: Would using hard links instead of soft links make a difference?

gerald_clark:
How would you hard link them?

ixbrian:

--- Quote from: maro on November 27, 2010, 03:42:27 PM ---Just a quick question: What happens if a LABEL is not unique amongst the set of devices? I could quite easily imagine to have a file system labeled 'DATA' on two different devices (e.g. a USB hard disk and a USB pendrive).

--- End quote ---

Good point.  It wouldn't be too difficult to add in some logic to work around having non-unique labels.  If there is interest in moving forward with using labels as mount points I can work on adding it in. 

Brian

SamK:
The inclusion of labels as announced in this topic http://forum.tinycorelinux.net/index.php?topic=7949.0 is a welcome move.  It led me to ponder further...

In this topic http://forum.tinycorelinux.net/index.php?topic=7935.msg42672 a patch was accepted in recognition that multiple partitions are now more likely due to the ready availability of large disks.  It may therefore become more desirable for them to indicate their purpose/content.

An example of the adopted manner of displaying labels is of course not yet available.  From the announcement, it appears that only those using mnttool will obtain the benefit of enhanced identification.  In contrast, a descriptive mount point would be available to all users whatever method they choose. 

Currently, I conduct mounting/unmounting by command line (including scripts), mnttool, and file manager.  From my point of view, the ideal outcome would be that each method is able to use the enhancement.  This is in no way suggesting that TC/MC should be designed to take account of the vagaries of third-party extensions.  In view of the offer of a patch, it is regrettable that only one of these methods will benefit in future.



--- Quote from: ixbrian on November 27, 2010, 08:12:08 PM ---
--- Quote from: maro on November 27, 2010, 03:42:27 PM ---Just a quick question: What happens if a LABEL is not unique amongst the set of devices? I could quite easily imagine to have a file system labeled 'DATA' on two different devices (e.g. a USB hard disk and a USB pendrive).

--- End quote ---

Good point.  It wouldn't be too difficult to add in some logic to work around having non-unique labels.  If there is interest in moving forward with using labels as mount points I can work on adding it in. 

Brian

--- End quote ---
Would this not be automatically taken account of if the mount point name is constructed of the two values device-id_label or vice versa?  It may be possible for a system to have multiple labels such as 'DATA' but not multiple 'sda1_DATA' etc.
   

Navigation

[0] Message Index

[*] Previous page

Go to full version