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 -v on 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

  1. Verify UEFI Secure Boot readiness: Boot into your Linux system and run mokutil --sb-state. If Secure Boot is active, you'll see SecureBoot 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.
  2. Ensure kernel and bootloader are signed: Most major distros ship with signed components. On Ubuntu/Fedora, verify with dpkg -l | grep linux-image (Ubuntu) or rpm -qa | grep kernel (Fedora). Check that your kernel version is ≥5.15. Run efibootmgr -v to confirm the shim bootloader (e.g., shim-signed on Ubuntu) is used. If not, reinstall the signed kernel via your package manager: sudo apt install --reinstall linux-image-generic (Debian/Ubuntu) or sudo dnf reinstall kernel (Fedora).
  3. Configure tmpfs 2.0 mounts: Edit /etc/fstab to replace traditional /tmp with a tmpfs 2.0 mount. First, back up the file: sudo cp /etc/fstab /etc/fstab.bak. Then open it with sudo nano /etc/fstab. Add this line: tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=8G 0 0. Adjust size=8G to 25–50% of your RAM (e.g., size=4G for 16GB RAM). Save and exit.
  4. Apply the tmpfs mount immediately: Run sudo mount -a to reload fstab entries. Verify /tmp is now tmpfs with df -h /tmp; the filesystem type should show tmpfs and size should match your configured value.
  5. Verify Secure Boot integrity: Run sudo mokutil --list-enrolled to confirm Microsoft and distro keys are enrolled. Then run sudo mokutil --test-key /usr/share/dbus-1/system.d/com.ubuntu.SoftwareProperties.conf (or similar) to test signature validation. For extra confidence, reboot and enter mokutil --enroll-hash to manually enroll a hash if needed (rare for standard kernels).
  6. Test tmpfs 2.0 with a write test: Create a file in /tmp with echo "test" > /tmp/testfile && cat /tmp/testfile. Then reboot. After restart, confirm /tmp/testfile is gone—tmpfs 2.0 is volatile by design. If it persists, your fstab entry may not be active; recheck the noauto or x-systemd.automount flags.

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=16G on 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/tmp instead of /tmp. To cover this too, add tmpfs /var/tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777,size=2G 0 0 to /etc/fstab.
  • Skipping Secure Boot enrollment: After kernel updates, some distros (e.g., Arch) require re-enrolling the new kernel hash via mokutil --import. Check mokutil --enrollment-key periodically.

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 /tmp to avoid swapping (tmpfs can swap if RAM is exhausted).
  • Use systemd-tmpfiles to pre-populate /tmp on boot (e.g., for app configs) by creating /etc/tmpfiles.d/custom.conf with lines like L /tmp/myapp - - - - /opt/myapp/config.

Troubleshooting

If the system fails to boot after enabling Secure Boot or mounting tmpfs:

  1. 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 shim is installed.
  2. 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-validation followed by sudo mokutil --enable-validation to reset the state. Alternatively, reset MOK list with sudo mokutil --reset (this clears enrolled keys—have your password ready).
  3. /tmp not mounting or filling up: Check df -h /tmp and du -sh /tmp/*. If disk-backed files persist, your fstab may have a typo (e.g., missing noauto or wrong mount point). Also verify no process has open file handles to /tmp (use sudo lsof +D /tmp).
  4. tmpfs 2.0 not visible: Ensure your kernel is 5.15+ and CONFIG_TMPFS_XATTR is enabled (run grep 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). Use swappiness=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 using mokutil --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, run sudo rm -rf /tmp/* as root, but ensure no processes are using it first (sudo lsof +D /tmp).