2

One of my HDD has some damaged sectors, which stay as pending. I want to force relocation.

From the question Reallocate bad sector [Linux] I know I can use sudo hdparm --yes-i-know-what-i-am-doing --write-sector 215040 /dev/sda but how to interpret the line:

# 1  Extended offline    Completed: read failure       90%     31807         1362407718

considering that the disk has 4 KB sectors? 31807 is the lifetime hours (wrapped at 65k...), 1362407718 is the LBA which caused an error and with it the end of the SMART "long test".

The disk has 512b logical sectors, 4 KB physical sectors.

Sector Sizes:     512 bytes logical, 4096 bytes physical

I tried sg_verify as recommended in https://www.smartmontools.org/wiki/BadBlockHowto#Badblockreassignment but it doesn't provide any output:

# sg_verify -v --lba=1362407718 /dev/disk/by-id/ata-WDC_WD30EFRX-68AX9N0_WD-WMC1T1033727
# 

How should I proceed to force remapping of the bad sector?

I'm running Ubuntu 22.04 LTS and the disk is formatted using ZFS.

FarO
  • 1,968

1 Answers1

0

How to interpret this LBA number?

The authoritative source is the ATA/ATAPI Specification, which is the basic command set used by SATA devices. According to Section 3.1.37 LBA (Logical Block Address), an LBA is the 'value used to reference a logical sector'.
A logical sector is the 'set of words accessed and referenced as a unit ... that contain user data and are referenced by LBA (see 3.1.37).'

The logical block size is stated to be the conventional 512 bytes. So the fact that the drive has physical sectors that are 4KB should be irrelevant because the terminology is used in a consistent manner.
The SATA interface has defined the LBA as the method to identify each and every logical sector. The SATA host (e.g. the computer) can only refer to a logical sector by its LBA. The mapping of logical blocks to physical sectors is intended to be transparent (except for write performance).

How should I proceed to force remapping of the bad sector?

Seems like you could try using the command you found with the LBA that is reported by your drive.


There is a possibility that that command could fail because a read of the physical sector would be required by the drive/controller before the 'write' of the logical sector can be accomplished. You might be able to circumvent a read-before-write by trying to force a dd command to use a multi-sector operation by specifying bs=4096 to match the physical sector size such as:

dd if=/dev/zero of=/dev/sdX bs=4096 count=1 seek=170300964

where the seek value is the LBA divided by bs/512. This assumes that the controller would recognize a write to a full physical sector, and therefore should skip the read operation. Note however that this operation will clobber more than just the single problematic logical sector.

sawdust
  • 18,591