Bad Sector Remapping:

When a hard disk is manufactured, there are areas on the platter that have bad sectors. Considering that on a 2 TB hard disk there are 4 billion sectors, then a few bad sectors is only a tiny proportion of the total number of sectors on the drive.

During the test phases of a hard disk, the platters are scanned at the factory and the bad sectors are mapped out - these are generally called 'Primary Defects'. The primary defects are stored in tables in the firmware zone, or in some cases the ROM of a hard disk.

When you buy a brand new hard disk, you will most likely be completely unaware of these bad sectors and the numbers because they are 'mapped out' using 'translator' algorithms.

Modern hard disks use Logical Block Addressing or LBA, this describes the sector numbering system on the hard disk, and goes in sequence
0,1,2,3,4,5,.....n-1,n (where n is the last sector on the drive.

 

Spare sector pools

All modern hard disk drives have a spare sector pool. This is used when bad sectors develop during the normal life of the hard disk and any newly found bad sectors are 'replaced' with good ones from the spare sector pool. This process is invisible to the user and they will probably never know that anything has changed.

How Bad Sector Mapping Works:

There are at least two methods of bad sector re-mapping (or translation) these are P-List and G-List.

  • P-list are defects found during manufacture and are also know as Primary Defects
  • G-List are defects that develop in normal use of the drive and are known as Grown Defects

There are other defect lists found in modern drives but the principles are similar. For example, you may find a T-List or a Track defect list, or an S-List or System area defect list.

P-List Remapping
Lets get into how these defect lists actually work, so say we have a small hard disk with just 100 sectors and a 10 sector spares pool.

When bad sectors are found at the factory, shift-points are entered into the P-List, if we take the following LBA sequence 0,1,2,3,4,5,6,7,8,9,10 ...99, 100 Lets say that Sectors 3, 6 and 9 are found to be bad. When the first bad sector is found, the first part of the re-mapping process will look like this

0,1,2,B,4,5,6,7,8,9,10 ..

What happens here is the bad sector at position 3 is recorded in the P-List and is marked as Bad. The good sectors are then 'translated' and the new map now looks like this;

0,1,2,P,3,4,5,6,7,8,9,10 ..  You can see now that 3 is where 4 was. This is known as 'translation'

The next bad sector at LBA 6 is now found

0,1,2,P,3,4,5,B,7 and is again mapped out giving 0,1,2,P,3,4,5,P,6,7

When the whole sequence is complete, our final map looks like this.

0,1,2,P,3,4,5,P,6,7,8,P,9,10

Because these sectors are mapped out and the LBA values are translated so that the bad ones are not included in the LBA map, the user will never be aware that they ever existed. If you want to look at sector 6, the drive will translate that to physical sector 8. It takes the 6 and adds the shift points to it, +1 for the bad sector at LBA3 and +1 for the bad sector at LBA 6

When the testing gets to the end of the drive, in order that it is of the correct size of 100 sectors, it allocates the sectors from the spare sector pool completely concealing the fact that there are bad sectors on the media. To all intents and purposes the drive looks just like the original as 1,2,3,4,5,6,7,8,9,10. However, our spare pool has reduced in size and there are now 7 sectors remaining in the spares pool.

After using the drive for a while some bad sectors may develop, so the drive has a method of taking care of these using a grown defect list or G-List.

G-List Remapping
The grown defect table contains the location of bad sector defects found during normal operation of the hard disk drive. When a bad sector develops during normal use of the computer, a similar process to the P-List generation occurs - resulting with the bad sectors being mapped out. The process for G-List mapping is slightly different though. Lets say our hard disk develops a bad sector at the current LBA 6. What happens in this case is first the bad sector is mapped out. Giving; 0,1,2,3,4,5,G,7,8,9,10 .. A sector from the spare pool is allocated in the bad sectors place. We used 3 of these sectors in factory testing, so the next available bad sector is 104 this now becomes mapped to LBA 6 so our true LBA sequence would look like this; 0,1,2,3,4,5,104,7,8,9,10 - the new bad sector is added to the translator and 'translated' out. Again, this process is completely invisible to the user and will still look like the original sequence of 0,1,2,3,4,5,6,7,8,9,10

You might ask, 'why don't the new defects get added to the P-List?' the answer is that if you add a grown defect to the P-List it has the effect of shifting the data up the drive for each sector from the point where the new bad sector is found. If you look again at the methodology behind the P-List it will help you understand this.

Where a G-List entry can help to revive hard disk, if there was data stored in the now bad-sector then to the user it is lost. This may appear as a file that not longer opens, or a program that doesn't run any more or some other errant behaviour. This type of failure will never become apparent until the next time the file is attempted to be opened. It may also be that it is such a long time since it was opened that a backup plan means there are no backups of the working version. So bear this in mind when developing your backup plan.

Defect Mapping in a live system
When a hard disk is powered up, the p-list and g-list are usually combines into a translator then loaded into RAM on the controller card. As requests for data come through, the location where the data is required from is passed to the translator, which makes the calculations necessary so as to determine which sectors to read in order to get to the requested data.

In our example above, if we wanted the data from LBA 6 the translator would first run through the p-list and add 2 sectors to the count for the two bad sectors found at the factory, it then checks this value in the G-list and finds it has been re-allocated to sector 104. It then reads sector 104 and presents you with the data. Voila !

History:
In the good old days when you got change from a quid after buying a pint of beer and a packet of crisps and Christmas meant an Orange and a hula hoop, bad sector mapping was done manually with the user having to map out the bad sectors from a list in the documentation that came with the drive or was printed on the drive label. Each time the drive was formatted this remap needed to be performed again. The mapping was done by marking the cluster containing the bad sector as Bad in the FAT table or other indexing system depending on the operating system.

 

MjM Data Recovery Ltd is rated 4.96 stars by Reviews.co.uk based on 50 merchant reviews