Encountering the error message below?
fsck exited with status code 4
The root filesystem on /dev/sdaxx requires a manual fsck
Enter 'help' for a list of built-in commands.
This means that the root filesystem (/dev/sdaxx
in this case) has errors that require manual intervention. Filesystem errors can occur due to sudden power failures, hardware issues, or improper shutdowns. This guide provides detailed steps to resolve this issue with examples and screenshots.
What Does Status Code 4 Mean?
In fsck
, status code 4
indicates:
- Filesystem errors left uncorrected.
This means that fsck
detected errors but did not fix them automatically.
Steps to Fix the Filesystem
1. Reboot into Recovery Mode
To repair the filesystem, you need to access a recovery shell.
- Restart your computer.
- Access the GRUB menu during boot. Depending on your system:
- Hold down the
Shift
key (for BIOS systems). - Press
Esc
(for UEFI systems).
- Hold down the
- In the GRUB menu, select:
- Advanced Options > Recovery Mode.
Once in recovery mode, you will be dropped into a root shell.
2. Remount the Filesystem as Read-Only
Ensure the root filesystem is mounted in read-only mode before running fsck
:
mount -o remount,ro /
To confirm, run:
mount | grep '/ '
You should see output indicating the filesystem is mounted as read-only.
3. Run fsck
to Repair the Filesystem
Use the fsck
command to check and repair errors.
fsck /dev/sda6
Example Output:
fsck from util-linux 2.36.1
e2fsck 1.46.2 (28-Feb-2021)
/dev/sda6: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda6: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda6: 234/128016 files (0.0% non-contiguous), 19876/512000 blocks
When prompted with options to fix errors (e.g., Fix?
or Yes/No
), type y
and press Enter.
4. Repeat fsck
if Necessary
If fsck
reports that the filesystem was modified, run it again:
fsck /dev/sda6
Continue this process until no errors are found.
5. Reboot the System
Once fsck
completes successfully, reboot the system:
reboot
The system should now boot normally.
Alternate Method: Using a Live USB/CD
If you cannot access recovery mode, use a Linux live USB/CD.
- Boot from the live USB/CD.
- Open a terminal.
- Identify the root partition:
sudo fdisk -l
Example output:Device Boot Start End Sectors Size Id Type /dev/sda1 2048 1050623 1048576 512M 83 Linux /dev/sda6 1050624 20971519 19920896 9.5G 83 Linux
- Run
fsck
on/dev/sda6
:sudo fsck /dev/sda6
- Follow the prompts to repair the filesystem.
- Reboot the system.
Troubleshooting
Common Errors
- Filesystem Cannot Be Repaired:
- This may indicate severe corruption or hardware issues. Check the disk health using
smartctl
(part ofsmartmontools
):sudo apt install smartmontools sudo smartctl -a /dev/sda
- This may indicate severe corruption or hardware issues. Check the disk health using
- Bad Superblock:
- If
fsck
reports a bad superblock, try using an alternate superblock:fsck -b 32768 /dev/sda6
- If
Preventing Future Filesystem Errors
- Regular Backups:
- Use tools like
rsync
or cloud services to back up your data.
- Use tools like
- Monitor Disk Health:
- Periodically check your disk using
smartctl
.
- Periodically check your disk using
- Avoid Forced Shutdowns:
- Always shut down the system properly to prevent filesystem corruption.
With these steps, you should be able to resolve filesystem errors and restore your system to normal operation. If problems persist, consider consulting a professional or replacing the affected hardware.