How to unmount stale NFS share

Unmount not accessible NFS share that still has open files.

There is a NFS share mounted on /media/nfs.

$ mount -t nfs4
192.168.88.106:/mnt/disk on /media/nfs type nfs4 (rw,relatime,vers=4.2,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.0.2.15,local_lock=none,addr=192.168.88.106)

It cannot be unmounted.

$ sudo umount /media/nfs 
umount.nfs4: /media/nfs: device is busy

Using force doesn't help.

$ sudo umount --force /media/nfs 
umount.nfs4: /media/nfs: device is busy

The solution is to use lazy unmount.

$ sudo umount --lazy /media/nfs 

NFS share was detached from the file hierarchy and all references to it will be cleaned up as soon as it is not busy anymore.

$ mount -t nfs4
$

This is for emergency use only.