in short:

on pc:


on 2 HDD's in root: /music, /docs, /photos.

need to automatically mount HDD1/music to .../music_from_disk_1 and HDD2/music to .../music_from_disk_2 regardless of the number of previously mounted file systems from other devices and from the sequence of connecting the hard disk drives.


i have 2 HDD. UUID HDD1 is 4E1AE and UUID2 is A7B1A. there are /music, /docs, /photos folders exists in root on each HDD.

in pc/music i have 2 folders. one for each HDD/music folder :


and the same hierarchy for photos.

I need to set everything up so that when the HDD1 is connected, the /music folder from HDD1 is automatically mounted into /home/user/Music/music_from_disk_1. and then i plug in HDD2. /music from HDD2 mounted into /home/user/Music/music_from_disk_2. and for /docs, /photos folders the same way.

and no matter what the sequence of connecting the disks and how many other disks and devices I have already mounted.

using UUIDs just to avoid confusion. if there are other more convenient options, of course I will use them.

it doesn't work for me. maybe I'm misusing it or don't know the additional options:

i know how to mount folder to folder. sudo mount --bind /from /to and in /etc/fstab wrote /from /to none bind 0 0. so that after rebooting everything is mounted again.

it works only when you know where HDD[1|2] is mounted now.

and also know how to mount HDD partition to some folder using UUID: /dev/disk/by-uuid/4E1AE /home/user/Music/ auto nosuid,nodev,nofail,x-gvfs-show 0 0 Gnome Disk Utility wrote it in /etc/fstab. "Edit Mount Options"->"Automatic Mount Options".

partition to folder but not folder to folder.

if there is no simple solution, can i probably use the bash(or other) script to check the UUID and mount it in the appropriate folders? I don't know how to write it and don't know how to automatically launch script when any device is connected.

I also know that there is a way to combine 2 partitions into one when mounting without using raid, but I don't need it.

i have Ubuntu 20.04 installed.

  • Do those drives already automatically mount under /media/username/? Aug 14, 2020 at 16:28
  • yes, both of them
    – NikolayFR
    Aug 15, 2020 at 21:15

1 Answer 1


You could create a symlink between the folders and the mount points:

$ ln -s /media/user/4E1AE/music /home/user/Music/music_from_disk_1
$ ln -s /media/user/A7B1A/music /home/user/Music/music_from_disk_2
  • ln -s /media/user/8A94F/music /home/user/music/music_from_disk_1 when is mounted trying to open it and get an error: the link "music" is broken this link cannot be used because its target /media/user/4E1AE/music doesn't exist
    – NikolayFR
    Oct 5, 2020 at 19:22
  • You should adapt the answer to your current setup. It was not a completely generic answer and 8A94F is not mentioned in your question. You could treat it as music_from_disk_3. Try to understand what the symbolic link does so that you can adapt and extend the commands. If in doubt, remove and recreate them, you can see them as just pointers. Oct 5, 2020 at 23:44

You must log in to answer this question.

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