Click to See Complete Forum and Search --> : HDD checkup


Firestorm
02-01-2006, 09:41 AM
Hi,
I have an old 40GB IDE HDD.
I want to use it in my second PC but first I want to do the following:
1. check if there are broken/blocks
2. format it and create a new partition that covers the whole HDD

The first point is neccessary because infact the HDD partly does not work so I want to mark those broken parts and prevent linux from writing data in those places.

WHO CAN I DO ALL THIS?

Modorf
02-01-2006, 10:33 AM
/sbin/fdisk /dev/hdx --- x == the drive postion on ide bus (primary master, primary slave...)
create partition 1
change partition type for linux or vfat depending on your need
write partition table
quite fdisk
format partition -- /sbin/mkfs.ext3 /dev/hdx1 or any other filesystem type you want
check partion -- /sbin/fsck /hdx1

then you should be good.

Firestorm
02-01-2006, 11:15 AM
Thanks a lot!
I've got only one more question: fsck returned the following:
fsck 1.36 (05-Feb-2005)
e2fsck 1.36 (05-Feb-2005)
/dev/hdc1: clean, 11/368000 files, 19765/734965 blocks

What does that mean?

Besides, when working with fdisk I typed "v" to verificate my new partitioin table and the answer was:
62 unused sectors
What does that mean? Is this good, bad, normal??

bwkaz
02-01-2006, 07:29 PM
If the disk has bad blocks on it now, why do you think that more blocks won't magically go bad in the future?

e2fsck -cc /dev/hdc1 will check the filesystem, then run the badblocks program in a non-destructive mode. badblocks searches for blocks that don't retain information that's written to them, and I think it maps them out of the filesystem (though it might not). Just e2fsck (or fsck) won't check for bad blocks, it'll only check whether the filesystem data that's there is valid.

rdeschene2
02-01-2006, 08:20 PM
As the drive has no data on it now (I assume), it might be worthwhile downloading the drive manufacturer's "disk function test" boot diskette, and using this to check the drive and repair it where possible.

Then to FORCE e2fsck to check the drive, even if it is logged as "clean" use:

e2fsck -ccf /dev/hdxy

where x is the drive identifier: (e.g. primary master is a, primary slave is b, etc.) and y is the partition number
Note that this can take a few hours to run, so don't worry about it if you think it's gone to sleep. For a drive this size, I'd estimate about 4 hours.

bkwaz is quite right on what -cc does (from the man pages):
"-c
This option causes e2fsck to run the badblocks(8) program to find any blocks which are bad on the filesystem, and then marks them as bad by adding them to the bad block inode. If this option is specified twice, then the bad block scan will be done using a non-destructive read-write test."

To help you monitor the drive's health, it would be useful to use SMART (Self-Monitoring, Analysis and Reporting Technology) to get a baseline reading on this drive. The SMART utilities are usually present in the smartmontools package, in RPM-based distros anyways. Here's a link to a very good article on how to interpret the smartctl utility's output. Note that some HD's (my 40GB Samsung for example) don't respond to (e.g.) smartctl -l selftest /dev/hdx properly -- no output.

http://www.linuxjournal.com/article/6983
http://http://www.linux-magazine.com/issue/49/Monitoring_Hard_Disks_with_smartmontools.pdf

SMART utilities are available on the system rescue cd: http://www.sysresccd.org

Rick D.

P.S. I pay particular attention to the output of smartctl --health /dev/hdx and the WHEN_FAILED column outputed by (e.g.) smartctl -a /dev/hdx. All dashes in the WHEN_FAILED column is good.

Firestorm
02-02-2006, 07:06 PM
I did the check with e2fsck:
# e2fsck -ccf /dev/hdc1
e2fsck 1.36 (05-Feb-2005)
Checking for bad blocks (non-destructive read-write test)
Testing with random pattern: done 965
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/hdc1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/hdc1: 11/368000 files (0.0% non-contiguous), 19765/734965 blocks

But what in fact seems strange to is another thing:
fdisk says:
Platte /dev/hdc: 61.4 GByte, 61492838400 Byte
255 Köpfe, 63 Sektoren/Spuren, 7476 Zylinder
Einheiten = Zylinder von 16065 * 512 = 8225280 Bytes

Gerät Boot Start End Blocks Id System
/dev/hdc1 1 7476 60050938+ 83 Linux
that means my partition contains the whole HDD which is - I have to correct myself- even 61GB.

But if mount it and do df-h it says:

Dateisystem Größe Benut Verf Ben% Eingehängt auf
...
/dev/hdc1 2,8G 33M 2,6G 2% /mnt/hdc1
So obviously there is not much of those 61GB left.
Why?
Did fdisk reach one broken block during the partition process and put the partition's end before that block without continueing any further?

bwkaz
02-02-2006, 07:27 PM
Well, I can't read German, so I'm not entirely sure what you're seeing there. However, the partition size and the filesystem size are two different numbers -- a filesystem does not have to fill an entire partition. (Though there's not much point in purposefully making the FS smaller, because I don't know of any utilities that let you store information in the extra space on the partition. But it is still possible.) It may be that you're running into a case where they're set to two different values.

You can use the resize2fs command to resize an ext2 or ext3 filesystem (without resizing the partition). Read its manpage though; I've never had to use it, so I don't know how to.

After the FS is resized, then run the e2fsck again.