Operating System - Linux
1827894 Members
1497 Online
109969 Solutions
New Discussion

Re: check hard disk for buffer I/O errors

 
SOLVED
Go to solution
'chris'
Super Advisor

check hard disk for buffer I/O errors

hi

Howto check a hard disk for buffer I/O errors and fix them using linux, without damaging OS?
6 REPLIES 6
P Muralidhar Kini
Honored Contributor

Re: check hard disk for buffer I/O errors

Hi Chris,

Try using the fdisk command with "-l" option.
This lists the parition tables on the devices that are specified.
Lets see whether the fdisk command is able to read the parition tables properly
from the devices.

fdisk -
http://linux.about.com/od/commands/l/blcmdl8_fdisk.htm

Also, try and check the file systems that are currently present.
Use the fsck command without repair and check if any errors are logged.

fsck-
http://linux.about.com/od/commands/l/blcmdl8_fsck_.htm

Hope this helps.

Regards,
Murali
Let There Be Rock - AC/DC
TwoProc
Honored Contributor
Solution

Re: check hard disk for buffer I/O errors

Well, typically - you wouldn't check a hard driver for buffer I/O errors. A buffer is a chunk of ram, and while there is ram (and a buffer) on the electronics board on a hard drive - if the memory "buffer" (ne' cache) is bad - you chunk the drive and don't look back, nothing to fix here.

If you mean check out the disk hard drive platter(s) to see if there's an I/O write problem, a basic check would be to run data dump (dd) using 1k block size, and just see where the data breaks. However, that's really bad for the OS (you'd definitely crash it).

If you mean to check out the hard drive platter(s) to see if there's an I/O read error, you could use data dump (dd) to read data from the drive in 1k blocks to see if you've got a problem.

For instance, if you hard drive is /dev/sda:
dd if=/dev/sda of=/dev/null bs=1024

this thing will run (a long time) and if you've got place where it can't read, it will tell which block it did it on. However, at the end of the drive, it *will* fail with an error on read, because there's no more blocks to read - which in this case is fine.

If you want to check just individual partitions, instead of the whole drives
- you'd just refer to the partition number, so you'd substitute /dev/sda for /dev/sdan with n for partition number, for example /dev/sda1 (first partition), etc.

Now, if you *do* find a bad block in there, and you've calculated how big the drive is, and you're *not* at the end of the disk... you can run fdisk and format around it (destroying any OS involved in that block). Or, you could use gparted (linux tool) to move the os partitions off that spot by reducing or moving the partition around. However, your mileage will var depending on how bad the drive is behaving with the error. But for my money - you'd be better off just chunking that drive and not fooling with it if you're seeing errors on it.
Drives are cheap now, and there's no reason to fool with bad hardware.

Lastly, keep in mind that if you successfully dd that drive with no errors, but are still seeing things that make you believe that your having hard drive trouble, you may just have soft corruption in the file system(s) that you're using. In which case you could fsck those drives from the command line (fsck /dev/sda1, fsck /dev/sda2, etc) to see if you can fix those soft error issues.
We are the people our parents warned us about --Jimmy Buffett
'chris'
Super Advisor

Re: check hard disk for buffer I/O errors

@TwoProc
Thx a lot for an excelent and very helpfull posting!

I'll try this command:

# dd if=/dev/sda of=/dev/null bs=1024

on my hard disk, but will be not better to write 1k blocks instead of read?
OS is anyway backuped.




Michal Kapalka (mikap)
Honored Contributor

Re: check hard disk for buffer I/O errors

Hi Chris,

# dd if=/dev/sda of=/dev/null bs=1024

on my hard disk, but will be not better to write 1k blocks instead of read?
OS is anyway backuped.

- no because if you write from /dev/null ==> /dev/sda your system will imediately crach because you will overwrite all system data.

- the logic is mostly that if you can't read you will be not able also to write to the damaged block.

mikap
Hakki Aydin Ucar
Honored Contributor

Re: check hard disk for buffer I/O errors

You can also use badblocks : search a device for bad blocks;

# badblocks -s -n /dev/your_drive_type/cXdY
TwoProc
Honored Contributor

Re: check hard disk for buffer I/O errors

Chris,

Yes, writing is a better check, but it will destroy everything on the drive, and you'd be at the point of restoring. If this doesn't bother you, then go ahead.

But, if you're going to do this, don't use /dev/null for input of the dd command, use /dev/zero or /dev/rand (if you have the random package installed) instead.

whole drive:
dd if=/dev/zero of=/dev/sda bs=1024

or per partition
dd if=/dev/zero of=/dev/sda[n] bs=1024
where n is the number of your partition you want to test.

Just understand that the above is absolutely destructive to whatever disk or partition your "testing", and will certainly require a restore or reinstall to get it back.
We are the people our parents warned us about --Jimmy Buffett