Is it possible to calculate where is, physically, a bad block located on a hard disk?

Solution 1:

This really isn't feasible with modern disks.

In the old days disks were essentially dumb devices (simplifying, but stick with me). The system would request data from a particular Cylinder (physically a ring on the disk), Head (2 heads per platter), and Sector (each ring had sector numbered from 1 to whatever). The controller told the disk to move to such and such CHS location and read or write the data. You knew that cylinder 0 was near the edge of the disk, and the highest cylinder was at the root. Really ancient disks had a physical mark where sector 1 was located in each cylinder, so you could open a drive and almost see data locations.

Today's disks have permanent formattings that include address information, true physical addresses, not the logical ones presented to the controller. When a disk is asked to move the head to Large Block Address (LBA) 0, that is mapped to a physical sector (probably the actual first sector, or near there, unless it's been remapped). But the disk predicts where that sector will be based on guess algorithm. It then waits for the next sector to fly under the head, reading the address - if it guessed wrong it adjusts, if just guessed right then it reads/writes the sector. This guessing process is necessary because the disk physically expands as it heats up, causing the sector to be in a different place when the disk is warm or cold. Also, there's isn't a consistent number of sectors in each cylinder. The older CHS disks had physically different size sectors because of the addressing system. Modern disks have consistent size sectors because they're just numbered from 0 to whatever sequentially.

To compound your question, as a disk detects sectors that may or actually have problems, it remaps them silently (SMART shows, but it's not an error to the host OS until it's unreadable - or SCSI disks can be told to notify the host OS). So the logical LBAs you see might not correspond to the physical addresses internal to the drive.