Link to home
Start Free TrialLog in
Avatar of piratepatrol
piratepatrolFlag for United States of America

asked on

How to Check Disk for Errors in Linux

Hi everyone,

In Windows, I can check a hard disk for errors with a couple of clicks of the mouse.  How is this done in Linux?  I have Fedora Core 2.

Thanks you so much,


Jazon
Avatar of Tim_Utschig
Tim_Utschig

fsck /dev/hda1

Where /dev/hda1 is the partition to check for consistency errors.

You can further check for bad blocks (on an ext2/3 filesystem) with:

   e2fsck -c /dev/hda1

Note this could take a LONG time depending on the size and speed of your disk.
Some file systems automatically handle bad blocks, so you don't have to go checking for them.
For fsck/e2fsck, it is highly recommended that run it in the single user mode with minmium running processes.

As root, do
init -s
to go to single user mode.

Then run
fdisk -l
to see all the partition table
and run fsck against the ext2/ext3 partitions.
Avatar of piratepatrol

ASKER

Heheh!  When I typed fsck /dev/hda2, I got this

WARNING!!!  Running e2fsck on a mounted filesystem may cause SEVERE filesystem damage.

So I aborted.

Before I did this, I tried init -s, but it said invalid option -- s.

hda 2 is the main partition where all my apps are.
SOLUTION
Avatar of Tim_Utschig
Tim_Utschig

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, you guys.  Wow, I was hoping it would be just a couple of mouse clicks like in Windows!  :-)
There's a much easier way to do this:
touch /forcefsck
Pirate, in order to do a proper check of the harddrive(s) in Windows you need to drop to single user (ie set it in motion and reboot) anyway. Windows gives you 1 way to do it while linux gives you several. Your "couple of mouse clicks" you mention wouldn't get you very far. I wanted to post this in defense of Linux as Pirate's follow up comment is fallacious.  :)
For fsck/e2fsck, it is highly recommended that run it in the single user mode with minmium running processes.

As root, do
init -s
to go to single user mode.

Then run
fdisk -l
to see all the partition table
Once you get into single user mode, you may have to remount your partition read-only before fsck'ing it:
mount -o remount,ro /
Comment the external or not needed mount point during the system booting time.
and run fsck against the ext2/ext3 partitions to check the partition.
fsck /dev/hdaX
Hope this will work.

Thanks
Kazi Tariqul Islam
System Administrator
AXIATA (Bangladesh) Limited




You'll also want to check the health of the drive itself, with "smartctl".


smartctl -a /dev/sda
smartctl version 5.37 [i686-suse-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Barracuda 7200.9 family
Device Model:     ST3120814A
Serial Number:    3LS0ABF9
Firmware Version: 2AAA
User Capacity:    120,034,123,776 bytes
ATA Version is:   7
Local Time is:    Fri Oct 16 12:32:49 2009 PDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED


SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   055   038   006    Pre-fail  Always       -       42658921
  3 Spin_Up_Time            0x0003   099   099   000    Pre-fail  Always       -       0
SMART Error Log Version: 1
No Errors Logged