LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   LBA address to actual byte offset (https://www.linuxquestions.org/questions/linux-hardware-18/lba-address-to-actual-byte-offset-707292/)

x0563511 02-24-2009 08:55 PM

LBA address to actual byte offset
 
I'm working on a windows machine through linux. smartctl reports that there is a pending sector (and the long self-test reported an error reading from that sector) at LBA 0x09c8a4bb (164144315)

How can I 'translate' that LBA address to something I can feed to 'dd'?

Bad LBA: 0x09c8a4bb (164144315)
Geometry: 255h, 63s, 12161c
Units = cylinders of 16065 * 512 = 8225280 bytes

I tried looking around online, everything is regarding finding the file in a filesystem occupied. I don't need something that high level - I just need the byte range that I can feed to dd to manipulate the damaged area.

CJS 02-25-2009 10:00 AM

"dd" uses decimal sectors as the unit when you give dd an offset value, so how about simply doing:
Code:

dd if=/dev/<drive> skip=164144315 | hexdump -C | less
And of course replace <drive> with sda or whichever is the drive in question. Is that maybe what you are looking for, or did I completely misunderstand your question?

x0563511 02-25-2009 02:19 PM

Quote:

Originally Posted by CJS (Post 3457066)
"dd" uses decimal sectors as the unit when you give dd an offset value, so how about simply doing:
Code:

dd if=/dev/<drive> skip=164144315 | hexdump -C | less
And of course replace <drive> with sda or whichever is the drive in question. Is that maybe what you are looking for, or did I completely misunderstand your question?

That did it. I did have to add "bs=512" as some research found that LBA uses blocks of 512 bytes (or less common 1024)

I did a test read of the areas around the error using both block sizes and 512 was the one that put me right on the read error.

Thrashed that sector with /dev/urandom for about half an hour and it finally reallocated.

CJS 02-25-2009 06:14 PM

Glad that worked OK, and by the way, dd uses a block size of 512 bytes by default, so you don't actually have to specify "bs=512" if you don't want to. Good luck, and I hope your HDD isn't going bad if you are starting to get too many bad sectors. :)


All times are GMT -5. The time now is 08:29 AM.