-
How is a dodgy hard disk viewed in Linux?
Introduction
I have accidentally created a dodgy partition table in a hard disk and like to share the experience with you.
How did it happened?
In an investigation of moving a XP from a primary to a logical partition of anther disk I have partitioned a second Sata 500Gb disk, identified as device sdb in Linux, into 5 partitions each of identically 4936 cylinders large, which is the size of the original Xp.
This was done successfully by employing a booting partition in sdb1, of Fat32, to fire up the XP in sda5.
As a trial I hide the sdb1 and tried to format sdb2 to do the same thing. However instead of using Linux to format the /dev/sdb2 I used a Win98 floppy, obviously didn't think that would make any difference. The Dos version of fdisk identified the specified partition correctly but appeared to have a serious bug because it made the end boundary of sdb2 to the end of the disk, thereby overlapping the Xp logical partition in sdb5. The sdb2 is completely empty inside but the funny thing is that Xp boots normally, as I am using a floppy to fire it up as a temporary measure.
The issue that troubles me is Xp reports the sdb2 having 460+Gb in a 500Gb disk absolutely error free, say in "My Computer" and "Disk management"! This I can live with as I don't have much respect for the M$ systems.
Behaviour of Linux partitioning tools (fdisk, cfdisk, sfdisk, parted & gparted)
It is the behaviour in Linux that I am interested. Here are the reactions of the various partitioning programs.
fdisk reports no irregularity but the error is ovious from the print out
Code:
root@saikee-desktop-1:/home/saikee# fdisk -l /dev/sdb
Disk /dev/sdb: 500.1 GB, 500106780160 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x9e7bdd1a
Device Boot Start End Blocks Id System
/dev/sdb1 1 4936 39648388+ 1c Hidden W95 FAT32 (LBA)
/dev/sdb2 * 1025 60801 480158752+ c W95 FAT32 (LBA)
/dev/sdb3 9873 14808 39648420 83 Linux
/dev/sdb4 14809 19744 39648420 5 Extended
/dev/sdb5 14809 19744 39648388+ 7 HPFS/NTFS
Not only does sdb2's starting cylinder No. 1025 is inside the boundary of sdb1 (from Cylinder 1 to 4936) its finishing cylinder matches the physical end of the hard disk at No 60801cylinder. This is clearly illegal.
The reaction from sfdisk is as follow
Code:
root@saikee-desktop-1:/home/saikee# sfdisk -l /dev/sdb
Disk /dev/sdb: 60801 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sdb1 0+ 4935 4936- 39648388+ 1c Hidden W95 FAT32 (LBA)
end: (c,h,s) expected (1023,254,63) found (1022,254,63)
/dev/sdb2 * 1024 60800 59777 480158752+ c W95 FAT32 (LBA)
start: (c,h,s) expected (1023,254,63) found (1022,0,1)
end: (c,h,s) expected (1023,254,63) found (1022,254,63)
/dev/sdb3 9872 14807 4936 39648420 83 Linux
/dev/sdb4 14808 19743 4936 39648420 5 Extended
/dev/sdb5 14808+ 19743 4936- 39648388+ 7 HPFS/NTFS
It at least points out something is seriously not right.
The cfdisk program, by command "cfdisk /dev/sdb" return this message
Code:
FATAL ERROR: Bad primary partition 1: logical partitions overlap
Press any key to exit cfdisk
This is an accurate diagnosis of the problem.
The other tool that I rarely use is parted which reported the following
Code:
Error: Cannot have overlapping partitions.
The graphic Gnome Partition Editor "gParted" or "Partition Editor" refused to display the partition table and treated the whole disk with unallocated 465.76Gb space. In other word it looked upon sdb as a raw disk.
Discussions of results
I know what you guys have in mind. Yes fdisk is crap and should be ditched. cfdisk, parted and gparted are the right tools to be used. But that is why I wrote this thread.
The important difference to me is that fdisk still display the dodgy partition table while gparted, Parted and cfdisk I can see nothing. Since the disk has other useful, healthy,normal and possibly important or valuable partitions I would respect a partitioning tool that shows me (1) what is exactly wrong with my hard disk and (2) Let me repair it. In this case with fdisk I can issue this command at the terminal
Code:
fdisk /dev/sdb << eof
> d
> 2
> n
> p
>
>
> w
> eof
which produces a healthy sdb disk again. My new sdb2 fits exactly between the partition boundaries of sdb1 and sdb3 as shown below.
Code:
root@saikee-desktop-1:/home/saikee# fdisk -l /dev/sdb
Disk /dev/sdb: 500.1 GB, 500106780160 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x9e7bdd1a
Device Boot Start End Blocks Id System
/dev/sdb1 1 4936 39648388+ 1c Hidden W95 FAT32 (LBA)
/dev/sdb2 4937 9872 39648420 83 Linux
/dev/sdb3 9873 14808 39648420 83 Linux
/dev/sdb4 14809 19744 39648420 5 Extended
/dev/sdb5 14809 19744 39648388+ 7 HPFS/NTFS
Conclusions
If one has a bit of a health problem one would try to get a second opinion from another doctor. It is the same when it comes to the health of the hard disk. Linux has a superb set of partitioning tools which when combined together form a mighty diagnostic team. This is something the proprietary systems like M$ Windoze can never catch up.
It may sounds silly but from my own experience the dodgy partition tables I got from hard disks were invariably from the courtesy of M$ Windoze software.
So remember for a dodgy hard disk the last line of defense is Linux.
Last edited by saikee; 05-25-2009 at 12:24 PM.
-
Great post. Thanks for that.
-
I would like to create hard drive errors on my linux box - so that I can test ... from a hard disk manufacturer that will create bad sectors on a drive?
-
Not sure how you can create your own bad sectors.
A bad sector could be a tiny contimination of a dust particle preventing one or several sectors of a platter not being reliably read or written. The onboard hard disk controller may go through a series of tests before eventually gives up and declares the sectors are no good. This is something quite difficult to replicate I would have thought.
Most bad sectors do not stop but increase the corruption/contimination rapidly until the disk is dead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|