Linux tune2fs Command Cheat Sheet: Safe ext4 Tuning, Error Policies, and Forensic Checks
Last verified: October 11, 2026. Commands reviewed against the tune2fs(8) manual page behavior.
Picture this composite scenario, the kind of thing SOC and sysadmin teams run into. A maintenance window ends, and at 2 a.m. a log-collection server drops into emergency mode on reboot. Nobody touched the application. Someone had regenerated a filesystem UUID "to avoid a clone conflict" and never updated /etc/fstab. Hours later, the same team finds that a database volume has been silently reserving a large slice of its capacity for years.
Both problems come from one small utility: tune2fs. It rarely appears in security write-ups, but it sits at the intersection of Linux server hardening, availability, and evidence preservation. This guide walks through the commands that matter, the traps in common cheat sheets, and how to monitor for misuse.
Table of Contents
- What tune2fs actually does
- Before you change anything
- Read-only inspection commands
- Filesystem check scheduling
- Reserved blocks and capacity
- Error behavior: continue, remount-ro, panic
- Labels and UUIDs
- Features and default mount options
- Timestamps and digital forensics and incident response
- Common cheat sheet mistakes
- Detection and monitoring
- Expert tips
- FAQ
What tune2fs Actually Does
tune2fs adjusts tunable parameters stored in the superblock of ext2, ext3, and ext4 filesystems. It does not work on XFS (use xfs_admin), Btrfs, or NTFS. Running it against the wrong filesystem type simply fails, but running it against the wrong device can still change a volume you did not intend to touch. Many options are safe to apply to a mounted filesystem. Others, such as removing a journal or changing some features, require it to be unmounted and clean.
Before You Change Anything
Confirm the filesystem type and the device name. Device names like /dev/sda1 can shift between boots, so verify every time.
lsblk -f
sudo blkid /dev/sda1
findmnt /dev/sda1
What it does: lists filesystem types, labels, and UUIDs, and shows whether the device is mounted. Expected output: a line showing ext4 (or ext2/ext3) for your target. If you see xfs or btrfs, stop. This is not the tool for that volume.
Warning: Take a snapshot or backup before changing features, journals, or UUIDs. Superblock changes are small, but mistakes on a production volume can cost hours of recovery.
Read-Only Inspection Commands
Start with the full parameter dump. It changes nothing.
sudo tune2fs -l /dev/sda1
This prints the superblock: UUID, features, mount counts, reserved blocks, error policy, and more. In daily work you usually want only a slice of it. These filtered versions are handy in scripts and audits:
sudo tune2fs -l /dev/sda1 | grep -E 'Filesystem UUID|Filesystem features'
sudo tune2fs -l /dev/sda1 | grep -E 'Mount count|Maximum mount count'
sudo tune2fs -l /dev/sda1 | grep -E 'Last checked|Check interval'
sudo tune2fs -l /dev/sda1 | grep -E 'Reserved block count|Reserved blocks uid|Reserved blocks gid'
sudo tune2fs -l /dev/sda1 | grep -E 'Filesystem state|Errors behavior'
sudo tune2fs -l /dev/sda1 | grep 'Default mount options'
sudo tune2fs -l /dev/sda1 | grep 'Filesystem created'
sudo tune2fs -l /dev/sda1 | grep -E 'Inode count|Free inodes|Inode size'
sudo tune2fs -l /dev/sda1 | grep -E 'Block count|Free blocks|Reserved block count'
Treat these as a baseline. Capture the output into your configuration management or audit records so you can spot drift later.
Filesystem Check Scheduling
Older ext filesystems forced a full e2fsck after a set number of mounts or days. That caused famous "why is boot taking 40 minutes" surprises, so many admins disabled it.
sudo tune2fs -c 10 /dev/sda1
sudo tune2fs -c 50 /dev/sda1
sudo tune2fs -i 30d /dev/sda1
sudo tune2fs -i 7d /dev/sda1
sudo tune2fs -i 6m /dev/sda1
-c sets the maximum mount count before a check. -i sets a time interval; the suffixes are d (days), w (weeks), and m (months). To disable both triggers:
sudo tune2fs -c 0 -i 0 /dev/sda1
sudo tune2fs -c -1 /dev/sda1
According to the manual page, a max mount count of 0 or -1 tells e2fsck to disregard the mount count. Note that the check also depends on the fsck pass field in /etc/fstab and your init system's behavior, so these values are not the whole story.
Trade-off: disabling scheduled checks speeds up boots, but it also removes a routine chance to catch latent corruption. If you disable them, replace them with something deliberate, such as a scheduled maintenance-window check or monitoring of kernel ext4 error messages.
Reserved Blocks and Capacity
By default, ext filesystems reserve a percentage of blocks (commonly 5%) so privileged processes can keep working when the disk fills. On a multi-terabyte data volume, 5% can be a lot of unavailable space.
sudo tune2fs -m 5 /dev/sda1
sudo tune2fs -m 1 /dev/sda1
sudo tune2fs -m 0 /dev/sda1
Use 1% or 0% on pure data volumes (media, backups, archives). Be careful on the root filesystem or any volume that holds /var, logs, or databases. With 0% reserved, a runaway process can fill the disk completely, and logging, authentication, and services may start failing. For a SOC, a full log partition means lost telemetry at the worst moment.
To assign which user or group the reserved blocks belong to:
sudo tune2fs -u 1000 /dev/sda1
sudo tune2fs -g 1000 /dev/sda1
These accept a numeric ID (and also a name). Most systems never need to change them from the default of root.
Error Behavior: Continue, remount-ro, or Panic
The superblock stores what the kernel should do when it detects a filesystem error.
sudo tune2fs -e remount-ro /dev/sda1
sudo tune2fs -e continue /dev/sda1
sudo tune2fs -e panic /dev/sda1
- remount-ro: the filesystem flips to read-only. This is the safest default for most servers, because it limits further damage and preserves the on-disk state for investigation.
- continue: the system keeps writing despite the error. This risks compounding corruption, so use it sparingly.
- panic: the kernel crashes. This sounds extreme, but in high-availability clusters it forces a fast failover instead of a node limping along with a damaged disk. It pairs with the
kernel.panicsysctl for automatic reboot.
One detail worth knowing: an errors= mount option in /etc/fstab generally overrides the superblock default, so check both places when behavior surprises you.
Labels and UUIDs
sudo tune2fs -L MyDrive /dev/sda1
sudo tune2fs -U random /dev/sda1
sudo tune2fs -U time /dev/sda1
sudo tune2fs -U 12345678-1234-1234-1234-123456789abc /dev/sda1
The first command sets a label. The others generate a random UUID, generate a time-based UUID, or set a specific one. Changing a UUID is the classic cause of the 2 a.m. scenario above, because the old UUID may still be referenced in:
/etc/fstaband/etc/crypttab- Bootloader configuration and the initramfs
- Backup tools and monitoring rules keyed on UUID
Warning: do not change the UUID of a mounted filesystem. On filesystems with the metadata_csum feature, tune2fs may require an unmounted, freshly checked volume (it will tell you to run e2fsck -f first) because checksums depend on the UUID. After any change, run sudo blkid, update every reference, and test a reboot in a maintenance window.
Features and Default Mount Options
sudo tune2fs -O quota /dev/sda1
sudo tune2fs -O ^quota /dev/sda1
sudo tune2fs -O has_journal /dev/sda1
sudo tune2fs -o journal_data /dev/sda1
sudo tune2fs -o ^journal_data /dev/sda1
sudo tune2fs -o acl,user_xattr /dev/sda1
-O enables a feature, and a leading ^ disables it. -o sets or clears default mount options stored in the superblock. A few cautions:
- Run feature changes on an unmounted filesystem whenever possible, and check compatibility first. Removing a journal, for example, requires a clean unmounted volume.
quotamay need additional setup before it is useful; consult the manual page for the related quota options.journal_datajournals both data and metadata. It adds integrity guarantees but costs performance, so test it against your workload.aclanduser_xattrmatter for security because they enable fine-grained permissions and extended attributes. Many modern distributions already enable them by default.
Timestamps and Digital Forensics and Incident Response
Superblock fields like "Last checked" and "Filesystem created" are useful context during an investigation, but they are weak evidence on their own. The tool can rewrite the last-check time:
sudo tune2fs -T 20261011000000 /dev/sda1
The format is YYYYMMDD[HH[MM[SS]]] (or now). It only changes the recorded last-check time. The practical lesson for responders: never rely on superblock timestamps alone. Corroborate with the journal, kernel logs, auditd records, and file-level timestamps. If you see an unexplained mismatch between "Last checked" and your fsck logs, treat it as a lead worth examining, not a conclusion. There are benign explanations, so avoid jumping to a verdict.
For incident handling, also remember that a remount-ro policy helps preservation: when the volume goes read-only, you capture the damaged state instead of overwriting it.
Common Cheat Sheet Mistakes
Several "cheat sheets" circulating online pair commands with the wrong description. Check these before you copy anything into a runbook:
| Claim | Reality |
-U random sets the last-mount time | It generates a new UUID. It does not touch mount timestamps. |
-E clear_mmp marks a filesystem clean | It only resets multiple-mount protection (MMP) state. It does not fix or "clean" a filesystem. Use it only when you are sure no other node has it mounted. |
-m 2 sets a minimum check interval | It sets reserved blocks to 2%. Check intervals use -i. |
tune2fs -h prints help | It is not a documented option. Running tune2fs with no valid arguments, or reading man tune2fs, is more reliable. The output may only be a usage message. |
Detection and Monitoring
Because tune2fs can change volume identity, error policy, and features, treat unexpected executions as worth reviewing. A simple auditd watch records every run:
sudo auditctl -w /usr/sbin/tune2fs -p x -k fs_tuning
sudo ausearch -k fs_tuning --start today
The binary may live at /sbin/tune2fs on some distributions, so confirm with command -v tune2fs. To catch the consequences of filesystem trouble, watch kernel messages:
sudo journalctl -k | grep -i ext4
Feed alerts on "EXT4-fs error" and "Remounting filesystem read-only" into your SIEM. These are early indicators of disk failure, and in rare cases of tampering or misconfiguration. Pair that with periodic baseline comparisons of tune2fs -l output so configuration drift stands out.
Expert Tips
- Verify the device every time. Use UUID or label based references, not a remembered
/dev/sdX. - Record before you change. Save
tune2fs -loutput to a ticket so rollback is trivial. - Prefer remount-ro for most servers, and panic only where automated failover exists.
- Do not set reserved blocks to 0% on system or log volumes.
- Align with benchmarks. If you follow CIS Benchmark guidance for Linux, check how it treats mount options and filesystem configuration, and apply those settings through consistent automation rather than one-off commands.
- Test in a lab first with a loopback ext4 image before touching production.
Related Cybersecurity Topics You Should Explore
- Linux blkid Command: 41 Examples Every SOC Analyst Should Know
- Linux fsck Command Guide: Fix Disk Errors Without Data Loss
- Linux mkfs Command Cheat Sheet: Format Disks Safely (2026)
- Linux parted Command Cheat Sheet: Partition Disks Safely
- Linux fdisk Command Cheat Sheet: Partition Disks Safely (2026)
- Linux lsblk Command: Cheat Sheet for Disks, USB & Encryption
- Linux umount Command Cheat Sheet: Safe Unmount Without Data Loss
- Linux Mount Commands Cheat Sheet: Secure Mounts (2026)
- Linux du Command Cheat Sheet: Find Disk Space Hogs Fast
- Linux df Command Cheat Sheet: Fix Full Disk & Missing Logs
- Linux Disk Commands Cheat Sheet: df, du, mount, fsck (2026)
- Linux umask Cheat Sheet: 022 vs 027 vs 077 Explained
FAQ
Is tune2fs safe to run on a mounted filesystem?
Read-only inspection with -l is safe. Some changes, such as labels and reserved blocks, work on a mounted volume. Feature, journal, and UUID changes are best done unmounted.
Does tune2fs work on XFS or Btrfs?
No. It is specific to ext2, ext3, and ext4. Use xfs_admin for XFS and the Btrfs tooling for Btrfs.
What is the default reserved block percentage?
Commonly 5%, though distributions and the mkfs.ext4 options can differ. Check with tune2fs -l.
Will changing the UUID break my system?
It can, if fstab, crypttab, the bootloader, or the initramfs still reference the old one. Update every reference before rebooting.
Is setting errors=panic a good idea?
Only when you have automatic failover or reboot configured. Otherwise remount-ro is usually the safer choice.
Can I trust "Last checked" for forensics?
Not by itself. The value can be changed, so corroborate it with logs and other timestamps.
Conclusion
tune2fs is a small tool with a surprisingly wide blast radius. Used well, it reclaims capacity, shapes how a server behaves when a disk misbehaves, and preserves evidence during failures. Used carelessly from a copied cheat sheet, it can break boots, hide corruption, or fill a log volume. Verify the device, back up first, understand each option's real behavior, and monitor for unexpected use. Do that, and tune2fs becomes a quiet part of your server hardening toolkit instead of a 2 a.m. surprise.
Analysis based on SOC monitoring experience and review of public Linux documentation.
