Home / Alt manpages / ext4(5)

  • ext4(5)
  • File format
  • linux

Configure and Verify an ext4 Mount Without Guesswork

You will finish with an ext4 filesystem identified by its UUID, mounted with an intentional option set, and checked from the kernel's view. You will also have a reversible /etc/fstab entry if the filesystem should return after a reboot. The examples follow the installed ext4(5) documentation from e2fsprogs 1.47.0 and the Linux 6.8 environment used for these checks.

Allow 15 minutes for an existing data volume. You need a shell, findmnt, blkid, and administrator access for mounting or changing /etc/fstab. Do not use the example device names literally. A wrong device can expose another filesystem or, in a formatting command, destroy it. This guide does not format, resize, or repair anything.

1. Identify the filesystem before touching it

Start with an inventory. This is read-only and does not require elevated privileges:

$ lsblk -o NAME,PATH,SIZE,FSTYPE,LABEL,UUID,MOUNTPOINTS
$ findmnt -t ext4

Use the PATH and UUID columns to distinguish the intended volume. Prefer a UUID in persistent configuration because device names such as /dev/sdb1 can change when storage is added. If the volume is already mounted, inspect the effective options rather than assuming that an fstab line is current:

$ findmnt -no SOURCE,FSTYPE,OPTIONS /path/to/mountpoint
/dev/EXAMPLE1 ext4 rw,relatime

The output will differ. In particular, ro means read-only, while rw means read-write. A mounted filesystem can have options inherited from the superblock, the mount command, or both.

Checkpoint

Write down the exact UUID and the intended mountpoint. If either is uncertain, stop here and resolve the storage mapping first.

2. Inspect ext4's stored defaults and features

For a more detailed view, use tune2fs against the confirmed block device. This reads filesystem metadata; it does not change it:

$ sudo tune2fs -l /dev/EXAMPLE1 | rg 'Filesystem features|Default mount options|Filesystem state|Last checked'
Filesystem features       : has_journal ext_attr resize_inode dir_index filetype extent 64bit metadata_csum
Default mount options     : user_xattr acl
Filesystem state           : clean

The feature list is not a shopping list. For example, 64bit permits more than 2^32 blocks, extent stores file mappings in extent trees, and metadata_csum checks filesystem metadata. Older kernels and older e2fsprogs may not support every feature. Check the machines that must mount the volume before enabling a feature, especially on shared or removable storage.

Do not confuse a feature with a mount option. The quota feature creates quota inodes and enables quotas when mounted; the prjquota mount option requires the project feature and still needs quota utilities to manage limits.

3. Test a temporary mount

Create a dedicated mountpoint and mount the confirmed device. Both commands change live system state, so use an empty directory and expect administrator authentication:

$ sudo mkdir -p /mnt/example
$ sudo mount -t ext4 -o defaults /dev/EXAMPLE1 /mnt/example
$ findmnt -no SOURCE,FSTYPE,OPTIONS /mnt/example
/dev/EXAMPLE1 ext4 rw,relatime

defaults is a mount(8) shorthand for generic defaults. It does not mean every ext4 feature is enabled, and it does not override the filesystem's own defaults. ext4 enables write barriers by default. The ext4-specific data=ordered mode is the normal journalling mode described by the installed documentation: data is written to the main filesystem before its metadata is committed to the journal.

Verify both access and identity, rather than trusting a successful mount alone:

$ findmnt -no SOURCE,FSTYPE,OPTIONS,TARGET /mnt/example
$ sudo sh -c 'touch /mnt/example/.mount-check && rm /mnt/example/.mount-check'
$ sudo umount /mnt/example

The final command is the undo for this temporary mount. If umount reports that the target is busy, leave the shell directory, close programs using the mount, and use sudo fuser -vm /mnt/example to investigate. Do not jump straight to a lazy or forced unmount when data may still be in use.

4. Choose options for a real workload

Keep the option list short. Add a documented reason for each non-default choice:

  • discard issues discard or TRIM commands when blocks are freed. It can suit SSDs and thinly provisioned storage, but the installed ext4(5) page says it is off by default. Confirm that the storage path benefits from it before enabling it.
  • data=journal journals file data as well as metadata and costs more I/O. data=writeback does not preserve data ordering and can expose old data after a crash. Do not select either as a casual performance tweak.
  • commit=SECONDS changes how often journal commits start; the documented default is 5 seconds. A larger value changes loss exposure after a crash, so treat it as a workload decision.
  • noauto_da_alloc removes ext4's compatibility handling for applications that replace files without calling fsync(). Leave the default enabled unless you have tested the application and have a specific reason.

A read-only mount is not automatically a non-writing forensic mount. The Linux kernel documentation says ext4 may replay its journal even with ro. To prevent journal loading, use ro,noload, and understand that skipping recovery after an unclean shutdown can leave inconsistencies. For routine administration, unmount the filesystem cleanly and use the normal mount mode.

5. Add and validate an fstab entry

Only do this after the temporary mount worked. First capture the UUID:

$ sudo blkid -s UUID -o value /dev/EXAMPLE1
01234567-89ab-cdef-0123-456789abcdef

Back up the configuration before editing it. This is a privileged, boot-affecting change:

$ sudo cp -p /etc/fstab /etc/fstab.before-example
$ sudoedit /etc/fstab

Add one line, replacing the UUID and mountpoint. The nofail option prevents a missing removable volume from making the boot depend on it; omit it for a required local filesystem where a failed mount should stop boot progress for attention:

UUID=01234567-89ab-cdef-0123-456789abcdef /srv/example ext4 defaults,nofail 0 2

Create the directory, then ask mount to use the entry without rebooting:

$ sudo mkdir -p /srv/example
$ sudo mount /srv/example
$ findmnt -no SOURCE,FSTYPE,OPTIONS,TARGET /srv/example
/dev/EXAMPLE1 ext4 rw,relatime,nofail /srv/example

If validation fails, undo the configuration change immediately: restore /etc/fstab.before-example with sudo cp -p, or remove only the line you added, then unmount the target if it was mounted. Re-run sudo mount -a after correction; it should return no output and status 0 when all entries succeed. Never reboot to test an unvalidated fstab.

6. Diagnose the common traps

  • Wrong filesystem or UUID: compare blkid and lsblk output again. Do not change the UUID to make a line appear to work.
  • Mountpoint is busy: identify processes with fuser, leave the directory, and stop the dependent service cleanly before unmounting.
  • Unsupported feature: check the kernel and e2fsprogs versions on every machine that needs the volume. An ext4 driver can mount ext2 and ext3 filesystems, but feature support still depends on the kernel version.
  • Unexpected read-only state: inspect dmesg and findmnt. The errors=remount-ro policy can make ext4 remount read-only after an error. Do not force it back to read-write before understanding the error.

Done means

  • The UUID and block device were matched with lsblk and blkid.
  • findmnt shows the intended filesystem, options, and target.
  • Any non-default option has a documented operational reason.
  • The temporary mount was unmounted cleanly, or the validated fstab entry mounts successfully.
  • You have a recovery copy of /etc/fstab if persistent configuration was changed.