*** DISCLAIMER: The information on these pages is not an official instruction or documentation. No responsibility will be taken. Use at your own risk. ***

Thursday, December 6, 2018

How to set up NFS and mount on Amiga

Here's one way to set up an nfs server under Linux, and mount an nfs share on your Amiga.

Requirements / prerequisites


We're using:

- Linux Fedora 25 or 33 (x86_64 hardware)
Probably any Linux will do, but configuration files and command syntax may differ. NFS must be supported, obviously. We need to be able to set up a NFS v2 server with udp support. This is non-standard on Fedora 25 and 33.

- Amiga 1200
Any Amiga that's able to run AmiTCP3.0b2, and connect to the machine running our Linux, will do.

- TCP/IP connection via AmiTCP3.0b2
We're assuming a working AmiTCP3.0b2 installation, which provides the nfs tools required on the Amiga side, and an active TPC/IP connection to the Linux machine.


In this example we're using IP addresses...

10.10.10.1 for the Amiga and
10.10.10.2 for the Linux box

Our netmask is: 255.255.255.0


We'll be using a Linux user account called "ami" with UID (user id) 1000 and GID (group id) 1000.

We'll create a user account on the Amiga accordingly ("ami", UID 1000, GID 1000) to avoid access-rights confusion. The Amiga user's home directory will be:

Work:home/ami


Our nfs share (the Linux directory visible to the Amiga) will be:

/home/ami

This directory - in this case it's the user "ami"'s home directory - should be accessible to the Linux-user "ami", thus it will also be accessible the same way to the (newly created) Amiga-user "ami" via nfs.

In your setup, replace numbers/paths/names with your own values as required.


Linux (IP 10.10.10.2)


Fedora 25's nfs server needs to be "downgraded" to be compatible with AmiTCP3.0b2's nfs tools. nfs version must be 2, and AmiTCP only supports nfs via udp protocol. If udp is not enabled, you will get a RPC error message on the Amiga side.

In Fedora 25, the config file is...

/etc/sysconfig/nfs

...and the arguments required are:

# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
RPCNFSDARGS="-V 2 --udp"


In Fedora 33, the config file is...

/etc/nfs.conf

...and in section [nfsd] 

udp=y
vers2=y

...must be set.


Next tell nfs server which directories we want to share with the Amiga or other machines, and who's allowed to access them.

The file...

/etc/exports

...contains the setup - use the example below, or add the second line to your file if you already have one. You can see our shared directory, the 10.10.10.xxx range of IP addresses allowed to access it, and our netmask:

/ *(ro,fsid=0)
/home/ami 10.10.10.0/255.255.255.0(rw,nohide,insecure,no_subtree_check,no_root_squash)


NOTE: These are two lines, each starting with "/".

You could also use e.g. just 10.10.10.2, restricting access to this IP address only.

NOTE: Try "man exports" on your Linux machine if you want to know more about the configuration file.



Now we can start (or restart) the nfs server. On Fedora 25 the command is: 

systemctl start nfs-server.service

NOTE: On other Linux systems, you may have to start portmap or rpcbind service first. On Fedora 25 rpcbind.service is enabled by default.


To see if your nfs server is ready enter:

rpcinfo -p

...which will probe and print services registered with the portmapper (see note above). You should see a list roughly like this:

[root@linux]# rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  38814  status
    100024    1   tcp  53319  status
    100005    1   udp  20048  mountd
    100005    1   tcp  20048  mountd
    100005    2   udp  20048  mountd
    100005    2   tcp  20048  mountd
    100005    3   udp  20048  mountd
    100005    3   tcp  20048  mountd
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    2   tcp   2049  nfs_acl
    100227    3   tcp   2049  nfs_acl
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100227    2   udp   2049  nfs_acl
    100227    3   udp   2049  nfs_acl
    100021    1   udp  39239  nlockmgr
    100021    3   udp  39239  nlockmgr
    100021    4   udp  39239  nlockmgr
    100021    1   tcp  33909  nlockmgr
    100021    3   tcp  33909  nlockmgr
    100021    4   tcp  33909  nlockmgr


The important lines are the ones with a "2" in the "vers" = "version column. Remember configuring nfs server for version-2 support?
We need a version-2 portmapper supporting udp (line 6), same for mountd (line 11), nfs (line 15), and nfs_acl (line 18).


If you got this far without errors, you're done with the Linux part.

For setup/testing it's probably best to make sure your Linux's firewall is off. You can examine network traffic/ports and adjust your firewall settings later.


Amiga (IP 10.10.10.1)


Now we can partly test the setup from the Amiga side using "rpcinfo", which comes with AmiTCP3.0b2:

rpcinfo -p 10.10.10.2

This should give you the same list as on the Linux side. (See above.)

NOTE: Output syntax may differ slightly - service names (rightmost column) might be missing.


We need to specify a user account on the Amiga side. For a proper setup it should match the Linux user "ami"'s UID and GID (see "Requirements / prerequisites" above).

NOTE: The user's name is actually not relevant to nfs, but for simplicity and clearness we also call it "ami", just like the Linux one.

Before creating an Amiga user for AmiTCP, we first create a home directory for him/her:

makedir Work:home/ami



Next, create the user account. Edit the file...

AmiTCP:db/passwd

...and add a line that looks like this:

ami|*|1000|1000|Amiga 1200|Work:home/ami|shell

Separated by pipes ("|"), these are...
...user name
...password ("*" = empty)
...UID (user id)
...GID (group id)
...real name
...home directory
...login shell command

NOTE: Try "man 5 passwd" on Fedora 25 for an explanation of the password-file. (Linux uses colons instead of pipes here.)


Probably not required, but it's always good to set a password for a user - do so by entering:

AmiTCP:bin/passwd ami

...and enter your desired password. (Twice.)

NOTE: Now your AmiTCP:db/passwd file contains an encrypted password instead of an asterisk in the password-field for user "ami".


Next set up the nfs share (directory) for the Amiga - to do so, we edit the file...

AmiTCP:db/ch_nfstab

...and add this line:

10.10.10.2:/home/ami NFS: user ami umask 0755

As you can see there's our Linux's IP address, and the shared Linux directory.
Next is the local (Amiga) name for the share ("NFS:"), with a trailing colon, just like a logical drive ("assign") on the Amiga. Finally the user account we want to use, and a umask, defining which access-rights a file written to the share will have.

NOTE: "0755" basically means: owner can read, write (also delete), and execute file, others can just read and execute. Here's an extensive explanation of Linux file permissions: https://help.ubuntu.com/community/FilePermissions


And here cometh the moment of truth!

Finally, to mount your nfs share on your Amiga, enter this:

AmiTCP:bin/ch_nfsmount nfs: 

NOTE: Needs stacksize > 30000. You will get an error message if it's insufficient. Use e.g. "stack 100000" to set it to 100000.

As you can see the argument to "ch_nfsmount" is our local nfs share name "nfs:". (AmigaDOS is not case sensitive.)

A disk icon named "NFS" should pop up on your workbench, and you're ready to use your Linux's directory from your Amiga! 


Debugging


Network debugging etc. is very limited on the Amiga:

Test your TCP/IP network connection:

ping 10.10.10.2

List your Linux's registered RPC services from the Amiga side:

rpcinfo -p 10.10.10.2


Linux has some powerful network debugging tools:

You can switch on kernel debugging modules, then watch your Linux log files (syslog, kernel log) for output:

rpcdebug -m nfsd -s all rpcdebug -m rpc -s all

NOTE: This sets all debug flags for modules "nfsd" and "rpc", enabling debug logging. To clear use "-c" instead of "-s".

"wireshark" is a powerful network traffic analyzing tool, that allows to capture, and view network traffic in full detail.


Notes

  • Your mileage may vary. There are a couple of bugs and instabilities along the way. Don't be too harsh with nfs on the Amiga. If in doubt reset and retry. (See next note, too.)
  • An update to the nfs tools provided with AmiTCP 3.0b2 is available on AmiNet, including docs: http://aminet.net/package/comm/net/chnfsc102-30b2
  • AmiTCP is known for it's extensive documentation. Read the docs for general TCP/IP information, and details about AmiTCP's components.
  • Your Linux most likely contains man-pages on the network commands and configuration files used here. The commands provided with AmiTCP 3.0b2 are more or less compatible.
  • Special thanks to Markus "Tulpi" T. for massive technical and moral support!

 

History:
2021-03-18: added Linux Fedora 33 information

No comments:

Post a Comment

Your comment will published after it has been reviewed.