Check ext4 Multiple-Mount Protection Before Mounting
You will finish with a read-only pre-flight check for an ext4 filesystem, a clear interpretation of e2mmpstatus's exit status, and a separate way to print the filesystem's MMP information. This is useful before mounting a volume that may still be attached to another host.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes. You need the e2fsprogs package and an ext4 device, label or UUID. The examples use e2fsprogs 1.47.0, matching the installed e2mmpstatus manpage. The normal check reads filesystem metadata; it does not mount, unmount, repair or enable MMP.
1. Confirm the installed command
Start with ordinary, read-only checks. No elevated privilege is required for the command lookup or package query, although reading a block device may be restricted by your host's device permissions:
$ command -v e2mmpstatus
/usr/sbin/e2mmpstatus
$ dpkg-query -W -f='${Package} ${Version}\n' e2fsprogs
e2fsprogs 1.47.0-2.4~exp1ubuntu4.1
The exact package revision will differ across distributions. The important checkpoint is that the binary comes from the expected package and that its manpage documents the same interface:
$ man e2mmpstatus
The documented syntax is e2mmpstatus [-i] <filesystem>. The filesystem argument is not a directory. Use a block device such as /dev/sdb2, or an ext4 identifier in the form UUID=... or LABEL=....
2. Identify the exact filesystem
Find the candidate device and its identifiers before running the check. This is an ordinary inventory step, but pause if the output identifies a mounted production filesystem or a device belonging to a different host:
$ lsblk -o NAME,TYPE,FSTYPE,LABEL,UUID,MOUNTPOINTS
$ findmnt --fstab --evaluate --types ext4
Replace /dev/EXAMPLE below with the exact ext4 device, label or UUID you intend to assess:
$ filesystem='/dev/EXAMPLE'
$ printf 'checking: %s\n' "$filesystem"
checking: /dev/EXAMPLE
Do not guess from a partition number. If the device is a member of a RAID, multipath or volume-management arrangement, establish which device is the filesystem's correct access path before proceeding. The command cannot tell you whether a guessed path represents the storage topology you intended.
3. Run the safety check
Run the command as the account that can read the device:
$ e2mmpstatus "$filesystem"
$ status=$?
$ printf 'e2mmpstatus exit status: %s\n' "$status"
e2mmpstatus exit status: 0
Exit status 0 means the check considers the filesystem safe to mount. Exit status 1 means the MMP block reports that the filesystem is in use on another node, so it is not safe to mount. Exit status 2 means another failure prevented a proper determination. Treat both 1 and 2 as a stop, not as permission to try the mount anyway.
The check may wait while it observes whether the MMP block is being updated. That delay depends on how often another node writes the block. Do not kill a slow check merely because it has not printed a line yet; first confirm that you selected the correct device and that the host is not experiencing an I/O problem.
Checkpoint
Only continue towards a mount when the command returned 0 and you have separately confirmed that the mount operation belongs in your change window.
4. Use the result in a script
For automation, test the numeric status rather than parsing human-readable output. This example reports the documented cases and stops on anything unexpected:
#!/bin/sh
filesystem=${1:?usage: $0 DEVICE-OR-UUID-OR-LABEL}
e2mmpstatus "$filesystem"
status=$?
case "$status" in
0) printf '%s\n' 'MMP check passed: safe to mount' ;;
1) printf '%s\n' 'MMP check failed: filesystem is in use on another node' >&2; exit 1 ;;
2) printf '%s\n' 'MMP check failed: current status could not be detected' >&2; exit 2 ;;
*) printf 'MMP check failed with unexpected status %s\n' "$status" >&2; exit 3 ;;
esac
This wrapper changes no persistent state. Keep the original status visible in logs, because status 1 and status 2 require different investigation. A status 1 calls for checking the other node and any concurrent filesystem activity. A status 2 calls for checking the device path, permissions, readable superblock and storage health.
5. Inspect MMP data when investigating
Use -i when you need the MMP information instead of the safety decision:
$ e2mmpstatus -i "$filesystem"
The output is filesystem-specific, so do not build an operational decision around a hard-coded line or timestamp. Use it to inspect the recorded MMP state alongside the result from the normal check. The option prints information; it does not make an unsafe filesystem safe and does not clear the MMP block.
Reading a real block device can require elevated privileges. If the command reports permission denied, rerun the same read-only command with the minimum privilege allowed by your system policy:
$ sudo e2mmpstatus "$filesystem"
$ printf 'exit status: %s\n' "$?"
sudo is not a repair step. Do not use it to bypass a status of 1, and do not write to the device with a hex editor or filesystem utility just to make the check pass.
6. Handle failures without damaging the volume
There are three common traps. First, a directory path is not a filesystem argument, even if it is the mountpoint. Supply the underlying device or its UUID= or LABEL= reference. Second, a non-zero result is not a prompt to force a mount: MMP exists to prevent concurrent modification. Third, a read failure is not evidence that the volume is unused. Preserve the conservative result until the storage path and filesystem can be checked safely.
The documented failure conditions include a running e2fsck, use by another node, and an MMP block that is corrupt or unreadable. If you need filesystem repair, schedule it separately, make sure the filesystem is unmounted everywhere, and follow your normal backup and recovery procedure. Do not run e2fsck against a mounted filesystem just to resolve this check.
Nothing in this guide changes state, so there is no undo command. If you stopped after a failed check, leave the volume unmounted and record the exact device and exit status for the person responsible for the storage system.
Done means
- You confirmed the installed e2fsprogs version and the documented
e2mmpstatussyntax. - You identified the intended ext4 device, UUID or label without guessing.
- The normal check returned 0 before treating the filesystem as mountable.
- Status 1 and status 2 are treated as separate stop conditions.
- You know that
-ireports MMP information and does not repair or clear it. - No mount, unmount, filesystem repair or device write was performed by these examples.