Recover Linux From Emergency Mode After an fstab Change
Before you begin
- Applies to:Linux hosts running systemd that enter emergency mode after an fstab change.
- Where to start:Open the emergency root shell through the local or out-of-band console. Confirm the root filesystem is healthy and writable before editing.
- What you need:Identify the intended mount point and device. Have a known-good copy of the configuration if one is available.
Guide tools
Troubleshooting Steps
Find the first failed mount
Start hereUse the console and read the current boot journal. Look for a failed mount or device unit that preceded the dependency errors. Check the actual unit name rather than guessing how systemd escaped the mount path.
systemctl --failedjournalctl -b -p warning --no-pager -n 100Compare the fstab entry with the actual device
For this example the mount point is /srv/data. Replace it with the failed target. Compare UUID, filesystem type, and device presence. An expected device that is missing entirely calls for storage or attachment checks. A UUID mismatch alone does not justify changing the entry to the first disk you see.
findmnt --fstab --mountpoint /srv/datalsblk -o NAME,TYPE,FSTYPE,UUID,MOUNTPOINTSfindmnt --mountpoint / -o TARGET,SOURCE,FSTYPE,OPTIONSBack up fstab before editing one line
Check the installed root mount state first. Use the installed emergency shell with a writable, healthy root, or follow your approved rescue workflow if you cannot make it writable safely. The example assumes a root shell on the installed system. Keep the displayed backup path. Correct only the confirmed UUID, type, or mount option.
backup=$(mktemp /etc/fstab.pre-recovery.XXXXXXXX) && cp -p -- /etc/fstab "$backup" && printf 'Saved %s\n' "$backup"After the backup prints its path, run vi /etc/fstab in the same root shell. Use the arrow keys to locate the row whose second field matches the failed mount point from Step 2. Confirm the row against the Step 2 output. Press i to edit the confirmed field, then press Esc, type :wq, and press Enter to save and exit. To discard unsaved edits, press Esc, type :q!, and press Enter.
If vi is unavailable, use an editor already installed in the rescue environment. Compare the saved file with the backup using diff -u -- "$backup" /etc/fstab. Continue only when the diff shows the intended change.
Validate before mounting
Read every verification error or warning and resolve anything affecting the target. findmnt verifies configuration but cannot prove a network endpoint is reachable or a volume is healthy. Run systemctl daemon-reload separately after a successful edit so it regenerates mount units. Skip broad mount testing if the host is serving other workloads.
What you should see Β· The verification command exits successfully and reports no unresolved errors for the repaired entry.
If you see something else Β· If it reports a missing device, wrong filesystem type, or invalid option, return to Step 2 and compare the exact device and mount entry. Leave the mount untested until the issue is resolved.
findmnt --verify --verboseAfter verification passes, run systemctl daemon-reload in the same root shell before testing the mount in Step 5.
Test only the repaired entry
For an unmounted data target that is safe to mount, start its generated mount unit. Verify the expected source before starting any dependent service. If it is already mounted, avoid assuming a successful start reapplied new options. Arrange a maintenance window for a controlled remount.
unit=$(systemd-escape --path --suffix=mount /srv/data) && systemctl start "$unit" && findmnt --mountpoint /srv/data -o TARGET,SOURCE,FSTYPE,OPTIONSBoot normally and verify the dependency
Keep the console available for the next approved boot. Confirm the mount uses the expected source, check failed units again, and verify the application reads and writes in the intended location. If validation fails, restore the recorded backup through the same recovery path, or use a known-good copy if the saved version already contained the original error.
Undo the recovery edit
From the same installed-system emergency root shell, compare the backup printed in Step 3 with the current file. Restore it only if it is the intended configuration. Replace the example path below with the exact backup path, then stop if validation fails.
backup=/etc/fstab.pre-recovery.REPLACE_MEdiff -u -- "$backup" /etc/fstab# Run only after confirming the backup is the intended configuration:cp -p -- "$backup" /etc/fstab && findmnt --verify --verbose && systemctl daemon-reloadDecide What to Do Next
| Finding | Next action |
|---|---|
| Device is absent | Check attachment, storage path, unlock state, or network availability. |
| Only an optional target is unavailable | Review whether nofail is appropriate. Keep explicitly required mounts ordered before dependent services. |
| Mount works but service data looks wrong | Verify the source and check for writes beneath the mount point before changing data. |
References
Your feedback keeps these production procedures accurate and battle-tested.