e2fsprogs - debugfs

前言

debugfs是e2fsprogs安装后的工具,这个工具的参数好多,而且是交互式输入命令,不是带参数执行完就了事。

实验

先用fdisk确定要操作的磁盘

root@localhost:/home/e2_install/sbin# fdisk -l

Disk /dev/sda: 120 GiB, 128849018880 bytes, 251658240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfed8ebe5

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048 247463935 247461888  118G 83 Linux
/dev/sda2       247465982 251656191   4190210    2G  5 Extended
/dev/sda5       247465984 251656191   4190208    2G 82 Linux swap / Solaris

Disk /dev/sdb: 30.1 MiB, 31555584 bytes, 61632 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2dac66d5

Device     Boot Start   End Sectors  Size Id Type
/dev/sdb1        2048 61631   59584 29.1M 83 Linux

能看到自己的实验小U盘为 /dev/sdb1

对选定磁盘使用debugfs

root@localhost:/home/e2_install/sbin# debugfs /dev/sdb1
debugfs 1.45.0 (6-Mar-2019)
debugfs:  

看看帮助

带硬盘全路径启动后,进入的式交互式UI. 这时不看帮助就不知道咋弄了。
平直觉,输入一个help, 回车,我真机智:)
帮助出来后,如果显示不完,按下回车不放,让帮助显示完。

debugfs:  help
Available debugfs requests:

show_debugfs_params, params
                         Show debugfs parameters
open_filesys, open       Open a filesystem
close_filesys, close     Close the filesystem
freefrag, e2freefrag     Report free space fragmentation
feature, features        Set/print superblock features
dirty_filesys, dirty     Mark the filesystem as dirty
init_filesys             Initialize a filesystem (DESTROYS DATA)
show_super_stats, stats  Show superblock statistics
ncheck                   Do inode->name translation
icheck                   Do block->inode translation
change_root_directory, chroot
                         Change root directory
change_working_directory, cd
                         Change working directory
list_directory, ls       List directory
show_inode_info, stat    Show inode information 
dump_extents, extents, ex
                         Dump extents information 
blocks                   Dump blocks used by an inode 
filefrag                 Report fragmentation information for an inode
link, ln                 Create directory link
unlink                   Delete a directory link
mkdir                    Create a directory
rmdir                    Remove a directory
rm                       Remove a file (unlink and kill_file, if appropriate)
kill_file                Deallocate an inode and its blocks
copy_inode               Copy the inode structure
clri                     Clear an inode's contents
freei                    Clear an inode's in-use flag
seti                     Set an inode's in-use flag
testi                    Test an inode's in-use flag
freeb                    Clear a block's in-use flag
setb                     Set a block's in-use flag
testb                    Test a block's in-use flag
modify_inode, mi         Modify an inode by structure
find_free_block, ffb     Find free block(s)
find_free_inode, ffi     Find free inode(s)
print_working_directory, pwd
                         Print current working directory
expand_dir, expand       Expand directory
mknod                    Create a special file
list_deleted_inodes, lsdel
                         List deleted inodes
undelete, undel          Undelete file
write                    Copy a file from your native filesystem
dump_inode, dump         Dump an inode out to a file
cat                      Dump an inode out to stdout
lcd                      Change the current directory on your native filesystem
rdump                    Recursively dump a directory to the native filesystem
set_super_value, ssv     Set superblock value
set_inode_field, sif     Set inode field
set_block_group, set_bg  Set block group descriptor field
logdump                  Dump the contents of the journal
htree_dump, htree        Dump a hash-indexed directory
dx_hash, hash            Calculate the directory hash of a filename
dirsearch                Search a directory for a particular filename
bmap                     Calculate the logical->physical block mapping for an inode
fallocate                Allocate uninitialized blocks to an inode
punch, truncate          Punch (or truncate) blocks from an inode by deallocating them
symlink                  Create a symbolic link
imap                     Calculate the location of an inode
dump_unused              Dump unused blocks
set_current_time         Set current time to use when setting filesystem fields
supported_features       Print features supported by this version of e2fsprogs
dump_mmp                 Dump MMP information
set_mmp_value, smmp      Set MMP value
extent_open, eo          Open inode for extent manipulation
zap_block, zap           Zap block: fill with 0, pattern, flip bits etc.
block_dump, bdump, bd    Dump contents of a block
ea_list                  List extended attributes of an inode
ea_get                   Get an extended attribute of an inode
ea_set                   Set an extended attribute of an inode
ea_rm                    Remove an extended attribute of an inode
list_quota, lq           List quota
get_quota, gq            Get quota
inode_dump, idump, id    Dump the inode structure in hex
journal_open, jo         Open the journal
journal_close, jc        Close the journal
journal_write, jw        Write a transaction to the journal
journal_run, jr          Recover the journal
help                     Display info on command or topic.
list_requests, lr, ?     List available commands.
quit, q                  Leave the subsystem.

实验命令的用法

关闭设备

debugfs:  close

打开设备

open /dev/sdb1

查看磁盘碎片统计

debugfs:  freefrag
Device: /dev/sdb1
Blocksize: 1024 bytes
Total blocks: 29792
Free blocks: 27454 (92.2%)

Min. free extent: 4862 KB 
Max. free extent: 7839 KB
Avg. free extent: 6863 KB
Num. free extent: 4

HISTOGRAM OF FREE EXTENT SIZES:
Extent Size Range :  Free extents   Free Blocks  Percent
    4M...    8M-  :             4         27454  100.00%
debugfs:  

打印超级块的特性

debugfs:  feature
Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super

显示超级块统计信息

debugfs:  stats
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          085d84cc-e885-46de-8237-3391bdd37fbc
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype sparse_super
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              7456
Block count:              29792
Reserved block count:     1489
Free blocks:              27454
Free inodes:              7445
First block:              1
Block size:               1024
Fragment size:            1024
Reserved GDT blocks:      116
Blocks per group:         8192
Fragments per group:      8192
Inodes per group:         1864
Inode blocks per group:   233
Filesystem created:       Wed Mar  6 18:12:36 2019
Last mount time:          n/a
Last write time:          Wed Mar  6 18:12:36 2019
Mount count:              0
Maximum mount count:      -1
Last checked:             Wed Mar  6 18:12:36 2019
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      b0cb4cb3-8838-4dd5-a5a6-d575f4973128
Journal backup:           inode blocks
Directories:              2
 Group  0: block bitmap at 119, inode bitmap at 120, inode table at 121
           7825 free blocks, 1853 free inodes, 2 used directories
 Group  1: block bitmap at 8311, inode bitmap at 8312, inode table at 8313
           7839 free blocks, 1864 free inodes, 0 used directories
 Group  2: block bitmap at 16385, inode bitmap at 16386, inode table at 16387
           6928 free blocks, 1864 free inodes, 0 used directories
 Group  3: block bitmap at 24695, inode bitmap at 24696, inode table at 24697
           4862 free blocks, 1864 free inodes, 0 used directories

当显示END时,按q退出,和在man中的退出是一样的。

猜你喜欢

转载自blog.csdn.net/LostSpeed/article/details/88398832
今日推荐