how to mount [bind] an external hard drive folder using UUID to another folder on a pc
0
votes
1
answer
2243
views
**in short:**
-------------
on pc:
/home/user/Music:
├─music_from_disk_1
└─music_from_disk_2
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.
**detailed:**
-------------
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 :
/home/user/Music:
├─music_from_disk_1
└─music_from_disk_2
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.
Asked by NikolayFR
(1 rep)
Aug 14, 2020, 02:44 PM
Last activity: May 31, 2024, 01:07 AM
Last activity: May 31, 2024, 01:07 AM