Map LBA to File

From Attie's Wiki
(Difference between revisions)
Jump to: navigation, search
m
m
Line 1: Line 1:
 
http://smartmontools.sourceforge.net/badblockhowto.html
 
http://smartmontools.sourceforge.net/badblockhowto.html
 
<pre>
 
  
 
Bad LBA = 0x0a8ae67d = 176875133
 
Bad LBA = 0x0a8ae67d = 176875133
  
 
+
<source lang="text">
 
+
 
$ sudo fdisk -lu /dev/sda
 
$ sudo fdisk -lu /dev/sda
  
Line 20: Line 17:
 
/dev/sda3      168181823  172376126    2097152  82  Linux swap / Solaris
 
/dev/sda3      168181823  172376126    2097152  82  Linux swap / Solaris
 
/dev/sda4      172376127  976768064  402195969  83  Linux
 
/dev/sda4      172376127  976768064  402195969  83  Linux
 +
</source>
  
 +
therefore it's on <code>/dev/sda4</code>, which is mounted on <code>/home</code> (ext4)
  
 
+
<source lang="text">
therefore /dev/sda4 -> /home (ext4)
+
 
+
 
+
 
+
 
$ sudo tune2fs -l /dev/sda4 | grep Block
 
$ sudo tune2fs -l /dev/sda4 | grep Block
 
Block count:              100548992
 
Block count:              100548992
 
Block size:              4096
 
Block size:              4096
 
Blocks per group:        32768
 
Blocks per group:        32768
 +
</source>
  
 +
<source lang="text">
 +
b = (int)(((L-S)*512)/B)
 +
</source>
 +
where:<br>
 +
{|
 +
| b || = || File System block number
 +
|-
 +
| B || = || File system block size in bytes
 +
|-
 +
| L || = || LBA of bad sector
 +
|-
 +
| S || = || Starting sector of partition as shown by fdisk -lu
 +
|-
 +
|colspan="2"|(int) || denotes the integer part (round it DOWN to a whole number).
 +
|}
 +
<source lang="text">
 +
b = (int)((176875133-172376127) * 512 / 4096)
 +
b = (int)562375.75
 +
b = 562375
 +
</source>
  
  
  b = (int)((L-S)*512/B)
+
<source lang="text">
where:
+
b = File System block number
+
B = File system block size in bytes
+
L = LBA of bad sector
+
S = Starting sector of partition as shown by fdisk -lu
+
and (int) denotes the integer part.
+
 
+
  b = (int)((176875133-172376127) * 512 / 4096)
+
  b = (int)562375.75
+
  b = 562375
+
 
+
 
+
 
+
 
$ sudo debugfs
 
$ sudo debugfs
 
debugfs 1.41.9 (22-Aug-2009)
 
debugfs 1.41.9 (22-Aug-2009)
Line 54: Line 57:
 
Block 562375 not in use
 
Block 562375 not in use
 
debugfs:  quit
 
debugfs:  quit
 +
</source>
  
 +
'''** OR **'''
  
 
+
<source lang="text">
** OR **
+
 
+
 
+
 
+
 
$ sudo debugfs
 
$ sudo debugfs
 
debugfs 1.41.9 (22-Aug-2009)
 
debugfs 1.41.9 (22-Aug-2009)
Line 74: Line 75:
 
^C
 
^C
 
debugfs:  quit
 
debugfs:  quit
</pre>
+
</source>

Revision as of 16:42, 24 May 2012

http://smartmontools.sourceforge.net/badblockhowto.html

Bad LBA = 0x0a8ae67d = 176875133

$ sudo fdisk -lu /dev/sda
 
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x030818eb
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      409662      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2          409663   168181822    83886080   83  Linux
/dev/sda3       168181823   172376126     2097152   82  Linux swap / Solaris
/dev/sda4       172376127   976768064   402195969   83  Linux

therefore it's on /dev/sda4, which is mounted on /home (ext4)

$ sudo tune2fs -l /dev/sda4 | grep Block
Block count:              100548992
Block size:               4096
Blocks per group:         32768
b = (int)(((L-S)*512)/B)

where:

b = File System block number
B = File system block size in bytes
L = LBA of bad sector
S = Starting sector of partition as shown by fdisk -lu
(int) denotes the integer part (round it DOWN to a whole number).
b = (int)((176875133-172376127) * 512 / 4096)
b = (int)562375.75
b = 562375


$ sudo debugfs
debugfs 1.41.9 (22-Aug-2009)
debugfs:  open /dev/sda4
debugfs:  testb 562375
Block 562375 not in use
debugfs:  quit

** OR **

$ sudo debugfs
debugfs 1.41.9 (22-Aug-2009)
debugfs:  open /dev/sda4
debugfs:  testb 562375
Block 562375 marked in use
debugfs:  icheck 562375
Block   Inode number
562375  132344
debugfs:  ncheck 132344
Inode   Pathname
132344  /attie/banner.jpg
^C
debugfs:  quit
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox