Secure Boot UEFI and tmpfs 2.0 together harden a Linux system against boot-time malware and ensure sensitive data lives only in RAM, not on disk. Secure Boot verifies signed bootloaders and kernels; tmpfs 2.0 (a modern RAM-backed filesystem) replaces persistent temporary storage for improved privacy and performance. This setup requires a UEFI firmware that supports Secure Boot, a Linux distribution with kernel 5.15+ (to include tmpfs 2.0), and administrator access. No extra hardware is needed, but a backup of critical data is strongly recommended before proceeding.
What You'll Need
- A UEFI-based computer (most systems from 2012 onward); confirm in BIOS/UEFI settings or via
efibootmgr -von Linux - Linux kernel version 5.15 or newer (check with
uname -r); distributions like Ubuntu 22.04 LTS, Fedora 36+, or Arch Linux include this - UEFI Secure Boot support enabled in firmware (verify in BIOS/UEFI menu under Security or Boot options)
- Root (sudo) access on the target system
- Optional: A USB flash drive with a signed bootable Linux installer (for recovery if Secure Boot blocks a new kernel)
Step-by-Step
- Verify UEFI Secure Boot readiness: Boot into your Linux system and run
mokutil --sb-state. If Secure Boot is active, you'll seeSecureBoot enabled. If not, reboot and enter UEFI setup (usually by pressing F2, F10, or Del during boot), navigate to the Security or Boot tab, and enable Secure Boot. Save and exit. Restart and re-run the command to confirm. - Ensure kernel and bootloader are signed: Most major distros ship with signed components. On Ubuntu/Fedora, verify with
dpkg -l | grep linux-image(Ubuntu) orrpm -qa | grep kernel(Fedora). Check that your kernel version is ≥5.15. Runefibootmgr -vto confirm theshimbootloader (e.g.,shim-signedon Ubuntu) is used. If not, reinstall the signed kernel via your package manager:sudo apt install --reinstall linux-image-generic(Debian/Ubuntu) orsudo dnf reinstall kernel(Fedora). - Configure tmpfs 2.0 mounts: Edit
/etc/fstabto replace traditional/tmpwith a tmpfs 2.0 mount. First, back up the file:sudo cp /etc/fstab /etc/fstab.bak. Then open it withsudo nano /etc/fstab. Add this line:tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=8G 0 0. Adjustsize=8Gto 25–50% of your RAM (e.g.,size=4Gfor 16GB RAM). Save and exit. - Apply the tmpfs mount immediately: Run
sudo mount -ato reload fstab entries. Verify/tmpis now tmpfs withdf -h /tmp; the filesystem type should showtmpfsand size should match your configured value. - Verify Secure Boot integrity: Run
sudo mokutil --list-enrolledto confirm Microsoft and distro keys are enrolled. Then runsudo mokutil --test-key /usr/share/dbus-1/system.d/com.ubuntu.SoftwareProperties.conf(or similar) to test signature validation. For extra confidence, reboot and entermokutil --enroll-hashto manually enroll a hash if needed (rare for standard kernels). - Test tmpfs 2.0 with a write test: Create a file in
/tmpwithecho "test" > /tmp/testfile && cat /tmp/testfile. Then reboot. After restart, confirm/tmp/testfileis gone—tmpfs 2.0 is volatile by design. If it persists, your fstab entry may not be active; recheck thenoautoorx-systemd.automountflags.
Common Mistakes
- Using an unsigned kernel: If you compile a custom kernel without signing it, Secure Boot will block booting. Always use distro-signed kernels or sign your own with MOK (Machine Owner Key).
- Overestimating tmpfs size: Setting
size=16Gon an 8GB RAM system can cause OOM (out-of-memory) crashes. Stick to 25–50% of RAM. - Ignoring /var/tmp: Applications like systemd may write to
/var/tmpinstead of/tmp. To cover this too, addtmpfs /var/tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=2G 0 0to/etc/fstab. - Skipping Secure Boot enrollment: After kernel updates, some distros (e.g., Arch) require re-enrolling the new kernel hash via
mokutil --import. Checkmokutil --enrollment-keyperiodically.
Tips
- For SSD longevity, tmpfs 2.0 reduces write cycles to disk—ideal for logging or cache-heavy apps like Docker.
- Pair Secure Boot with full disk encryption (LUKS) for defense-in-depth: Secure Boot protects the boot chain; LUKS protects data at rest.
- Monitor RAM usage with
watch -n 1 'free -h'while heavy apps run in/tmpto avoid swapping (tmpfs can swap if RAM is exhausted). - Use
systemd-tmpfilesto pre-populate/tmpon boot (e.g., for app configs) by creating/etc/tmpfiles.d/custom.confwith lines likeL /tmp/myapp - - - - /opt/myapp/config.
Troubleshooting
If the system fails to boot after enabling Secure Boot or mounting tmpfs:
- Boot loop or blank screen: Reboot and hold Shift to access GRUB. Select Advanced options, then choose an older, known-good kernel. If it boots, the latest kernel may be unsigned. Reinstall the kernel package and ensure
shimis installed. - Secure Boot error (e.g., "Secure Boot violation"): Enter UEFI setup and temporarily disable Secure Boot to boot. Then re-enable it and run
sudo mokutil --disable-validationfollowed bysudo mokutil --enable-validationto reset the state. Alternatively, reset MOK list withsudo mokutil --reset(this clears enrolled keys—have your password ready). - /tmp not mounting or filling up: Check
df -h /tmpanddu -sh /tmp/*. If disk-backed files persist, your fstab may have a typo (e.g., missingnoautoor wrong mount point). Also verify no process has open file handles to/tmp(usesudo lsof +D /tmp). - tmpfs 2.0 not visible: Ensure your kernel is 5.15+ and
CONFIG_TMPFS_XATTRis enabled (rungrep CONFIG_TMPFS_XATTR /boot/config-$(uname -r)). If disabled, update the kernel or rebuild it with tmpfs 2.0 support.
Frequently Asked Questions
Does tmpfs 2.0 work on swapless systems?
Yes, but if RAM fills up, the kernel will kill processes (OOM killer). Useswappiness=10 in /etc/sysctl.conf to reduce swap reliance while avoiding OOM crashes.
Can I use tmpfs 2.0 with Docker?
Yes—run containers with-v tmpfs:/var/lib/docker/tmp for ephemeral build caches. Secure Boot doesn’t interfere, but ensure Docker’s containerd uses a signed binary (standard in official installs).
Is Secure Boot required for tmpfs 2.0?
No. tmpfs 2.0 is a kernel feature independent of Secure Boot. However, running both provides stronger security: Secure Boot prevents tampering with the kernel that could disable tmpfs protections.Will updating the kernel break Secure Boot?
Possibly. On Ubuntu/Fedora, updates are signed automatically and work out-of-the-box. On Arch or custom kernels, you must re-enroll the new kernel hash usingmokutil --import and reboot to complete enrollment via the MOK manager.
Does tmpfs 2.0 improve boot time?
Indirectly. Since/tmp is RAM-backed, there’s no disk I/O for temp files during boot or runtime. But it doesn’t accelerate the bootloader itself—Secure Boot adds ~1–3 seconds during verification.
How do I clear /tmp on shutdown?
tmpfs 2.0 clears automatically on reboot or power-off. For manual cleanup without rebooting, runsudo rm -rf /tmp/* as root, but ensure no processes are using it first (sudo lsof +D /tmp).