DEBUGFS(8) DEBUGFS(8)
名前
debugfs - ext2/ext3 ファイルシステムデバッガ
書式
debugfs [ -Vwci ] [ -b blocksize ] [ -s superblock ] [ -f cmd_file ] [
-R request ] [ -d data_source_device ] [ device ]
説明
debugfs は対話的なファイルシステムのデバッガである。 ext2 ファイルシ ス
テムの状態の調査・変更に利用できる。 device は、ext2 ファイルシステムを
含むデバイスに対応するスペシャルファイルである。(例: /dev/hdXX)
オプション
-w ファイルシステムを read/write モードでオープンする。このオプショ
ン を指定しない場合は、ファイルシステムは read-only モードでオー
プンされる。
-c ファイルシステムを catastrophic (甚大な破損が起こった場合の) モ
ー ドでオープンする。このモードでは inode とグループビットを最初
に読み込まない。これは重度に破損したファイルシステムに対しては有
効なことがあるが、一方このため catastrophic モードではファイルシ
ステムを read-only でしかオープンできない。
-i device が e2image プログラムによって作成された ext2 イメージファ
イルであることを指定する。 ext2 イメージファイルは、スーパーブロ
ック・ブロックグループディスクリプタ・ブロックアロケーションビッ
ト マップ・ inode アローケションビットマップ・inode テーブルしか
持たないので、 debugfs の多くのコマンドが正しく機能しない。 警
告: 安 全 性のチェックは行わない。また、 -d オプションによって
data_source_device を指定せずに、 ls, dump などのコマンドを実 行
した場合には debugfs は変な風に失敗するかもしれない。 debugfs は
デバッグ用のツールなので、洗練された部分のみであるとは限らな い!
-d data_source_device
-i オプションと共に使用され、読み込みブロックが ext2 イメージフ
ァイルに見つからない場合には、指定された data_source_device が使
用 される。このデバイスにはデータ・ディレクトリ・間接 (indirect)
ブロックが含まれる。
-b blocksize
通常のように正しいブロックサイズを検出する動作を行わず、指定した
ブロックサイズをそのファイルシステムに用いる。
-s superblock
フ ァイルシステムのスーパーブロックを、デフォルトの 1 ではなく、
指定したブロック番号から読ませる。 -s オプションを指定した場合、
-b オプションも指定しなければならない。
-f cmd_file
debugfs に、 cmd_file からコマンドを読み込ませ、実行させる。コマ
ンドの実行を終了すると、 debugfs は終了する。
-R request
request というひとつのコマンドを実行し、終了する。
-V debugfs のバージョンを表示して終了する。
ファイル指定
debugfs のコマンドの多くは、 debugfs が現在オープンしているファイルシス
テ ムにおける inode (パス名ではない) を示す filespec という引数を取る。
filespec には 2 種類の表記法がある。ひとつは、inode 番号を <> で囲む 方
法である (例: <2>)。もうひとつはパス名で指定する方法である。パス名が「/
(スラッシュ)」ではじまる場合、 debugfs が現在オープンしているファイルシ
ステムのルートからの相対パスを表す。「/」で始まらない場合、カレントワー
キングディレクトリからの相対パスを表す。カレントワーキングディレクト リ
は debugfs の cd コマンドによって変更できる。
コマンド
debugfs がサポートするコマンドの一覧を以下に示す。
bmap filespec logical_block
filespec で指定した inode における論理ブロック番号 logical_block
に対応する物理ブロック番号を表示する。
cat filespec
filespec で指定した inode の内容を標準出力へダンプする。
cd filespec
カレントワーキングディレクトリを filespec で指定したディレクトリ
に変更する。
chroot filespec
ルートディレクトリを filespec で指定したディレクトリに変更する。
close 現在オープンしているファイルシステムをクローズする。
clri file
file で指定した inode の内容をクリアする。
dump [-p] filspec out_file
filespec で指定した inode の内容を out_file で指定したファイルに
ダンプする。 -p オプションを与えると、 out_file の所有者 (owner)
、所有グループ (group)、パーミッション (permission) を filespec
と同じにする。
expand_dir filespec
filespec で指定したディレクトリを展開する。
feature [fs_feature] [-fs_feature] ...
ス ーパーブロックの様々なファイルシステム属性をセット/クリアする
。要求のあった属性をセット/クリアした後は、ファイルシステム属 性
の現在状態の一覧を表示する。
find_free_block [count [goal]]
goal から始まる最初の count 分の空きブロックを探し、その空きブロ
ックをアロケート (allocate) する。
find_free_inode [dir [mode]]
空き inode を探し、その inode をアロケートする。 dir を指定す る
と、これはその inode を置くべきディレクトリの inode と解釈される
。さらに mode を指定すると、これは新しい inode のパーミッショ ン
と 解釈される。 (mode にディレクトリであることを指定するビットが
立っている場合、アロケートルーチンの挙動は異なるものになる。)
freeb block [count]
ブロック番号 block をアロケートされていないものとしてマークす る
。省略可能な引数 count を指定すると、ブロック番号 block から始ま
る count 分のブロックをアロケートされていないものとしてマーク す
る。
freei filespec
filespec で指定した inode を解放する。
help debugfs(8) で利用できるコマンドのリストを表示する。
icheck block ...
コマンドラインに与えたブロック (複数指定可) を利用している inode
のリストを表示する。
imap filespec
filespec で指定された inode の (inode テーブルにおける) inode デ
ータ構造の場所を表示する。
init_filesys device blocksize
device 上に、デバイスサイズ blocksize の ext2 ファイルシステムを
作成する。このコマンドは、すべてのデータ構造を完全に初期化するわ
け ではない。これをしたい場合は mke2fs(8) プログラムを用いること
。このコマンドは、単にスーパーブロックとブロックディスクリプタを
設定する低レベルライブラリを呼び出すだけである。
kill_file filespec
filespec で指定した inode と、その inode が使用しているブロック
をアロケートから外す (deallocate)。なお、その inode に対応するデ
ィレクトリエントリは削除しないことに注意。ファイルを unlink した
い場合は rm コマンドを参照のこと。
lcd directory
debugfs プロセスのカレントワーキングディレクトリをネイティブファ
イ ルシステム (訳註: 作業対象のものではなく、 debugfs が呼び出さ
れ、稼働しているファイルシステム) 上の directory に変更する。
ln filespec dest_file
filespec を指すリンク dest_file を作成する。この際 inode の参 照
数 (reference counts) は変更しないことに注意。
logdump [-acs] [-b
DEBUGFS(8) DEBUGFS(8)
NAME
debugfs - ext2/ext3/ext4 file system debugger
SYNOPSIS
debugfs [ -Vwci ] [ -b blocksize ] [ -s superblock ] [ -f cmd_file ] [
-R request ] [ -d data_source_device ] [ device ]
DESCRIPTION
The debugfs program is an interactive file system debugger. It can be
used to examine and change the state of an ext2, ext3, or ext4 file
system.
device is the special file corresponding to the device containing the
file system (e.g /dev/hdXX).
OPTIONS
-w Specifies that the file system should be opened in read-write
mode. Without this option, the file system is opened in read-
only mode.
-c Specifies that the file system should be opened in catastrophic
mode, in which the inode and group bitmaps are not read ini-
tially. This can be useful for filesystems with significant
corruption, but because of this, catastrophic mode forces the
filesystem to be opened read-only.
-i Specifies that device represents an ext2 image file created by
the e2image program. Since the ext2 image file only contains
the superblock, block group descriptor, block and inode alloca-
tion bitmaps, and the inode table, many debugfs commands will
not function properly. Warning: no safety checks are in place,
and debugfs may fail in interesting ways if commands such as ls,
dump, etc. are tried without specifying the data_source_device
using the -d option. debugfs is a debugging tool. It has rough
edges!
-d data_source_device
Used with the -i option, specifies that data_source_device
should be used when reading blocks not found in the ext2 image
file. This includes data, directory, and indirect blocks.
-b blocksize
Forces the use of the given block size for the file system,
rather than detecting the correct block size as normal.
-s superblock
Causes the file system superblock to be read from the given
block number, instead of using the primary superblock (located
at an offset of 1024 bytes from the beginning of the filesys-
tem). If you specify the -s option, you must also provide the
blocksize of the filesystem via the -b option.
-f cmd_file
Causes debugfs to read in commands from cmd_file, and execute
them. When debugfs is finished executing those commands, it
will exit.
-R request
Causes debugfs to execute the single command request, and then
exit.
-V print the version number of debugfs and exit.
SPECIFYING FILES
Many debugfs commands take a filespec as an argument to specify an
inode (as opposed to a pathname) in the filesystem which is currently
opened by debugfs. The filespec argument may be specified in two
forms. The first form is an inode number surrounded by angle brackets,
e.g., <2>. The second form is a pathname; if the pathname is prefixed
by a forward slash (’/’), then it is interpreted relative to the root
of the filesystem which is currently opened by debugfs. If not, the
pathname is interpreted relative to the current working directory as
maintained by debugfs. This may be modified by using the debugfs com-
mand cd.
COMMANDS
This is a list of the commands which debugfs supports.
bmap filespec logical_block
Print the physical block number corresponding to the logical
block number logical_block in the inode filespec.
cat filespec
Dump the contents of the inode filespec to stdout.
cd filespec
Change the current working directory to filespec.
chroot filespec
Change the root directory to be the directory filespec.
close [-a]
Close the currently open file system. If the -a option is spec-
ified, write out any changes to the superblock and block group
descriptors to all of the backup superblocks, not just to the
master superblock.
clri file
Clear the contents of the inode file.
dump [-p] filespec out_file
Dump the contents of the inode filespec to the output file
out_file. If the -p option is given set the owner, group and
permissions information on out_file to match filespec.
dump_extents [-n] [-l] filespec
Dump the the extent tree of the inode filespec. The -n flag
will cause dump_extents to only display the interior nodes in
the extent tree. The -l flag cause dump_extents to only dis-
play the leaf nodes in the extent tree.
(Please note that the length and range of blocks for the last
extent in an interior node is an estimate by the extents library
functions, and is not stored in filesystem data structures.
Hence, the values displayed may not necessarily by accurate and
does not indicate a problem or corruption in the file system.)
expand_dir filespec
Expand the directory filespec.
feature [fs_feature] [-fs_feature] ...
Set or clear various filesystem features in the superblock.
After setting or clearing any filesystem features that were
requested, print the current state of the filesystem feature
set.
find_free_block [count [goal]]
Find the first count free blocks, starting from goal and allo-
cate it.
find_free_inode [dir [mode]]
Find a free inode and allocate it. If present, dir specifies
the inode number of the directory which the inode is to be
located. The second optional argument mode specifies the per-
missions of the new inode. (If the directory bit is set on the
mode, the allocation routine will function differently.)
freeb block [count]
Mark the block number block as not allocated. If the optional
argument count is present, then count blocks starting at block
number block will be marked as not allocated.
freei filespec
Free the inode specified by filespec.
help Print a list of commands understood by debugfs(8).
icheck block ...
Print a listing of the inodes which use the one or more blocks
specified on the command line.
imap filespec
Print the location of the inode data structure (in the inode ta-
ble) of the inode filespec.
init_filesys device blocksize
Create an ext2 file system on device with device size blocksize.
Note that this does not fully initialize all of the data struc-
tures; to do this, use the mke2fs(8) program. This is just a
call to the low-level library, which sets up the superblock and
block descriptors.
kill_file filespec
Deallocate the inode filespec and its blocks. Note that this
does not remove any directory entries (if any) to this inode.
See the rm(1) command if you wish to unlink a file.
lcd directory
Change the current working directory of the debugfs process to
directory on the native filesystem.
ln filespec dest_file
Create a link named dest_file which is a link to filespec. Note
this does not adjust the inode reference counts.
logdump [-acs] [-b
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa