You are not logged in.
Pages: 1
I have two machines: server and miniserver and ran the following commands
server:
sudo pacman -S openmpi
cd ~/.ssh
ssh-keygen -t rsa
cp id_rsa.pub authorized_keys
chmod 600 authorized_key
sssh-copy-id miniserver
sudo vi /etc/ssh/sshd_config: Add the following lines
PubkeyAuthentication yes
RSAAuthentication yes
sudo pacman -S ntp
sudo vi /etc/ntp.conf: Add the following lines
tos orphan 15
logfile /var/log/ntp.log
sudo ntpd -u ntp:ntp
sudo systemctl start ntpd.service
sudo systemctl enable ntpd.service
sudo pacman -S nfs-utils
mkdir ~/sharedfolder
chmod 777 ~/sharedfolder
sudo vi /etc/exports:
/home/vorlket/sharedfolder miniserver(rw,sync)
sudo exportfs -arv
sudo systemctl start nfs-server.service
sudo systemctl enable nfs-server.serviceminiserver:
sudo pacman -S openmpi
cd ~/.ssh
ssh-keygen -t rsa
cp id_rsa.pub authorized_keys
chmod 600 authorized_key
sssh-copy-id server
sudo vi /etc/ssh/sshd_config:
PubkeyAuthentication yes
RSAAuthentication yes
sudo pacman -S ntp
sudo pacman -S nfs-utils
mkdir ~/sharedfolder
chmod 777 ~/sharedfolder
sudo mount server:/home/vorlket/sharedfolder /home/vorlket/sharedfolderNow, I want to know how to automount the nfs on miniserver on startup.
Last edited by vorlket (2024-01-03 10:02:51)
Offline
Write a unit file on miniserver like this one and save it as /etc/systemd/system/sharedfolder.mount:
[Unit]
Description=mount sharedfolder
Requires=network-online.target
After=network-online.service
[Mount]
What= server:/home/vorlket/sharedfolder
Where=/home/vorlket/sharedfolder
Type=nfs
Options=rw,timeo=10,rsize=131072,wsize=131072,noatime,hard
# Uncomment the below if your server is real slow
TimeoutSec=10
[Install]
WantedBy=multi-user.targetAnd additionally /etc/systemd/system/sharedfolder.automount:
[Unit]
Description=sharedfolder.mount automounter
Requires=network-online.target
[Automount]
Where=/home/vorlket/sharedfolder
TimeoutIdleSec=5m
[Install]
WantedBy=multi-user.targetAnd then enable only the automount. It will trigger the mount.
P.S.: As you can see "Where" is duplicated... not sure if you can remove it in one of the files.
Last edited by thorstenhirsch (2024-01-01 21:46:31)
Offline
nb. the caveats on "network-online.target", neither networkmanager nor networkd default to what you'd expect as sane behavior and will trigger the target before there's an actual network connection established.
https://wiki.archlinux.org/title/System … work_is_up
https://wiki.archlinux.org/title/Networ … ait-online
https://wiki.archlinux.org/title/System … ait-online (esp. the blue box on the top)
Online
I'm using netctl. I'm confused by @seth's comment. I understand that we want the nfs automount after the network is up. Do I still need @thorstenhirsch's scripts above?
Last edited by vorlket (2024-01-02 02:54:30)
Offline
I'm using netctl.
First link.
You don't need any custom service, an fstab entry will do: https://wiki.archlinux.org/title/NFS#Mo … /etc/fstab
nb. that the same network-online problems apply (_netdev waits for that target, but the target implementation is wonky)
W/ somewhat unsteady FS I'd personally always recommend to mount them on access: https://wiki.archlinux.org/title/NFS#Mo … th_systemd
You then also don't have to worry about _netdev/network-online, if you try to access the FS w/o a network that's a user error and will always result in a stall or error (soft/hard timeout)
Online
[vorlket@miniserver ~]$ ls -l sharedfolder/
ls: cannot access 'sharedfolder/': No such deviceserver:
sudo pacman -S nfs-utils
mkdir ~/sharedfolder
chmod 777 ~/sharedfolder
sudo vi /etc/exports:
/home/vorlket/sharedfolder miniserver(rw,sync)
sudo exportfs -arv
sudo systemctl start nfs-server.service
sudo systemctl enable nfs-server.service
sudo vi /etc/nfs.conf:
[nfsd]
host=192.168.1.2
sudo systemctl restart nfs-server.service
sudo vi /etc/iptables/iptables.rules:
-A INPUT -p tcp -m tcp --dport 111 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 2049 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 20048 -j ACCEPT
-A INPUT -p udp -m udp --dport 111 -j ACCEPT
-A INPUT -p udp -m udp --dport 2049 -j ACCEPT
-A INPUT -p udp -m udp --dport 20048 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 32765 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 32803 -j ACCEPT
-A INPUT -p udp -m udp --dport 32765 -j ACCEPT
-A INPUT -p udp -m udp --dport 32803 -j ACCEPT
sudo systemctl start iptables.service
sudo systemctl enable iptables.serviceminiserver:
sudo pacman -S nfs-utils
mkdir ~/sharedfolder
chmod 777 ~/sharedfolder
sudo vi /etc/fstab:
server:/home/vorlket/sharedfolder /home/vorlket/sharedfolder nfs _ne
tdev,noauto,x-systemd.automount,x-systemd.mount-timeout=10,timeo=14,x-systemd.id
le-timeout=1min 0 0
sudo systemctl daemon-reload
sudo systemctl restart remote-fs.targetLast edited by vorlket (2024-01-03 04:59:01)
Offline
There's a stray newline in your fstab - or you copypasted that out of a linebreaking editor.
Remove the _netdev stance and manually check whether you can reach/mount the exports *at all*, https://wiki.archlinux.org/title/NFS#Client
Online
I removed the following on server and it works:
sudo vi /etc/nfs.conf:
[nfsd]
host=192.168.1.2
sudo vi /etc/iptables/iptables.rules:
-A INPUT -p tcp -m tcp --dport 111 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 2049 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 20048 -j ACCEPT
-A INPUT -p udp -m udp --dport 111 -j ACCEPT
-A INPUT -p udp -m udp --dport 2049 -j ACCEPT
-A INPUT -p udp -m udp --dport 20048 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 32765 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 32803 -j ACCEPT
-A INPUT -p udp -m udp --dport 32765 -j ACCEPT
-A INPUT -p udp -m udp --dport 32803 -j ACCEPTOffline
Pages: 1