LFCS 3.2: The virtual file system
Mount options, remounting in place, bind mounts, tmpfs, and a safer /tmp.
Before you start
The lab adds a 512 MiB spare disk, /dev/loop40, that already holds an ext4
filesystem. It comes back at every boot, before filesystems are mounted, so
an /etc/fstab line for it keeps working. It also creates user alice
(password Lab-Pass-1) and a directory /srv/shared with a file in it.
Tasks
- Mount the filesystem on
/dev/loop40at/data, read-only and withnoexec. Then make it read-write without unmounting it. Make/datamount read-write withnoexecat every boot too. - Make
/srv/sharedalso appear as/home/alice/sharedat every boot. - Create a 256 MiB tmpfs at
/scratch, writable by everyone with the sticky bit, present after every boot. - Make
/tmprefuse to run programs and honor no set-user-ID bits, at every boot. If/tmpisn't a separate mount (findmnt /tmpshows nothing), add a line such astmpfs /tmp tmpfs defaults,noexec,nosuid,nodev,mode=1777 0 0.
Check your /etc/fstab before you reboot: a bad line can stop the boot.
Hints
mount -o ro,noexec,mount -o remount,rw,findmnt -no OPTIONS /data.blkidgives the UUID for/etc/fstab.mount --bind; in/etc/fstabthe type isnoneand the optionbind.mount -t tmpfs -o size=...,mode=...;df -h /scratch,ls -ld /scratch.findmnt --verify,systemctl daemon-reload,mount -a.