Friday, September 14, 2012

How To repair file system after unclean shutdown

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 not 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.

2 comments:

  1. الطيب تعتبر الشركة الرسمية و الرئيسية لتنظيف المنازل حيث اننا نقوم بتنظيف المنازل بافضل معدات التنظيف فنحن شركة تنظيف منازل بالرياض احد العملاء قد نادي شركة الطيب باستغاثة و قد قال انكم الشركة الوحيدة التي اثق فيها بدرجة كبيرة للغاية فنحن شركة الطيب الاولي في خدمات التنظيف

    ReplyDelete

  2. كما اننا نقدم اليكم افضل الخدمات المنزلية التي لا يمكن ان نستغني عنها فنحن افضل شركة تنظيف بيوت بالرياض و ايضا نقوم بتنظيف الشقق بافضل العمالة الفلبينية المتدربة علي اعلي مستوي نحن شركة الطيب افضل شركة تنظيف شقق بالرياض نقوم بتنظيف الشقق بافضل الطرق الجديدة عزيزي العميل نحن نقدم لكم خدمة تنظيف المنازل الموجودة في الرياض عليكم ان تثقوا في شركتن افضل شركة تنظيف مجالس بالرياض

    ReplyDelete