Quantcast

Script for bad block LBA -> LVM PE -> ext2 block/inode calculation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Script for bad block LBA -> LVM PE -> ext2 block/inode calculation

Eduardo Habkost


Hi,

(please CC me if replying to this, as I am not following the mailing
list traffic)

While following the Bad Block HOWTO to find out the filesystem blocks
and inodes affected by some bad blocks on a hard disk, I've written a
small script to help me on all the calculations described on the HOWTO.
The result is at:

http://raisama.net/diary/archive/2009/03/22/lba2fs  (announcement)
http://raisama.net/software/lba2fs/lba2fs.py   (the script itself)

The script is almost a direct translation of the instructions on the
HOWTO for checking the partition table, LVM PEs and ext2/ext3 blocks. I
hope it is useful for other people. Any feedback is welcome.

This is a sample run of the script:

=====================================================
# ./lba2fs.py /dev/sda 11475078  # SMART says LBA 11475078 is bad
lba2fs, by Eduardo Habkost <[hidden email]>
If you want to know what to do with the output of this program, check:
http://smartmontools.sourceforge.net/badblockhowto.html

[/dev/sda sector 11475078]
Press Return to automatically probe, or enter command:
cmd>
I think I've found: partition table
Checking the partition list...
/dev/sda2 sector 11073453
[/dev/sda2 sector 11073453]
Press Return to automatically probe, or enter command:
cmd>
I think I've found: LVM volume
Checking the PE where the block is located
pe_start: 384 sectors
PE: 168
Checking on which LV the PE is located
Found PE range on map (LV)
Checking maps of LV...
/dev/VolGroup00/LogVol00 sector 11073069
[/dev/VolGroup00/LogVol00 sector 11073069]
Press Return to automatically probe, or enter command:
cmd>
I think I've found: ext3 filesystem
Checking ext2 fs block...
Block size: 4096
Block: 1384133
debugfs 1.41.4 (27-Jan-2009)

GOOD: ext2fs block 1384133 at /dev/VolGroup00/LogVol00, not in use

You can zero the block running the following command, but:
1) Don't do that if the device is in use (e.g. filesystem mounted)
2) *You will lose data* that is stored on the block. It looks like
   It is safe to do that on this block, but be careful. Are your
   backups up to date?  8)

  dd if=/dev/zero of=/dev/VolGroup00/LogVol00 bs=4096 count=1 seek=1384133

I recommend doing a read-test on the block first, to see if an I/O error
is returned. Use the 'read' command for that.

[ext2fs block 1384133 at /dev/VolGroup00/LogVol00, not in use]
Press Return to automatically probe, or enter command:
cmd> quit
Bye!
=====================================================

--
Eduardo

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Smartmontools-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/smartmontools-support
Loading...