[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 2


fsdb Command

Purpose

Debugs file systems.

Syntax

fsdb FileSystem [ - ]

Description

The fsdb command enables you to examine, alter, and debug a file system, specified by the FileSystem parameter. The command provides access to file system objects, such as blocks, i-nodes, or directories. You can use the fsdb command to examine and patch damaged file systems. Key components of a file system can be referenced symbolically. This feature simplifies the procedures for correcting control-block entries and for descending the file system tree.

To examine a file system, specify it by a block device name, a raw device name, or a mounted file system name. In the last case, the fsdb command determines the associated file system name by reading the /etc/filesystems file. Mounted file systems cannot be modified.

The fsdb command has a different interface for a JFS file system and a JFS2 file system. The following explains how to use fsdb with a JFS file system. See JFS2 Subcommands for information about JFS2 subcommands.

The subcommands for the fsbd command allow you to access, view, or change the information in a file system. Any number you enter in the subcommand is considered decimal by default, unless you prefix it with either 0 to indicate an octal number or 0x to indicate a hexadecimal number. All addresses are printed in hexadecimal.

Because the fsdb command reads and writes one block at a time, it works with raw as well as with block I/O.

Implementation Specifics

JFS is POWER-based platform only, and JFS2 is common to both platforms.

Flag


- Disables the error checking routines used to verify i-nodes and block addresses. The O subcommand switches these routines on and off. When these routines are running, the fsdb command reads critical file system data from the superblock. The obtained information allows the fsdb command to access the various file system objects successfully and to perform various error checks.

Subcommands

The fsdb subcommands are requests to locate and display or modify information in the file system. The main categories of subcommands are:

Category Function
Location Access the information in the file system.
Display View the information in the file system.
Modification Change the information in the file system.

In addition, there are a few miscellaneous subcommands.

Location Subcommands

There are two types of location subcommands:

Number[ I | M | i | b ]

OR

dDirectorySlot

The first type consists of a number, optionally followed by an address specification. The address specification defines how the preceding number is to be interpreted. There are four address specifications corresponding to four different interpretations of the Number variable:

I I-node map block number
M Disk map block number
i I-node number
b Fragment number

Depending on the address specification (or absence of it), this type of location subcommand accesses information as follows:

Number Accesses data at the absolute byte offset specified by the Number variable.
MapBlockNumberI Accesses the i-node map block indicated by the MapBlockNumber variable.
MapBlockNumberM Accesses the disk map block indicated by the MapBlockNumber variable.
InodeNumberi Accesses the i-node indicated by the InodeNumber variable.
FragmentNumberb Accesses the file system block indicated by the FragmentNumber variable. A fragment number consists of a block address and an encoded length. A complete fragment address is 32 bits in length. The low-order 28 bits are the beginning fragment address. The fragment length is encoded in the remaining 4 bits; it is encoded as the number of fragments less than a full block. For example, on a file system consisting of 1024-byte fragments, the address 0x2000010f references a block that begins at 1KB block number 0x10f and is 2KB in length. In contrast, on a file system of 512-byte fragments, the address 0x2000010f references a block that begins at 512-byte block 0x10f and is 3072 (512 * 6) bytes in length.

The second type of location subcommand is used to access directory entries. The subcommand consists of the character d followed by a directory-slot number. Directory-slot numbers start at 0 for each block of the associated i-node.

This type of location subcommand accesses information as follows:

dDirectorySlot Accesses the directory entry indexed by the DirectorySlot variable for the current i-node. Only allocated directory entries can be manipulated using this location subcommand.

Display Subcommands

To view information relative to the address specification, use a display subcommand comprised of one of the display facilities in conjunction with one of the display formats, as follows:

p[Number]{ i | d | o | e | c | b | y | M | I | x | s | D }

OR

f[Number]{ i | d | o | e | c | b | y | M | I | x | s | D }

The display facilities are:

p Indicates a general facility. Use the general display subcommand to display data relative to the current address. If you enter a number after the p symbol, the fsdb command displays that number of entries. A check is made to detect block boundary overflows. If you enter 0 or * (asterisk), the fsdb command displays all entries to the end of the current fragment.
f Indicates a file facility. Use the file display subcommand to display data blocks associated with the current i-node. If you enter a number after the f symbol, the fsdb command displays that block of the file. Block numbering begins at 0. The display format follows the block number. If you enter f without a block number, the fsdb command defaults to displaying block 0 of the current i-node.

The display formats for either facility are:

i Displays as i-nodes.
d Displays as directories.
o Displays as octal words.
e Displays as decimal words.
c Displays as characters.
b Displays as octal bytes.
y Displays as hexadecimal bytes.
M Displays as disk map entries.
I Displays as i-node map entries.
x Displays as hexadecimal words.
S Displays as single indirect blocks.
D Displays as double indirect blocks.

The chosen display facility and display format remain in effect during the processing of the fsdb command until explicitly changed. You may receive an error message indicating improper alignment if the address you specify does not fall on an appropriate boundary.

If you use the Number, MapBlockNumberI, or FragmentNumberb location subcommands to access i-node information, you can step through the data, examining each byte, word, or double word. Select the desired display mode by entering one of the following subcommands:

B Begins displaying in byte mode.
D Begins displaying in double-word mode.
W Begins displaying in word mode.

You can move forward or backward through the information. The boundary advances with the display screen and is left at the address of the last item displayed. The output can be ended at any time by pressing the INTERRUPT key. The following symbols allow movement through the information:

+ Number Moves forward the specified number of units currently in effect.
-Number Moves backward the specified number of units currently in effect.

The following symbols allow you to store the current address and return to it conveniently:

> Stores the current address.
< Returns to the previously stored address.

You can use dots, tabs, and spaces as subcommand delimiters, but they are only necessary to delimit a hexadecimal number from a subcommand that could be interpreted as a hexadecimal digit. Pressing the Enter key (entering a blank line) increments the current address by the size of the data type last displayed. That is, the address is set to the next byte, word, double word, directory entry, or i-node, allowing you to step through a region of a file system.

The fsdb command displays information in a format appropriate to the data type. Bytes, words, and double words are displayed as a hexadecimal address followed by the hexadecimal representation of the data at that address and the decimal equivalent enclosed in parentheses. The fsdb command adds a .B or .D suffix to the end of the address to indicate a display of byte or double word values. It displays directories as a directory slot offset followed by the decimal i-node number and the character representation of the entry name. It displays i-nodes with labeled fields describing each element. The environment variables control the formats of the date and time fields.

Modification Subcommands

You can modify information relative to the address specification by using a field specification (for fields in the i-node and fields in the directory). The general form for assigning new values is: mnemonic operator new-value, where the mnemonic parameter represents one of the fields described in the following list:

The following mnemonics are used for the names of the fields of an i-node and refer to the current working i-node:

md Permission mode
ln Link count
uid User number
gid Group number
sz File size
aNumber Data block numbers (0 to 8) where the Number parameter can be a location subcommand
at Access time
mt Modification time
maj Major device number
min Minor device number

The following mnemonics refer to the i-node and disk maps:

mf Map free count
ms Map size
mp Permanent allocation bit map
mw Working allocation bit map

The following mnemonics are used for the names of the fields in directories:

rl Length of directory entry record
nl Length of directory name
nm Directory name

Valid values of the Operator parameter include:

Note: A file system must be unmounted before attempting to modify it.

= Assigns the New-Value parameter to the specified Mnemonic parameter.
=+ Increment the Mnemonic parameter by the specified New-Value parameter. The default New-Value parameter is a value of one.
=- Decrease the Mnemonic by the specified New-Value. The default New-Value is a value of one.
=" Assigns the character string specified by the New-Value parameter to the specified Mnemonic parameter. If the current display format is the d address specification for directory and a mnemonic is not specified, the directory name is changed. The new directory name cannot be longer than the previous directory name.

Miscellaneous Subcommands

Miscellaneous subcommands are:

q Quits.

xn Expands a directory by n bytes where n plus the current size of the directory is not greater than the current directory's fragment in bytes.
! Escapes to the shell.
O Toggles error checking.

JFS2 Subcommands

These subcommands can be entered by their entire name or by using a subset of the name. At least the bold letters must be entered.

a[lter] <block> <offset> <hex string> Alters disk data.
b[tree] <block> [<offset>] Displays btree nodes.
dir[ectory] <inode number> [<fileset>] Displays directory entries.
d[isplay] [<block> [<offset> [<format> [<count>]]]] Displays data.
dm[ap] [<block number>] Displays dmap pages.
dt[ree] <inode number> [<fileset>] Displays dtree nodes.
h[elp] [<command>] Provides help on subcommands.
ia[g] [<IAG number>] [a | <fileset>] Displays IAG pages.
i[node] [<inode number>] [a | <fileset>] Displays inodes.
q[uit] Exits fsdb.
su[perblock] [p | s] Displays superblock.

a[lter] <block> <offset> <hex string>
where:
<block> block number (decimal)
<offset> offset within block (hex)
<hex string> string of hex digits

 
 

 
Alters disk data. <hex string> should contain an even number of digits.

 
 

b[tree] <block> [<offset>]
 
<block> block number (decimal)
<offset> offset within block (hex)

 
Displays one node of a btree and enters a subcommand mode in which to navigate the btree.

 
 

 
Subcommands:
l Visits left sibling
m Modifies current node
p Visits parent node
r Visits right sibling
[0-9] Visits the nth child node
x Exits subcommand mode

 
 

dir[ectory] <inode number> [<fileset>]
 
<inode number> inode number of directory (decimal)
<fileset> number, currently must be zero

 
 

 
Displays directory entries.

 
 

d[isplay] [<block> [<offset> [<format>[<count>]]]]
 
<block> block number (decimal)
<offset> offset within block (hex)
<format> format in which to display data (see below)
<count> number of objects to display (decimal)

 
Displays data in a variety of formats.

 
 

 
Format may be one of the following:
a ascii  
i inode struct dinode
I inode allocation map iag_t
s superblock struct superblock
x hexadecimal  

 
 

dm[ap] [<block number>]
 
<block number> Displays dmap page which describes this block number.

 
 

 
Subcommands:
m Modifies current node
u Visits upper level dmap page
l Visits left sibling
r Visits right sibling
w Displays wmap
p Displays pmap
s Displays stree
x Exits subcommand mode

 
 

dt[ree] <inode number> [<fileset>]
 
<inode number> inode number of directory (decimal)
<fileset> fileset number, currently must be zero

 
Displays root of the directory btree and enters a subcommand mode in which to navigate the btree.

 
 

 
Subcommands:
l Visits left sibling
m Modifies current node
p Visits parent node (not parent directory)
r Visits right sibling
[0-9] Visits the nth child node
x Exits subcommand mode

 
 

h[elp] [<command>]
 
<command> command name

 
Prints help text. Lists all commands if no parameter.

 
 

ia[g] [<IAG number>] [a | <fileset>]
 
<IAG number> IAG number (decimal)
a use aggregate inode table
 <fileset> fileset number (currently must be zero)

 
Displays iag information and enters subcommand mode.

 
 

 
Subcommands:
e Displays/modifies inode extents map
m Modifies iag
p Displays/modifies persistent map
w Displays/modifies working map

 
 

i[node] [<inode number>] [a | <fileset>]
 
<inode number> inode number (decimal)
a use aggregate inode table
fileset fileset number (currently must be zero)

 
Displays inode information and enters subcommand mode.

 
 

 
Subcommands:
e Displays/modifies inode's extended attributes.
m Modifies inode
t Displays/modifies inode's b-tree

 
 

q[uit]
Exits fsdb.

 
 

su[perblock] [p | s]
 
p Displays primary superblock
s Displays secondary superblock

 
Displays superblock data.

Examples

The following examples show subcommands you can use after starting the fsdb command on a JFS file system.

  1. To display an i-node, enter:

    386i
    

    This command displays i-node 386 in i-node format. It now becomes the current i-node.

  2. To change the link count for the current i-node to a value of 4, enter:

    ln=4
    
  3. To increase the link count of the current i-node by a value of 1, enter:

    ln=+1
    
  4. To display part of the file associated with the current i-node, enter:

    fc
    

    This command displays block 0 of the file associated with the current i-node in ASCII bytes.

  5. To display entries of a directory, enter:

    2i.fd
    

    This changes the current i-node to the root i-node (i-node 2) and then displays the directory entries in the first block associated with that i-node. One or more of the last entries displayed may have an i-node number of 0 (zero). These are unused directory blocks; such entries cannot be manipulated as in the next example.

  6. To go down a level of the directory tree, enter:

    d5i.fc
    

    This command changes the current i-node to the one associated with directory entry 5. Then it displays the first block of the file as ASCII text (fc). Directory entries are numbered starting from 0.

  7. To display a block when you know its block number, enter:

    1b.p0o
    

    This command displays the superblock (block 1) of file system in octal.

  8. To change the i-node of a directory entry, enter:

    2i.a0b.d7=3
    

    This command changes the i-node of directory entry 7 in the root directory (2i) to 3. This example also shows how several operations can be combined on one line.

  9. To change the file name of a directory entry, enter:

    d7.nm="chap1.rec"
    

    This command changes the name field of directory entry 7 to chap1.rec.

  10. To display a given block of the file associated with the current i-node, enter:

    a2b.p0d
    

    This command displays block 2 of the current i-node as directory entries.

  11. To display the content of a single indirect block at block 7, enter:

    7b. p0S
    

    This command displays the block numbers allocated to the i-node that has a single indirect block at block 7.

  12. To display the first page of the disk map, enter:

    OM
    
  13. To display the first 10 words of permanent block allocation map in hexadecimal, enter:

    mp1.p10x
    

    This command shows the allocation bit map at the current address; for example, at 0M.

Files


/usr/sbin Contains the fsdb command.
/etc/filesystems Contains information on the file systems.

Related Information

The dfsck command, fsck command.

The dir file, filsys.h file.

The environment miscellaneous facility.

The read subroutine.

The File Systems Overview for System Management in AIX 5L Version 5.1 System Management Concepts: Operating System and Devices explains file system types, management, structure, and maintenance.

The Files Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices provides information on working with files.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]