A team wants a filesystem mounted at `/tmp` that clears on reboot and can't run binaries. How do you set it up?
IntermediateScenarioStorage, disks and filesystems
Answer
Situation read → tmpfs with hardened mount options.
What I'd do →
sudo systemctl enable tmp.mounton distros that ship it, or add to fstab:
tmpfs /tmp tmpfs defaults,size=2G,nodev,nosuid,noexec,mode=1777 0 0
sudo mount -o remount /tmp(or reboot) and verify withfindmnt /tmp.- Test installers and tools that unpack to
/tmpand run from there; setTMPDIRfor them ifnoexecbreaks them.
Why → noexec blocks a common attacker trick of dropping binaries in /tmp; 1777 keeps the sticky bit so users can't delete each other's files.
Interview tip → Mention the sticky bit by name.
More on Storage, disks and filesystems
You get paged at 3 AM: the root filesystem on a production server is at 98% and climbing. Walk through your response.BeginnerA new 200 GB EBS volume is attached to an EC2 instance. How do you make it usable and persistent across reboots?BeginnerThe `/var` LVM logical volume is nearly full and there is free space in the volume group. How do you grow it online?BeginnerThe volume group has no free space. You've been given a new disk. How do you add it to grow `/var`?IntermediateA cloud VM's root disk was enlarged from 30 GB to 80 GB in the console, but `df` still shows 30 GB. What do you do?BeginnerYou need to move a busy MySQL data directory from the root disk to a new, faster volume. Plan it.Intermediate