Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Using kfed tips

Oracle Database Tips by Donald BurlesonSeptember 19, 2015

Question:  I have heard of the undocumented kfed (kernel file editor) utility.  Can you explain how kfed works?

Answer:  The kfed is an undocumented ASM utility that is used to read and modify ASM metadata blocks. The kfed is a standalone utility, independent of any ASM instance, so it can be used with either mounted or dismounted disk groups.
 
kfed is available from Oracle Database 11g Release 1 and forward and can be used to read and write ASM metadata, in particular disk headers and ASM metadata contents. kfed in write mode is a powerful but can be potentially destructive tool in the wrong hands. kfed invoked with the -help option displays the online help for the utility.
 
The most common kfed feature is its ability to fix corrupt ASM metadata.  The kfed binary is located in $ORACLE_HOME/bin directory.  With the kfed "read" command we can read a single ASM metadata block. The syntax is:
 
$ kfed read [aun=ii aus=jj blkn=kk dev=]asm_disk_name
 
Where the command line parameters are
 
aun - Allocation Unit (AU) number to read from. Default is AU0, or the very beginning of the ASM disk.
aus - AU size. Default is 1048576 (1MB). Specify the aus when reading from a disk group with non-default AU size.
blkn - block number to read. Default is block 0, or the very first block of the AU.
dev - ASM disk or device name. Note that the keyword dev can be omitted, but the ASM disk name is mandatory.
Use kfed to read ASM disk header block.

# displays online help for the utility
$ kfed -help

# reads the disk header to stdout
$ kfed op=read dev=/dev/mapper/itstor741_11p1

# reads the specified AU and block into file /tmp/a
$ kfed op=read dev=/dev/mapper/itstor741_11p1 aunum=3 blknum=3 text=/tmp/a

# writes from /tmp/a into the specified AU and block
#block checksum is computed and written together with data
$ kfed op=write dev=/dev/mapper/itstor741_11p1 aunum=3 blknum=3 text=/tmp/a


The following is an example of using the kfed utility to read the ASM disk header from ASM disk /dev/sda1.
 
$ kfed read /dev/sda1 | more
kfbh.endian:                          1 ; 0x000: 0x01
kfbh.hard:                          130 ; 0x001: 0x82
kfbh.type:                            1 ; 0x002: KFBTYP_DISKHEAD
kfbh.datfmt:                          1 ; 0x003: 0x01
kfbh.block.blk:                       0 ; 0x004: blk=0
kfbh.block.obj:              2147483648 ; 0x008: disk=0
kfbh.check:                  3102721733 ; 0x00c: 0xb8efc6c5
kfbh.fcn.base:                        0 ; 0x010: 0x00000000
kfbh.fcn.wrap:                        0 ; 0x014: 0x00000000
...
kfdhdb.dsknum:                        0 ; 0x024: 0x0000
kfdhdb.grptyp:                        2 ; 0x026: KFDGTP_NORMAL
kfdhdb.hdrsts:                        3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname:               DATA_0000 ; 0x028: length=9
kfdhdb.grpname:                    DATA ; 0x048: length=4
kfdhdb.fgname:                DATA_0000 ; 0x068: length=9
kfdhdb.ausize:                  1048576 ; 0x0bc: 0x00100000
kfdhdb.dsksize:                   12284 ; 0x0c4: 0x00002ffc
 
...

 
Note that the above kfed command is equivalent to this one (with all parameters explicitly set to their default values): 
 
If you wish to use kfed prior to the Grid Infrastructure installation, please refer to MOS Note: 1505005.1 which involves invoking the ldd command against kfed and saving off the required kfed libraries.
 
Here's a simple shell script called kfed.ksh to display ASM Disk Header information.
 
kfed read /dev/oracleasm/disks/DATA1 |egrep -i "kfdhdb.hdrsts|kfdhdb.dskname|kfdhdb.grpname|kfdhdb.fgname|kfdhdb.secsize|blksize|driver.provstr|kfdhdb.ausize"
cat <
Legend:
kfdhdb.hdrsts - Status of disk
kfdhdb.dskname - Name of the disk
kfdhdb.grpname - Name of disk group the disk belongs to
kfdhdb.fgname - Name of failure group the disk belongs to
kfdhdb.secsize - Sector size of disk
kfdhdb.blksize - Blocksize of disk
kfdhdb.driver.provstr - Provision string for use with asm
kfdhdb.ausize - AU size
!!
+ASM > ./kfed.ksh
kfdhdb.driver.provstr: ORCLDISKDATA1 ; 0x000: length=13
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname: DATA1 ; 0x028: length=5
kfdhdb.grpname: DATA ; 0x048: length=4
kfdhdb.fgname: DATA1 ; 0x068: length=5
kfdhdb.secsize: 512 ; 0x0b8: 0x0200
kfdhdb.blksize: 4096 ; 0x0ba: 0x1000
kfdhdb.ausize: 1048576 ; 0x0bc: 0x00100000
Legend:
kfdhdb.hdrsts - Status of disk
kfdhdb.dskname - Name of the disk
kfdhdb.grpname - Name of disk group the disk belongs to
kfdhdb.fgname - Name of failure group the disk belongs to
kfdhdb.secsize - Sector size of disk
kfdhdb.blksize - Blocksize of disk
kfdhdb.driver.provstr - Provision string for use with asm
kfdhdb.ausize - AU size
+ASM > kfed read /dev/oracleasm/disks/DATA1
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD
kfbh.datfmt: 1 ; 0x003: 0x01
kfbh.block.blk: 0 ; 0x004: T=0 NUMB=0x0
kfbh.block.obj: 2147483648 ; 0x008: TYPE=0x8 NUMB=0x0
kfbh.check: 2184817018 ; 0x00c: 0x8239a97a
kfbh.fcn.base: 15632 ; 0x010: 0x00003d10
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdhdb.driver.provstr: ORCLDISKDATA1 ; 0x000: length=13
...
...
...
+ASM > kfed read /dev/oracleasm/disks/DATA1 aunum=2 blknum=0 text=/tmp/DATA1.txt
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 5 ; 0x002: KFBTYP_LISTHEAD
kfbh.datfmt: 1 ; 0x003: 0x01
kfbh.block.blk: 0 ; 0x004: T=0 NUMB=0x0
kfbh.block.obj: 1 ; 0x008: TYPE=0x0 NUMB=0x1
kfbh.check: 4277819812 ; 0x00c: 0xfefa59a4
kfbh.fcn.base: 9635 ; 0x010: 0x000025a3
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfflhe[0].cnt: 0 ; 0x000: 0x00000000
kfflhe[0].rcvr: 0 ; 0x004: 0x00000000
kfflhe[0].high: 0 ; 0x008: 0x00000000
kfflhe[0].frlist.number: 4294967295 ; 0x00c: 0xffffffff
kfflhe[0].frlist.incarn: 0 ; 0x010: A=0 NUMM=0x0
kfflhe[0].dangle.number: 4294967295 ; 0x014: 0xffffffff


One Oracle OTN user notes that kfed can be used to rename an ASM disk header. 

 Here it is in hopes that it helps someone else.

DISCLAIMER.... If you screw up your disks don't blame me.

If you have any questions about this you can email me: ramcda@hotmail.com

The procedure is basically this:
- compile kfed
- dump the disk header with kfed
- Modify the dump file
- write the dump back to the disk header.

** Changing ANYTHING other than the diskgroup name will render your disks useless.

Here is a script to do the work for you:

for file in `ls /dev/vx/rdsk/as1_pccdw/asmdata*`
do
echo "Processing DATA disk $file ..."
search=ASCDW_DATA
replace=AS1CDW_DATA
newlength=`echo $replace | wc -m`
let newlength=$newlength-1
shortname=`echo $file | cut -f 6 -d /`

kfed op=read dev=$file | sed -e '24,24s/ '$search' / '$replace' /' -e '24,24s/length=.*/length='$newlength'/' > /tmp/$shortname.kfed
kfed op=write dev=$file text=/tmp/$shortname.kfed CHKSUM=YES
done

for file in `ls /dev/vx/rdsk/as1_pccdw/asmredo*`
do
echo "Processing REDO disk $file ..."
search=ASCDW_REDO
replace=AS1CDW_REDO
newlength=`echo $replace | wc -m`
let newlength=$newlength-1
shortname=`echo $file | cut -f 6 -d /`

kfed op=read dev=$file | sed -e '24,24s/ '$search' / '$replace' /' -e '24,24s/length=.*/length='$newlength'/' > /tmp/$shortname.kfed
kfed op=write dev=$file text=/tmp/$shortname.kfed CHKSUM=YES
done


   
Oracle Training from Don Burleson 

The best on site "Oracle training classes" are just a phone call away! You can get personalized Oracle training by Donald Burleson, right at your shop!

Oracle training
 
 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster