1.8 KiB
1.8 KiB
LFCS 3.6: Filesystem automounters
Mounting NFS shares and home directories on demand with autofs, idle timeouts, and systemd's own automounting.
Before you start
The lab adds a second machine, nfs1 (10.99.0.2), running an NFS server
that exports to the lab network 10.99.0.0/24:
nfs1:/srv/share, with a filehello.txtin it;nfs1:/export/home, holding home directories foraliceandbob(/export/home/aliceand/export/home/bob, each with awelcome.txt).
nfs1 shares this VM's files, so you can see the exported directories
here too, but mount them from nfs1. The lab creates users alice and
bob (password Lab-Pass-1) with the same UIDs as on the server, and
installs the NFS client tools. It also adds a 256 MiB spare disk,
/dev/loop40, that already holds an ext4 filesystem and comes back at every
boot before filesystems are mounted.
Tasks
- Automount
nfs1:/srv/shareat/mnt/sharewith autofs, using a direct map. - Automount every user's home directory from
nfs1:/export/homeunder/home/remotewith one wildcard line, and make/home/remote/alicealice's home directory. - Make autofs unmount idle shares after 30 seconds, for both maps.
- Without autofs, make the filesystem on
/dev/loop40mount at/dataonly when it's first used, set up in/etc/fstab.
Hints
/etc/auto.master.d/*.autofs(or/etc/auto.master) and map files;systemctl reload autofs;findmnt -t autofs,nfs4;automount -m.*and&in an indirect map;usermod -d;su - alice,pwd. The homes are private and root is squashed on the share, so look inside them as their owner.--timeout=in the master map.x-systemd.automount(andx-systemd.idle-timeout) in/etc/fstab;systemctl daemon-reload;systemctl list-units --type=automount.