“Fsck exited with status code 4” in Astra Linux (or any Linux system) indicates that the fsck (file system check) utility encountered a problem while checking the file system and was unable to fix it automatically. A status code of 4 specifically means: “File system errors left uncorrected.”
This error usually arises during boot if the file system has been flagged as needing a check due to a previous unclean shutdown, errors detected during normal operation, or intentional flagging by the system.
Here’s a breakdown of the problem and how to address it:
Understanding the Problem:
- File System Corruption: The file system likely has some inconsistencies or errors that need to be repaired. These errors can range from minor issues like incorrect file timestamps to more serious problems like corrupted inodes or directory structures. Automatic Repair Failed: The fsck utility attempted to automatically repair the errors but was unable to resolve all of them. This often happens when the errors are too complex or require manual intervention. Boot Process Interruption: The system is halting the boot process because it cannot reliably use the potentially corrupted file system. Continuing to boot without resolving the errors could lead to further data corruption or instability.
Troubleshooting Steps:
Boot into Recovery Mode (Recommended):
- Reboot your Astra Linux system. During the boot process, before the OS loads, you should see a GRUB menu (the bootloader). If you don’t see the menu, hold down the Shift key during boot (on some systems, the Esc key or another function key). In the GRUB menu, select “Advanced options for Astra Linux” (or similar). Choose a recovery mode kernel (it will have “recovery mode” in the name). Do Not select a normal kernel entry.
Recovery mode provides a minimal environment with root access, allowing you to perform file system checks and repairs. It often remounts the root filesystem read-only initially, so you’ll need to remount it read-write.
Remount the Root Filesystem in Read-Write Mode (if necessary):
Recovery mode might mount the root file system (/) in read-only mode. You need to remount it in read-write mode to make changes. To determine if it’s read-only, you can try to create a file: touch /testfile. If you get a “Read-only file system” error, proceed.
Mount -o remount, rw /
This command will remount the root file system in read-write mode.
Identify the Problematic Partition:
The error message “Fsck exited with status code 4” usually appears along with information about which partition is causing the issue. Look for the device name (e. g., /dev/sda1, /dev/mapper/vg0-root) in the console output before the error message. If you didn’t see it, you can try to identify the root partition using the mount command:
Mount | grep "on / type"
This will list the mounted file systems, and you should be able to identify the root partition (the one mounted on /).
Run Fsck Manually:
Now that you know the problematic partition, run fsck manually on it. It’s extremely important to unmount the partition before running Fsck! However, you Cannot unmount the root filesystem while the system is running from it. This is why you need to boot into recovery mode.
Fsck -y /dev/sda1 # Replace /dev/sda1 with the actual partition
- -y (or -a): This option tells fsck to automatically answer “yes” to all questions and attempt to fix any errors it finds. Use this option with caution, as it may make changes that you don’t understand. If you omit this option, fsck will prompt you for confirmation before fixing each error. This gives you more control but requires you to understand the nature of the errors and the potential consequences of fixing them. Do NOT run fsck on a mounted filesystem: Running fsck on a mounted filesystem can cause serious data corruption. Make sure the filesystem is unmounted first. In this case (recovery mode), you are Not unmounting because you are running from a minimal environment and the checks are being performed on the root partition. If fsck — y doesn’t resolve the issue, try running fsck without the -y option to examine the errors and decide how to proceed.
If you’re dealing with an Ext4 filesystem (the most common in modern Linux distributions), you can be more specific:
Fsck. ext4 — y /dev/sda1
Examine the Output of Fsck:
Pay close attention to the output of fsck. It will tell you what errors it found and what actions it took to fix them. If fsck reports that it was unable to fix certain errors, it’s important to investigate further.
Reboot the System:
After fsck completes, reboot your system:
Reboot
Hopefully, the system will now boot normally.
If the Problem Persists (More Advanced Solutions):
If the system still fails to boot after running fsck, the file system damage may be too severe to be repaired automatically. Here are some more advanced troubleshooting steps:
- Try a different Fsck command with more aggressive options (use with extreme caution):
- fsck — p — f /dev/sda1: Attempts to automatically repair the file system and forces a check even if it appears clean.
Check SMART Status of the Hard Drive: The hard drive itself may be failing. Use the smartctl utility (part of the smartmontools package) to check the SMART status of the drive. This can give you an indication of whether the drive is experiencing hardware problems.
O sudo apt install smartmontools
O sudo smartctl — a /dev/sda
Look for any errors or warnings in the output. If the SMART status indicates that the drive is failing, you should replace it as soon as possible.
- Data Recovery Tools: If the file system is severely damaged, you may need to resort to data recovery tools like TestDisk or PhotoRec. These tools can scan the disk for lost files and attempt to recover them. However, data recovery is a complex process, and there’s no guarantee that you’ll be able to recover all of your data. It’s best to consult with a professional data recovery service in severe cases. Reinstall the Operating System: In the worst-case scenario, you may need to reinstall the operating system. This should be considered a last resort, as it will erase all data on the hard drive. Make sure to back up any important data before reinstalling.
Important Considerations:
- Backup Your Data Regularly: The best way to prevent data loss from file system corruption is to have a regular backup strategy. Uninterruptible Power Supply (UPS): Use a UPS to protect your system from power outages, which can cause file system corruption. Safe Shutdown Procedures: Always shut down your system properly through the graphical interface or by using the shutdown or reboot commands. Avoid simply turning off the power. Disk Errors: Pay attention to any warnings or error messages related to disk errors. Address these issues promptly to prevent further damage. Consider the age and health of your storage device: Older hard drives are more prone to failure. If your system is running on an old hard drive, consider replacing it with a newer SSD.
In summary, “Fsck exited with status code 4” indicates that your file system has errors that need to be corrected. Booting into recovery mode, manually running Fsck, and carefully examining the output are the first steps to resolving this issue. If the problem persists, you may need to resort to more advanced troubleshooting techniques or consider data recovery options.