linux poison RSS
linux poison Email

How to check/repair (fsck) filesystem after crash or power-outage

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.

fsck (file system consistency check) is a command used to check filesystem for consistency errors and repair them on Linux filesystems. This tool is important for maintaining data integrity so should be run regularly, especially after an unforeseen reboot (crash, power-outage).

Usage: fsck [-sACVRTNP] [-t fs-optlist] [filesystem] [fs-specific-options]

Filesystem can be either a device's name (e.g. /dev/hda) or its mount point. fsck run with no options will check all devices in /etc/fstab. It might be neccesary to run fsck from single-user mode

Note: You need to be "root" to use any of the below mentioned command

* Take system down to runlevel one: # init 1

* Unmount file system, for example if it is /home (/dev/sda2) file system then type command:
# umount /home OR  # umount /dev/sda2
* Now run fsck on the partition: # fsck /dev/sda2

* Specify the file system type using -t option:  
# fsck -t ext3 /dev/sda2 OR  # fsck.ext3 /dev/sda2
fsck will check the file system and ask which problems should be fixed or corrected. If you don't wanna type y every time then you can use pass -y option to fsck: 
# fsck -y /dev/sda2
Please note if any files are recovered then they are placed in /home/lost+found directory by fsck command.

* Once fsck finished, remount the file system: # mount /home

Read man page of fsck for more information.
Make sure you replace /dev/sda2 with your actual device name.



6 comments:

Anonymous said...

My inodes indicate my SSD is full, when it really isn't. How do I run a complete fsck (Ubuntu 12.04) on the root partition of the SSD, from the install disk?

Wang said...

Thanks for the info.

Found a typo at the end of post:

In "Please not if any files ", "not" should be "note".

Anonymous said...

man i got know fsck command found?

how do i get this command??

thanks

DevOps said...

you need to be "root" user to use this command - fsck

Pontianak Web (@mbahlol) said...

thanks a lot. now i can work again using my lubuntu

Post a Comment

Related Posts with Thumbnails