BBED marks Bad blocks and fixes bad blocks.

Source: Internet
Author: User

BBED marks Bad blocks and fixes bad blocks.

Create a test table:

ZBDBA@orcl11g>select * from zbdba;NAME------------------------------------------------------------zbdbahuihuiZBDBA@orcl11g>ZBDBA@orcl11g>ZBDBA@orcl11g>ZBDBA@orcl11g>ZBDBA@orcl11g>select rowid,dbms_rowid.rowid_object(rowid) robject,  2  dbms_rowid.rowid_relative_fno(rowid) fno,  3  dbms_rowid.rowid_block_number(rowid) bno,  4  dbms_rowid.rowid_row_number(rowid) rno from zbdba where rownum=1;ROWID                 ROBJECT        FNO        BNO        RNO------------------ ---------- ---------- ---------- ----------AAASMNAAGAAAAC/AAA      74509          6        191          0

Use bbed to modify the block status:

BBED> set file 6 block 191        FILE#           6        BLOCK#          191BBED> mapFile: /opt/oracle/oradata/orcl11g/zbdba01.dbf (6)Block: 191                                   Dba:0x018000bf------------------------------------------------------------KTB Data Block (Table/Cluster)struct kcbh, 20 bytes                      @0      struct ktbbh, 72 bytes                     @20     struct kdbh, 14 bytes                      @100    struct kdbt[1], 4 bytes                    @114    sb2 kdbr[2]                                @118    ub1 freespace[8047]                        @122    ub1 rowdata[19]                            @8169   ub4 tailchk                                @8188   BBED> p kcbhstruct kcbh, 20 bytes                       @0         ub1 type_kcbh                            @0        0x06   ub1 frmt_kcbh                            @1        0xa2   ub1 spare1_kcbh                          @2        0x00   ub1 spare2_kcbh                          @3        0x00   ub4 rdba_kcbh                            @4        0x018000bf   ub4 bas_kcbh                             @8        0x005036cd   ub2 wrp_kcbh                             @12       0x0000   ub1 seq_kcbh                             @14       0x01   ub1 flg_kcbh                             @15       0x06 (KCBHFDLC, KCBHFCKV)   ub2 chkval_kcbh                          @16       0x426d   ub2 spare3_kcbh                          @18       0x0000BBED> modify /x ff offset 14Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) yFile: /opt/oracle/oradata/orcl11g/zbdba01.dbf (6)Block: 191              Offsets:   14 to  525           Dba:0x018000bf------------------------------------------------------------------------ff066d42 00000100 00000d23 01009636 50000000 00000200 3200b800 8001130002001800 0000e90b 80021100 38000220 0000cd36 50000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000001 0200ffff 1600851f6f1f6f1f 00000200 8f1f851f 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<32 bytes per line>BBED> p kcbhstruct kcbh, 20 bytes                       @0         ub1 type_kcbh                            @0        0x06   ub1 frmt_kcbh                            @1        0xa2   ub1 spare1_kcbh                          @2        0x00   ub1 spare2_kcbh                          @3        0x00   ub4 rdba_kcbh                            @4        0x018000bf   ub4 bas_kcbh                             @8        0x005036cd   ub2 wrp_kcbh                             @12       0x0000   ub1 seq_kcbh                             @14       0xff   ub1 flg_kcbh                             @15       0x06 (KCBHFDLC, KCBHFCKV)   ub2 chkval_kcbh                          @16       0x426d   ub2 spare3_kcbh                          @18       0x0000BBED> sum applyCheck value for File 6, Block 191:current = 0x4293, required = 0x4293
Go back to the database to view the table:

ZBDBA@orcl11g>select * from zbdba;select * from zbdba              *ERROR at line 1:ORA-01578: ORACLE data block corrupted (file # 6, block # 191)ORA-01110: data file 6: '/opt/oracle/oradata/orcl11g/zbdba01.dbf'

Conventional Bad Block Processing Methods:
1. event 10231
2. rowid Extraction
3. DBMS_REPAIR

Here I use bbed to fix this block:

BBED> p kcbhstruct kcbh, 20 bytes                       @0         ub1 type_kcbh                            @0        0x06   ub1 frmt_kcbh                            @1        0xa2   ub1 spare1_kcbh                          @2        0x00   ub1 spare2_kcbh                          @3        0x00   ub4 rdba_kcbh                            @4        0x018000bf   ub4 bas_kcbh                             @8        0x005036cd   ub2 wrp_kcbh                             @12       0x0000   ub1 seq_kcbh                             @14       0xff   ub1 flg_kcbh                             @15       0x06 (KCBHFDLC, KCBHFCKV)   ub2 chkval_kcbh                          @16       0x4293   ub2 spare3_kcbh                          @18       0x0000BBED> p tailchkub4 tailchk                                 @8188     0x36cd0601
Here, the tailchk information is correct and does not need to be modified.

BBED> modify /x 01 offset 14Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) yFile: /opt/oracle/oradata/orcl11g/zbdba01.dbf (6)Block: 191              Offsets:   14 to  525           Dba:0x018000bf------------------------------------------------------------------------01069342 00000100 00000d23 01009636 50000000 00000200 3200b800 8001130002001800 0000e90b 80021100 38000220 0000cd36 50000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000001 0200ffff 1600851f6f1f6f1f 00000200 8f1f851f 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<32 bytes per line>BBED> p kcbhstruct kcbh, 20 bytes                       @0         ub1 type_kcbh                            @0        0x06   ub1 frmt_kcbh                            @1        0xa2   ub1 spare1_kcbh                          @2        0x00   ub1 spare2_kcbh                          @3        0x00   ub4 rdba_kcbh                            @4        0x018000bf   ub4 bas_kcbh                             @8        0x005036cd   ub2 wrp_kcbh                             @12       0x0000   ub1 seq_kcbh                             @14       0x01   ub1 flg_kcbh                             @15       0x06 (KCBHFDLC, KCBHFCKV)   ub2 chkval_kcbh                          @16       0x4293   ub2 spare3_kcbh                          @18       0x0000BBED> sum applyCheck value for File 6, Block 191:current = 0x426d, required = 0x426dBBED> verifyDBVERIFY - Verification startingFILE = /opt/oracle/oradata/orcl11g/zbdba01.dbfBLOCK = 191DBVERIFY - Verification completeTotal Blocks Examined         : 1Total Blocks Processed (Data) : 1Total Blocks Failing   (Data) : 0Total Blocks Processed (Index): 0Total Blocks Failing   (Index): 0Total Blocks Empty            : 0Total Blocks Marked Corrupt   : 0Total Blocks Influx           : 0Message 531 not found;  product=RDBMS; facility=BBED
Query the database again:

ZBDBA@orcl11g>select * from zbdba;NAME------------------------------------------------------------zbdbahuihui






Can I fix a bad USB flash drive?

The number of Bad blocks is small and can be repaired. The method is to make the USB flash disk into a system boot disk by means of mass production;
[Note: it is a "Mass Production" USB flash disk]

If there are too many bad blocks, it should not be repaired unless it is obtained from the manufacturer ~~~~~~

How to hide Bad blocks

If the data on your hard disk is irrelevant, you should first completely format it so that you can mark the bad sector and then execute Scandisk/all. If you want to retain the data, scan the hard disk with Scandisk/all to mark the bad sector. Then press Pause to Pause the scan. Now we can see several bad blocks marked with red "B", which begins the repair.

First, write down the relative position of each bad block in this figure, that is, the size of the "Good block" before each bad block, which accounts for the percentage of the entire hard disk, you can partition in PQMagic. Take my hard drive (3.2 GB) as an example.

The percentage of Good blocks in front of the Bad block to the entire hard disk is 150% 22.5%. The size of Good blocks before the first bad block is 50% × 3. 2G = 1.6G; the size of the Good block before the second bad block is 2.5% × 3. 2G = 80 M; the remaining part is the intact slice size of 1.52G. Therefore, the hard disk is first divided into the three partitions, and then the next bad block is roughly calculated to be about several MB, which is separated and hidden in the partition containing the bad block. If you think it is difficult to calculate the size of a bad block, you can do this: estimate the size of the Bad block, for example, 40 MB (it doesn't matter if it is bigger at first), and then separate it to ensure smooth completion, it indicates that no bad block is encountered, and the bad block has been allocated to the new partition, which is 40 MB. If you think it is too waste to lose 40 MB, you can also narrow down the partition, look at which side of the Bad block is close, and first indent it to the side away from the bad block, narrowing down at 1.1 points until the size of the Bad block cannot be changed. In this way, if you are lucky, you can scale down the bad block to a very small range. However, we do not recommend that you scale down the bad block too small because if it is too small, when using data, bad blocks may affect good sectors and cause more bad blocks. Today's hard disks are so huge that the loss of 100 or 200 MB space is nothing, the key is to be able to safely use other parts of the hard disk.

This method is very effective, avoiding the headache of computing a large amount of data and making it easy to operate. This is the method I found when I repaired my hard drive. It feels good to share it with you.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.