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 ?


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.

| improve this answer | |
  • 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 – Eduard Florinescu Sep 25 '18 at 14:04
  • 1
    Yes, exactly. And after you edited /etc/fstab, you can just mount /myfolder. – dirkt Sep 25 '18 at 14:17

A quick fix would be to unmount all already mounted and mount them all in folders having the uuid serial:

cd /media/$USER
ls -1 | xargs -L1 -I {} sudo umount /media/$USER/{}
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
| improve this answer | |

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.