1

I have many hard-disks that need to be mounted on restarts some have have NTFS file-systems other have EXT4, some are USB and some are SATA, some have the same label names, and they don't get mounted in the same place.

Is there a way that I pin a mount folder to a specific serial number, so that the same disk gets mounted in the same place every-time ?

2 Answers 2

4

First, have a look at the various symlinks in /dev/disk/.... Symlinks exist for different criteria (volume label, serial number of disk, ...), and you can pick those that best describe the partition you are interested in.

Second, you can edit /etc/fstab to mount those partitions wherever you'd like them to be mounted. Including to directories with some serial number. Yes, you need one entry for every partition.

If instead you are talking about auto-mounting, and want some general scheme for autom-mounting, that will depend on your auto mounter. One way would be to write custom udev-rules with high priority than whatever your auto-mounter uses.

2
  • now I see in /dev/disk/ i have this folders by-id/ by-path/ by-uuid/ so you say I can mount like this mount /dev/disk/by-id/serial /myfolder Sep 25, 2018 at 14:04
  • 1
    Yes, exactly. And after you edited /etc/fstab, you can just mount /myfolder.
    – dirkt
    Sep 25, 2018 at 14:17
0

A quick fix would be to unmount all already mounted disks and mount them all in folders having the uuid serial which is unique and doesn't change:

#cd /media/$USER
#ls -1 | xargs -L1 -I {} sudo umount /media/$USER/{}
#above two lines only if there are drives mounted by nautilus
sudo mkdir /media/amounted
cd /media/amounted
ls -1 /dev/disk/by-uuid/ | xargs sudo mkdir 
ls -1 | xargs -L1 -I {} sudo mount /dev/disk/by-uuid/{} /media/amounted/{}

Then list the drive with the corresponding mount folder uuid etc:

sudo lsblk -o name,mountpoint,tran,fstype,label,size,uuid

Having the disks mounted with uuid, permits then to symbolic links to those uuids and you can have then any kind of descriptive names to those drives.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .