|
Editor’s Note: Tip Top Tips is a semi-monthly column in The PCLinuxOS Magazine. Periodically, we will feature – and possibly even expand upon – one tip from the PCLinuxOS forum. The magazine will not accept independent tip submissions specifically intended for inclusion in the Tip Top Tips column. Rather, if you have a tip, share it in the PCLinuxOS forum’s “Tips & Tricks” section. Occasionally, we may run a “tip” posted elsewhere in the PCLinuxOS forum. Either way, share your tip in the forum, and it just may be selected for publication in The PCLinuxOS Magazine.
This month’s tip is from Cúig.
The difficulty in unmounting NFS shares in Dolphin has been bugging me for more than a year now. I had many failures trying to make it easy for me.
The difficulty is that the mounts, via Dolphin (and I expect other file managers), are done in kernel space and not user space, and the user is not granted permission to unmount those mounts. So to unmount the share, root permissions are required.
I am presently testing an alternative, called autofs, which automounts a share when accessed, and unmounts it again after a time specified in the config files. The user is still unable to unmount a share for the same reasons as above, but hopefully this method will suffice as a sort of 'halfway house' as the timeout can be specified.
Most applications will trigger the automount. I have tried Synaptic and Rsync and they worked. But of course, I have no idea if some other applications might be problematic.

Image by OpenClipart-Vectors from Pixabay
How it works
The setup details are below.
After setup, I click on a shortcut in the Places panel of Dolphin to automount and access the share.
If there is no access or viewing of the share (Dolphin closed) it will auto unmount after the specified time.
The mount and access appears to be visibly faster than before when I was using fstab entries.
This is my first attempt to use autofs/automount, so this is not a recommendation or anything other than an information post of what I have done. I have no idea how it will work out in the long term.
That said, here is a listing of what I did.
Note that the majority of the steps require root privileges.
Setting Up NFS Shares with autofs
1. Install Required Packages
install autofs and nfs-utils-clients
2. Create the Base Directory (use whatever suits your use case - I used /media, but it could just as easily be your home)
mkdir -p /media/nfs
chown root:root /media/nfs
chmod 755 /media/nfs
3. Edit /etc/autofs/auto.master by adding this line:
/media/nfs /etc/autofs/auto.nfs --timeout=60
4. Create /etc/autofs/auto.nfs
mkdir -p /etc/autofs/auto.nfs
Add one line per share to this file, using this format. Be sure to do the substitutions.
<sharename> -fstype=nfs,rw,soft,intr,noatime <server_ip>:/<export_path>
Example Only:
ShareDisk3 -fstype=nfs,rw,soft,intr,noatime 192.168.1.100:/media/Disk3
5. Restart autofs
/etc/init.d/autofs restart
6. Access Shares
First access using Dolphin:
Access /media/nfs and manually type the share name in Dolphin's location bar so it shows:
/media/nfs/ShareDisk3
For Subsequent access:
Drag the mounted folder from the location bar to Dolphin's Places panel for one-click access.
Avoid Static Mounts in /etc/fstab for the Same Paths:
If you use autofs for a mount point, comment out or remove any static mount for the same path in /etc/fstab to prevent conflicts.
Always restart the autofs service after editing configuration files to apply changes.
The above is how I did it, and it is working for me, but that is not to say it cannot be improved by someone who knows what they are doing!
|