Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

unmount unreachable nfs-server

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
peer
Posts: 451
Joined: 2017-03-26 10:14
Has thanked: 9 times
Been thanked: 22 times

unmount unreachable nfs-server

#1 Post by peer »

I use nfs to connect to pc's
client: 192.168.2.20
server: 192.168.2.22

I establish the connection with the mount command on the client:

Code: Select all

sudo mount -t nfs 192.168.2.22:/home/peer /mnt/asus/home
Unmounting goes with:

Code: Select all

sudo umount 192.168.2.22:/home/peer or
sudo umount /mnt/asus/home
This works great when bot pc's are connected but there is a problem when the server is not reachable (turend off). I tried the --force option:

Code: Select all

sudo umount -f 192.168.2.22:/home/peer or
sudo umount -f /mnt/asus/home
This seems to work but the umount command is not completed so the prompt will not return.
I also tried the --lazy option but that gave the same result.

How can I umount the unreachable server properly?

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 7 times
Been thanked: 16 times

Re: unmount unreachable nfs-server

#2 Post by Dai_trying »

If the server is not switched on then I don't see how it could be mounted in the first place, and therefore would not need (or be able) to be unmounted...

peer
Posts: 451
Joined: 2017-03-26 10:14
Has thanked: 9 times
Been thanked: 22 times

Re: unmount unreachable nfs-server

#3 Post by peer »

Sometimes the server is switched off while it is mounted on the client.

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 7 times
Been thanked: 16 times

Re: unmount unreachable nfs-server

#4 Post by Dai_trying »

How is that possible? I mean if the server is physically switched off, what makes you think the client is connected?

CwF
Global Moderator
Global Moderator
Posts: 2719
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 201 times

Re: unmount unreachable nfs-server

#5 Post by CwF »

peer wrote: 2024-02-16 09:21 How can I umount the unreachable server properly?
You don't.
I would look into changing the method. Systemd-mount accepts the same options and gives some easier options. You could eliminate the sudo requirement. --discover and/or automount timeouts should eliminate the issue.

I think systemd-mount can do nfs the same, I haven't tried. This can be on the command line too, no need to create 'units'.

peer
Posts: 451
Joined: 2017-03-26 10:14
Has thanked: 9 times
Been thanked: 22 times

Re: unmount unreachable nfs-server

#6 Post by peer »

Dai_trying wrote: 2024-02-16 19:31 How is that possible? I mean if the server is physically switched off, what makes you think the client is connected?
Both server and client are normal pc's (server-pc and cllient-pc).
The connection is made when both pc's are running (of coarse)
When I shutdown the server-pc the mount-point on the client-pc is still there. And Dolphin (the file-manager) on the client-pc becomes inresponsive because it cannot read the directory on the server-pc .

At this moment I have created a workaround script that prevents the server-pc from shutting down while a nfs-connection exists.

peer
Posts: 451
Joined: 2017-03-26 10:14
Has thanked: 9 times
Been thanked: 22 times

Re: unmount unreachable nfs-server

#7 Post by peer »

CwF wrote: 2024-02-16 20:42
peer wrote: 2024-02-16 09:21 How can I umount the unreachable server properly?
You don't.
I would look into changing the method. Systemd-mount accepts the same options and gives some easier options. You could eliminate the sudo requirement. --discover and/or automount timeouts should eliminate the issue.

I think systemd-mount can do nfs the same, I haven't tried. This can be on the command line too, no need to create 'units'.
That looks promising. I have tried the command 'systemd-mount ---list':

Code: Select all

systemd-mount --list
NODE      PATH                     MODEL                 WWN                TYPE LABEL  UUID                                
/dev/sda1 pci-0000:00:1f.2-ata-1.0 xxxx xxxx xxxx xxxx xxxx
/dev/sdb1 pci-0000:00:1f.2-ata-3.0  xxxx xxxx xxxx xxxx xxxx
/dev/sdb2 pci-0000:00:1f.2-ata-3.0  xxxx xxxx xxxx xxxx xxxx
/dev/sdc1 pci-0000:00:1f.2-ata-6.0  xxxx xxxx xxxx xxxx xxxx
II removed the information: MODEL WMN TYPE LABEL UUID
It shows the partitions on my internal disks. The nfs connection is not shown although it is there.
I think I have to work with units. In a unit I can define a NFS connection. At this moment I do not have knowledge enough to write a unit but I will look into it
Thanks for this tip, CwF

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 7 times
Been thanked: 16 times

Re: unmount unreachable nfs-server

#8 Post by Dai_trying »

peer wrote: 2024-02-17 08:52
Dai_trying wrote: 2024-02-16 19:31 How is that possible? I mean if the server is physically switched off, what makes you think the client is connected?
Both server and client are normal pc's (server-pc and cllient-pc).
This is the same as any client - server connection so doesn't make any difference as far as I am aware, same software and protocols used.
peer wrote:The connection is made when both pc's are running (of coarse)
When I shutdown the server-pc the mount-point on the client-pc is still there. And Dolphin (the file-manager) on the client-pc becomes inresponsive because it cannot read the directory on the server-pc .
The mount point will always be there, if you start your client machine without the server machine switched on I would think you will get the same result.
peer wrote:At this moment I have created a workaround script that prevents the server-pc from shutting down while a nfs-connection exists.
Wouldn't this prevent the server machine from being able to switch off though? I'm not sure I would like that, but if it suits your needs who am I to complain :)

peer
Posts: 451
Joined: 2017-03-26 10:14
Has thanked: 9 times
Been thanked: 22 times

Re: unmount unreachable nfs-server

#9 Post by peer »

Dai_trying wrote: 2024-02-17 10:39
peer wrote:The connection is made when both pc's are running (of coarse)
When I shutdown the server-pc the mount-point on the client-pc is still there. And Dolphin (the file-manager) on the client-pc becomes inresponsive because it cannot read the directory on the server-pc .
The mount point will always be there, if you start your client machine without the server machine switched on I would think you will get the same result.
Yes, the mountpoint is still there (it always is) but dolphin becomes irresponsive because it thinks that de server-pc is still mounted. And umount does not work when the client-pc is not reachable.

peer
Posts: 451
Joined: 2017-03-26 10:14
Has thanked: 9 times
Been thanked: 22 times

Re: unmount unreachable nfs-server

#10 Post by peer »

I have created a unit file /etc/systemd/system/mnt-Asus.mount:

Code: Select all

[Unit]
Description=Asus PC
After=network.target

[Mount]
What=192.168.2.22:/home/peer
Where=/mnt/Asus
Type=nfs
Options=_netdev,auto

[Install]
WantedBy=multi-user.target
I can mount the nfs server with 'systemctl start mnt-Asus.mnt' and umount it with 'systemctl start mnt-Asus.mnt' .

But when I shutdown the server-pc when the nfs connection is present I get the same problem on the client-pc.
The mount exits but the listing of the directory cannot be renewed because the server is unreachable.

But working with systemd-mount does not solve my problem either.

The command 'systemctl status mnt-Asus.mnt' gives the following:

Code: Select all

root@debian:~# systemctl status mnt-Asus.mount
● mnt-Asus.mount - Asus PC
     Loaded: loaded (/etc/systemd/system/mnt-Asus.mount; disabled; preset: enabled)
     Active: active (mounted) since Sat 2024-02-17 15:55:33 CET; 5min ago
      Where: /mnt/Asus
       What: 192.168.2.22:/home/peer
      Tasks: 0 (limit: 19056)
     Memory: 28.0K
        CPU: 6ms
     CGroup: /system.slice/mnt-Asus.mount

Feb 17 15:55:33 debian systemd[1]: Mounting mnt-Asus.mount - Asus PC...
Feb 17 15:55:33 debian systemd[1]: Mounted mnt-Asus.mount - Asus PC.
This is when the client-pc and the server-pc are connected. This good
When I execute the command 'systemctl status mnt-Asus.mnt' after I shutdown the server-pc I get the exact same results.
The server-pc is mounted but cannot be reached!!

steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1418
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 80 times
Been thanked: 191 times

Re: unmount unreachable nfs-server

#11 Post by steve_v »

NFS isn't really designed to handle this scenario, as it caters more to serving things like home directories (or even the whole system, i.e. diskless clients) over the network than casual file access. In those situations you need the client to simply wait for the server to come back, else you loose data.

Things that may help, in no particular order:
Using systemd mounts or autofs, such that the client unmounts the share when idle.
Using the soft and intr options when mounting the share, possibly also setting a timeout.
Unmounting with --force and/or --lazy (though this is a somewhat dirty solution wrt file integrity).
And perhaps most obviously, simply not shutting the server down when there are active clients... which is traditionally how such setups would work.
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

peer
Posts: 451
Joined: 2017-03-26 10:14
Has thanked: 9 times
Been thanked: 22 times

Re: unmount unreachable nfs-server

#12 Post by peer »

I think I found a solution. I added the line 'Forceunmount=true' to the unit file:

Code: Select all

[Unit]
Description=Asus PC
After=network.target

[Mount]
What=192.168.2.22:/home/peer
Where=/mnt/Asus
Type=nfs
Options=_netdev,auto
Forceunmount=true

[Install]
WantedBy=multi-user.target
Now I can unmount the server even when the serve is not reachable.
I'll try it a few times to see if it really works..

Post Reply