LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 02-24-2009, 08:55 PM   #1
x0563511
LQ Newbie
 
Registered: Dec 2005
Distribution: In OS limbo
Posts: 7

Rep: Reputation: 0
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.
 
Old 02-25-2009, 10:00 AM   #2
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
"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?
 
Old 02-25-2009, 02:19 PM   #3
x0563511
LQ Newbie
 
Registered: Dec 2005
Distribution: In OS limbo
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by CJS View Post
"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.
 
Old 02-25-2009, 06:14 PM   #4
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to copy an entire disk byte-for-byte Pawprint Linux - Software 6 06-16-2011 11:01 AM
byte to byte remote comparison louisJ Linux - Newbie 3 09-21-2007 05:28 PM
get the actual hardware memory address of kernel oops edman007 Linux - General 0 02-24-2005 10:26 PM
backup byte-for-byte axion0917 Linux - Software 2 12-11-2003 05:01 PM
what is LBA? cyberswami Linux - Hardware 2 06-26-2003 06:23 AM


All times are GMT -5. The time now is 10:41 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration