- Linux Training
- Desktop Tutorials
- Server Tutorials
|Linux Commands - Troubleshooting|
fsck - Recovering from a System Crash
At some point your system will crash and you need to perform a manual repair of your file system. A typical situation would be power loss while you are working on the system. You reboot and the system stops and indicates you must perform a manual repair of the system using fsck.
Hers is a sample of the text you may see:
O.K. i t looks like a nightmare...but it is not so bad if you do a few basic things. Your file system is installed on a partition on the hard drive and it is that partition that you need to run the manual check on. If you have it on hard drive and it is divided into two partitions, one for swap and one for the file system, then it will look like this:
The dev part of this signifies that it is an attached device. Notice that hd stands for hard drive and the a means that it is the first hard drive or Master on the primary disk controller. Now one of these will be swap space and the other will be your distribution. So you need to run the program fsck on your file system partition.
This command would start a manual scan of the partition hda1. If you do this and it says it cannot use fsck on swap file then do it on the second one:
That is all you have to do most of the time as it will be automatically fixed.
The actual program that does the fixing is fsck which tries to repair the Linux file system.
Often times the fsck will give an exit code which will tell you what has happened when it is done:
0 No errors
You could also use fsck to repair a mount point like /usr
When you are done what you will need to do is reboot the machine at the command prompt type:
When the machine reboots it should be OK. If it is not OK...well I hope you have a backup.