Mount a fileserver automatically by afpfs

I got an Zyxel Nas326 which i filled with 2 still good 6TB drives i had access to. Now, i have several questions in regard. And, in advance my excuses for being so ingeniuous … :innocent:

I can access the server either using smb or afp (from what i read, afp should be better as for speed). nfs should work too, but does not (probably because of problems with username & password which are not transmitted - and i do not see how to set up in the configuration software on the nas a handshake by ip addresses).

Anyway in Thunar all that (afp and cifs) works fine, but Thunar laments too about nfs. But, since I’d like to be able to access the net volumes by ranger as well - and i would like to have an automated access i think i should set up one (or more, if more volumes should be mounted) line in fstab.

But how? I found this instruction:
host_name:/share_name /Volumes/mount_name url automounted,url==afp://user_name:password@host_name/share_name 0 0

What would be the correct format of host_name? The plain text or the ip?

And what would be the correct format of url? http://ip.adress or afp://ip.adress?

When i handish mount the drive i get an error msg that afpfsd is not configured to be run by uid=1000 (which would be me, but runs at 0, which i presume is root (?) ). How can i change the config of afpfsd consequentely, if so … ? I experienced, by chance that setting group=wheel me gives access anyway.

And, at least, a question regarding fuse: I realize there is no group fuse on my machine (although fuse is installed) - should there be such group and who should be in that group? So eventually i could add the mounted drive to fuse to have access to it …

Thanks a lot in advance for any pointer.

Searching further i found this:

sudo mount_afp afp://<username>:<password@<server-ip>/photo /net 

mounts the share (photo in this case) but only for root. not for the usr. When i specify in the mount command group=wheel i get an error msg:

Incorrect permissions on mountpoint group=wheel: No such file or directory

How would that translate a) into fstab and b) with the correct rights so that i as user (and not as root) have access to the mounted share?

From the link you provided:

Note that the host_name must resolve to the actual IP address of the host computer. You could modify /etc/hosts to add the host_name to it if the host_name cannot be resolved by the DNS server.

So the ip address is fine, as is the hostname assuming it can be resolved.

The url would be the filesystem type. Never seen url used before.

It may be that it only works on a mac, since that guide is for a mac. You can try, but have a live USB handy just in case.

Because mount is trying to mount the device you gave it and group=wheel is not a valid path or device.

I don’t know about the rest. Maybe these will help, if you haven’t already read them. I’d try NFS again, but if that isn’t working then samba might be the path of least resistance.
Netatalk - ArchWiki # AFP, not much help, but it’s short

First of all: Thanks!!!

I’ll retry nfs - but i don’t have so much hope …

And then, i discovered that, when i change the handish command in this way:

sudo --user=<linuxusername> mount_afp afp://<username>:<password@<server-ip>/photo /net

i.e. adding me as the user, then i have the rights to access the mounted drive.

I think that could translate into fstab as:

afp://<username>:<password@<server-ip>/photo /net user=<linuxusername> 0 0

Never even heard of afp until this post, so not sure about mount_afp, but it’s not mount so it may not be compatible. What makes you think this is right?

It’s missing the filesystem type, otherwise it at least looks a bit like an fstab entry, whether it is or not :man_shrugging: . Did you try:

<server ip>:/share_name /mount_name url automounted,url==afp://user_name:password@<server ip>/share_name 0 0

If it’s not that then I’d just move on to samba or back to nfs, due to the lack of info on afp. Unless someone else has more info, or running the command on login is acceptable.

I can’t find anything about fstab entries for afp and linux, the only things I can find are about using linux as a fileserver for a mac.

At least you have a command that works, you can always run it at login or whatever. :slight_smile:

In theory, i think it wouldn’t be state of the art, but … at least i could write a script and execute it automatically at the end of my startup programs, i think …

Then a, related, question: is it useful to have a group fuse (where i belong to, obviously and which rights should that group have?


Yeah, you can run it manually or append to .bashrc or put it in auto start etc. :slight_smile:

sudo --user=<linuxusername> mount_afp afp://<username>:<password@<server-ip>/photo /net

I haven’t used a remote filesystem in a few years and when I did it was nfs, don’t remember using fuse. I have used fuse once or twice at some point, but I currently don’t have a fuse group not sure I ever have.

About the only recent thing I can find about a fuse group is this.

Users are allowed to use fuse if they could read and write to /dev/fuse ie they are in group fuse on debian system. Starting with Debian 8 (Jessie) this group is not required anymore because /dev/fuse is world-writeable.

My system seems to agree that a fuse group is no longer needed. :slight_smile:

$ ls -l /dev/fuse
crw-rw-rw- 1 root root 10, 229 Dec 24 15:32 /dev/fuse

Thanks a lot to you!

If i’ll ever find a solution via fstab, i’ll post it here. But i think i’ll go the way of a bash script …

1 Like

That would be great, I’d be interested and it would help future readers with the same problem . :slight_smile:

You’re welcome and merry xmas (if it applies). :slight_smile:

That is actually not adding you as the user, but instead executing that command as that user, see sudo(8):

-u user, --user=user
Run the command as a user other than the default target user (usually root). The user may be either a user
name or a numeric user-ID (UID) prefixed with the ‘#’ character (e.g., #0 for UID 0). When running commands as
a UID, many shells require that the ‘#’ be escaped with a backslash (‘\’). Some security policies may restrict
UIDs to those listed in the password database. The sudoers policy allows UIDs that are not in the password
database as long as the targetpw option is not set. Other security policies may not support this.

There seems to be an netatalkAUR package in the works which might help…

1 Like

Running zsh as default shell my shebang would be this, i presume:
#!/usr/bin/env zsh

Or not?

Either that or #!/usr/bin/zsh should work. :slight_smile:

However that line tells the shell how to interpret the script, so it should be ok using bash, as long as it’s valid bash.

sudo and mount_afp are both external commands, so aren’t shell specific.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.