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.

  1. Restart your computer.
  2. Access the GRUB menu during boot. Depending on your system:
    • Hold down the Shift key (for BIOS systems).
    • Press Esc (for UEFI systems).
  3. In the GRUB menu, select:
    • Advanced Options > Recovery Mode.
GRUB menu screenshot

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.

fsck repair screenshot

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.

  1. Boot from the live USB/CD.
  2. Open a terminal.
  3. 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
  4. Run fsck on /dev/sda6: sudo fsck /dev/sda6
  5. Follow the prompts to repair the filesystem.
  6. Reboot the system.

Troubleshooting

Common Errors

  1. Filesystem Cannot Be Repaired:
    • This may indicate severe corruption or hardware issues. Check the disk health using smartctl (part of smartmontools): sudo apt install smartmontools sudo smartctl -a /dev/sda
  2. Bad Superblock:
    • If fsck reports a bad superblock, try using an alternate superblock: fsck -b 32768 /dev/sda6

Preventing Future Filesystem Errors

  1. Regular Backups:
    • Use tools like rsync or cloud services to back up your data.
  2. Monitor Disk Health:
    • Periodically check your disk using smartctl.
  3. 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.

Fixing Filesystem Errors: Handling ‘fsck exited with status code 4’

Post navigation