0

I have zero previous experience with unix (other than I used to have an account on an SGI box more than 25 years ago and remember some of the commands).

I want a rasberry pi 4 to auto-logon to a remote share (could be a NAS box, could be a windows share) and the mount command specifies the remote path and also specifies a local path which must exist.

I don't understand why.

What role does the local path perform?

I want the PI to act as a syslog server and write the logs to the remote share.

0

This is because Unix/Linux tries to represent everything as a file/directory in the local filesystem (even things like hardware and states of the system).

So this also counts for remote directories: After mounting a remote dir on a local dir you will be able to read/write from/to the local dir but the effects will actually happen on the remote dir.

It also makes it way easier for software to handle files on remote servers because it can use them as if they exist locally.

Example: In my /etc/fstab file (the file containing all information about how the system should mount stuff) on my desktop I have a line:

//secrethostname/vanalles /mnt/targasmb cifs user,noauto,guest,ro 0 0

(secrethostname is actually another name, i just don't want to post it online...)

When I now run mount /mnt/targasmb on my desktop I will be able to see all files in the vanalles dir on secrethostname in the directory /mnt/targasmb on my local system. I will also be able to able to read them as if they exist locally.

cifs user,noauto,guest,ro 0 0 provides the system more info about what the mount is and how it should be mounted by default. The details are for another question.

7
  • I guess I find it strange that I have to specify a local (and real) dir to which nothing actually gets written to when I mount (and write to) the remote dir. I could understand this better if the local dir was virtual (for the purpose of the mount) and hence would go away when the remote dir was unmounted. The current implimentation makes it confusing when you issue a dir listing command and you don't know what files actually do exist in the local dir vs which ones exist on the remote share. – Peggy Schafer Dec 24 '19 at 15:27
  • Or what happens if files with the same names already exist in both locations when the mount command is issued. – Peggy Schafer Dec 24 '19 at 15:33
  • If there are already files in the local dir they become invisible until you umount the remote dir (this is why you normally do this on a empty dir). Because the local files become invisible the problem of files with the same name doesn't occur. There are implementations that do it like you describe (creating a temporary dir before mounting and removing after mounting) but they are very rare because it makes things harder(e.g. user has to start searching for the dir). It is possible to write scripts that do this for you, but the system that doesn't do it automatically to give you more control – Garo Dec 24 '19 at 15:44
  • Ok, so this is a really kludgy way they decided to do this. Not elegant at all. – Peggy Schafer Dec 24 '19 at 16:58
  • I wouldn't have it any other way. Lot's of advantages and the only thing vaguely resembling a disadvantage is that you have to choose a local location. "have to" should even be replaced by "get to". – Garo Dec 24 '19 at 19:49

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.