I have installed Ubuntu system at an SS disk and I wish users to access partitions of the second (mechanical) disk as common depositories with full read/write/delete permissions for each file. And I wish that each user see such a partition (say /dev/sdb7) as a directory with a fixed name (say /home/the_user/F). I was advised (Is it possible to mount a partition as a common depository for users with the same relative path?) to mount the partition during boot and to symlink that mountpoint to somewhere in the user's home. However, in the manual for
linkI see an option
‘-d’ ‘-F’ ‘--directory’ Allow users with appropriate privileges to attempt to make hard links to directories. However, note that this will probably fail due to system restrictions, even for the super-user.I am afraid of it. Please advise me an example of a proper link; and the corresponding group or bindfs commands to be used at user login or once forever by the root. Thanks!
You don't need to use hard links, actually we can not create a hard link to a directory because it makes loop in file system hierarchy.
You have to use
-s
option to create a symlink (symbolic link):Let's say I have mounted
/dev/sda7
on/media/some/mount/point
. To create a link to this path I have to run:Like:
The permission of link would be 777 but however a symlink is a different file from you actual directory, it only grant access to symlink itself and the user must have correct permissions to be able to work with the files in
/media/some/mount/point
.Regarding your concern about linking to the mounted directory, it sounds like you may have simply stumbled onto the wrong program. According to your post, you were advised to create symbolic links (i.e. symlinks). However the
link
command only creates hard links. To create symbolic links you can use theln
command instead, e.g.:Regarding shared access, you can set this up using ACLs (access control lists), e.g.:
To demonstrate what this might look like and give you a starting-point to experiment with, here's a longer example which bind-mounts a directory (you would replace this with the actual mount that you want), sets its ownership and permissions (using access control lists), and then creates a symbolic link to it inside another directory:
I think that your question needs two a two-fold answer: firstly on mounting of the device in the filesystem, and secondly on linking a destination location.
Before you start
The following explanations require a terminal program (keyboard shortcut: Ctrl+Alt+t) for typing the commands in.
You will also need a superuser privileges. Typically (as the first user after the fresh installation) you get the privileges by typing
sudo
ahead of the command. After that (typically, if you are the first user after the fresh installation) you have to provide your own password before the command runs.Your hard drive (the "mechanical" disk) needs to be connected to your computer already, and formatted properly with a file system (like ntfs or ext4).
Beware! By changing your fstab file, you work on internals which can stop your computer from booting. This is not a permanent damage, but it will need skill and time to repair. Work with it carefully.
If in doubts about any of the above prerequisite, please ask in the comment.
Mounting the disk at boot-time
Mounting disks in boot-time is made in
/etc/fstab
file. For this you need to know either the UUID of your "mechanical" disk or at least it's name in the/dev
directory.Find the UUID and the name (similar to
/dev/sdb5
) of your disk:It will be listed here. Now determine the filesystem. It will be listed in the last column of the appropriate line of
Next, decide on the mount path, and create it:
Knowing the disk's UUID, name, and the file-system type, your configuration line for
/etc/fstab
looks like this:where
UUID=481aba75-c8a7-4b70-bdc4-fab4de7c1410
can be something like/dev/sdb5
if you had problems establishing what the UUID is. The part/media/shareddrv
is the location that you have decided on, andext4
is the partition type, and be different depending on your disk. The rest remains preferably as it is here.You have to add this entire line to your
/etc/fstab
. Since there are many ways to do it, one quite convenient is to usesudo nano /etc/fstab
and to type/paste the line at the end of the file.Now make your changes work for you: the simpliest way is to RESTART your computer (e.g.
sudo init 6
orsudo shutdown -h now
). If all works, you will see your "mechanical" disk and its mount-point after you type:df -h
in the terminal.Linking the disk in user directories
This part can be done user-after-user, semi-manually. For a user "alice", run:
And repeat this for each user. At the end you could
unset TMPUNAME
but not necessarily.I hope all works for you. If you find this mini-tutorial helpful, please upvote my answer and mark it as useful. Thank you! Also ask more questions if something isn't clear or does not work!