Showing posts with label fsck. Show all posts
Showing posts with label fsck. Show all posts

Wednesday, March 30, 2016

วิธีการตรวจสอบดิสก์หลังจากระบบล้ม หรือ ไฟตก (How to check/repair (fsck) filesystem after crash or power-outage)

          เมื่อเจอปัญหาลีนุกส์ฮาร์ดดิสก์มีปัญหา จากเครื่องดับ หรือไฟตก ลีนุกส์จะปรับซ่อมฮาร์ดดิสก์เอง เมื่อบู๊ตขึ้นมาใหม่

          มาดูคำสั่งที่ใช้ในการสแกนดิสก์ และซ่อมแซมดิสก์

1. ควรบู๊ตเข้า single mode
#init 1

2. umount /home partion หรือ umount partition ที่ต้องการสแกน
#umount /home
or
#umount /dev/sdxx

3.scan disk
#fsck -v -f /dev/sdxx
use -v -f check health disk
#fsck -y /dev/sdxx
use -y  auto fix error

4.scan disk spacial file system
#fsck -t ext3 /dev/sdxx
or
#fsck.ext3 /dev/sdxx


Ref:how-to-checkrepair-fsck-filesystem

linux-tools-to-monitor-disk-partition-usage


check bad sector on linux


ก่อนอื่นต้องเช็ค Disk drive บนเครื่องก่อน มีอะไรบ้าง สำหรับเครื่องที่ใช้รูปแบบดิสก์เป็น LVM ใช้คำสั่งตรวจเช็คดังนี้ check-disk-lvm-on-centos

แล้วใช้คำสั่งต่อไปนี้ ตรวจสอบฮาร์ดดิสก์

badblocks -v /dev/sda2 > bad-block


หลังจากรันคำสั่งเสร็จ ก็รายงานผลออกมาดังภาพด้านล่าง


badblocks -svn /dev/sdd
to have the hard disk controller replace bad blocks by spare blocks.

fsck /dev/sdd  > fix all drive
fsck /dev/sdd1  > fix special drivebadbl
repair disk

e2fsck -cfpv /dev/sda1
The parameters have the following meanings: “c” searches for bad blocks and adds them to the list, “f” forces a check on the file system, “p” repairs anything that can be safely repaired and “v” is verbose mode so you can see the command progress.

Ref: fix haddisk bad sector