Does e2fsck indicate which blocks are bad on your hard drive???
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Does e2fsck indicate which blocks are bad on your hard drive???
HI!!
I recently bought a new HDD and I wanted to test it in order to see if it had some bad sectors. After some google search (I am a Linux newbie :P) I found out that the best option would be using e2fsck.
I ran the following command:
e2fsck -c -c /dev/hdc3
and apparently there were no errors during the process. But does actually e2fsck (with the parameters I used) tell you which blocks are bad, or it fixes the problem automatically without telling you anything???
I need to know this, because I can still change my hard drive in the shop and I want to be sure to have a drive with no errors on it.
I'm not absolutely positive about e2fsck, but I do know that the double -c option on mkfs will invoke the badblocks program prior to format. If you don't mind partitioning and formating again, I would run badblocks manually.
badblocks /dev/hda -wvs
In this example, w causes a destrutive write (in other words, it doesn't bother trying to save data, it just overwrites it.). v stands for verbose; it gives more output. s here causes the current status to be displayed. You could do a check on the individual partition, but if you suspect the drive, I'd test the whole thing.
This command will both do a more thorough type of badblocks scan than the e2fsck man page mentions, and I know it will tell you the block number the instant it finds a bad one (as well as a final count).
On the other hand, if the drive is new, you have almost nothing to worry about. I've seen very few new drives fail, and none of those by bad blocks.
This will take longer to run, but is the non-destructive version (keeps your data). The normal non-destructive test only uses random bits. It's good for a relatively quick test, but this (and the destructive write) are much more thorough.
Make sure the partitions are unmounted first (or partition if just scanning the one).
(I added the parameter -o to save the numbers of the bad blocks in a file)
the program FOUND bad blocks on 2 of my 3 ext3 partitions. The strange thing is that the bad blocks were found always at the end of the partition (example: if the partition has 7164958 blocks, the bad blocks were 7164956 and 7164957).
I have 3 linux (ext3) partitions: / ; /home ; /boot
the errors were found on the large partitions (/boot has only 100MB ; the other two partitions have 7 and 4GB)
Finally, when I used the command "dumpe2fs -b /dev/hdc5" to display the bad blocks of the partition, the program didn't display anything except the version number and so on (So it looked like there were no bad blocks indexed on the partition).
I am not sure if this could be some kind of bug, or it is because of some "feature" of the ext3 filesystem (I am not very familiar with this filesystem) or my hard drive has really bad sectors on it.
Any suggestions??
I am really thinking about formatting the whole hard drive using the good old fdisk (and creating only one NTFS partition) and then see if the drive has some errors on it...If not, I will create then new partitions for linux at the end of the disk and install it again...
Unmount the all partitions from the drive, and then do a scan of the whole drive (/dev/hdc).
If the sectors are going bad, it will probably find them again. If there is a bug (doubtful, but suspicious) They wont be there (or only at the end of the whole disk).
Remember, the "-w" and the "-n -t 0xaa -t 0x55 -t 0xff -t 0x00" are much more thorough than "-n" on it's own (which I think is what -c -c does).
Remember also, if blocks are going out, they might not scan bad each time. This does sound suspicious though.
I couldn't do a scan of the whole drive because of the 2 NTFS partitions I had on it; I couldn't scan the /swap partition either, these filesystems donīt work with e2fsck.
I scanned only my 3 ext3 partitions as I mentioned in my previous post ( / ; /home and /boot)...
The errors were found always at the same place (end of /home and / partition; the /boot partition was ok);
Finally I used Partition-Magic to delete all the partitions from my drive and create a single NTFS partition where I installed Windows XP. During the re-partitioning there were no errors found by partition magic (and it checks the drive for bad sectors) and after installing windows and using "chkdsk /R", in the summary there werenīt any bad sectors either...
I'm not sure if I should be worried about my hard drive or not, but it looks like the only way I can know if it works properly is using it during some period of time (while praying for it :P)...
Uhhh. e2fsck cares about the filesystem. Badblocks does not. It could care less what data is stored there, as long as nothing is in the process of using it. You can scan ANYTHING with badblocks. ext2, ext3, reiserfs, xfs, jfs, fat12, fat16, fat32, ntfs, some weird proprietary format, you name it. All it does is completely ignore the file system format, and read the block device raw. The advantage of e2fsck is that it marks bad sectors for the filesystem to avoid using.
I still think it fishy that the so-called badblocks were all in the same place in each partition. All the same, if it's working properly, I'm sure badblocks is more thorough than chkdsk (I don't even know if chkdsk does a read/write test, or if it just verifies readability. I doubt it does four comprehensive passes).
All the same, Good luck. I hope the drive is fine (and if it isn't, that you learn quickly). I've been having problems with my drive too (though not bad sectors) and am trying to make sure that I didn't do something stupid.
I didn't know that Badblocks ignores the filesystem of the partition... (I thought it doesn't ignore the filesystem because e2fsck doesn't ignore it either and e2fsck actually calls badblocks to perform the test)... I'll give it a try then (as soon as I finish with my exams :P)...
I'll post later (in two weeks more or less...) if my drive is still alive :P
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.