Joomla!

 
  • Increase font size
  • Default font size
  • Decrease font size

fschk

E-mail Print PDF

fschk

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:

 

/dev/hda1 not cleanly unmounted, check forced.

fsck .........54%

inode 1130517 zero dtime ...........Fixed

 

fsck failed. Please repair manually and reboot. Please note that the root file system is currently mounted read-only. To remount it read-write:

 

mount -n -o remount, rw /

 

Control-D will exit from this shell and REBOOT the system.

 

 

 

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:

 

/dev/hda1

/dev/hda2

 

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.

 

fsck /dev/hda1

 

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:

 

fsck /dev/hda2

 

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
1 File system errors corrected
2 System should be rebooted
4 File system errors left uncorrected
8 Operational error
16 Usage or syntax error

 

You could also use fsck to repair a mount point like /usr

fsck /usr

When you are done what you will need to do is reboot the machine at the command prompt type:

init 6

When the machine reboots it should be OK. If it is not OK...well I hope you have a backup.