Linux – Mount Linux Drive in Two Places

hard drivelinuxmount

I've been looking for a way to mount the same drive (e.g. /dev/sdd1) in two places on a hard drive. If I try using the command that I use to mount a drive in the first location again, I recieve the error:

"Mount is denied because the NTFS drive is already exclusively opened."

I've also tried binding the mount point, but obviously if the main location becomes unmounted, the binded folder becomes in accessible.

Are there any other commands I can try?

Best Answer

The only way I can see of solving this problem (the "what happens if it got unmounted?" part in particular) is to use automount and symlinks, as suggested in Gustav's answer:

ln -s /mnt/original /home/max/newlink

The trick though would be to make /mnt and in particular /mnt/original be covered by an automount map, your distribution should provide a package for this, you'll need something like the following in /etc/auto.master:

/mnt    /etc/auto.mnt

and then in /etc/auto.mnt:

original        -fstype=ntfs    /dev/sdd1

In this way accessing /mnt/original will cause /dev/sdd1 to be mounted appropriately, but "looking through" the symlink will also cause it to be mounted if not already mounted for any reason.

(One more thing - if you happen to export this through samba too, you'll need to use preexec to make samba believe it existed. I was "the chatty friend" in this blog post)