前言
e2fsprogs是一个开源库,可以读写ext2/ext3/ext4磁盘。
e2fsprogs提供了工具(可执行文件),库(可以包含到自己的工程干活)。
想先学习下工程的编译,工程安装了什么应用程序,每个应用程序都是干啥的。
实验
开源工程的下载点 https://sourceforge.net/projects/e2fsprogs/
当前版本为 e2fsprogs-1.45.0.tar.gz
编译
上传到debian9
tar -xzvf ./e2fsprogs-1.45.0.tar.gz
cd e2fsprogs-1.45.0
mkdir ./build
cd ./build
# 用来看man
# ../configure
# 如果要看安装后的文件
../configure --prefix=/home/e2_install/
make
make check
make install > /home/dev/e2fsprogs_install.log
看看装了哪些工具
从/home/dev/e2fsprogs_install.log中可以看出来,到底向系统中安装了啥
root@localhost:/home/e2_install/bin# pwd
/home/e2_install/bin
root@localhost:/home/e2_install/bin# ls -alp
total 204
drwxr-xr-x 2 root root 4096 Mar 11 15:35 ./
drwxr-xr-x 8 root root 4096 Mar 11 15:34 ../
-rwxr-xr-x 1 root root 71768 Mar 11 15:35 chattr
-rwxr-xr-x 1 root root 1354 Mar 11 15:35 compile_et
-rwxr-xr-x 1 root root 63160 Mar 11 15:35 lsattr
-rwxr-xr-x 1 root root 1114 Mar 11 15:35 mk_cmds
-rwxr-xr-x 1 root root 52864 Mar 11 15:35 uuidgen
chattr
chattr - change file attributes on a Linux file system
compile_et
compile_et - error table compiler
lsattr
lsattr - list file attributes on a Linux second extended file system
mk_cmds
mk_cmds - error table compiler
uuidgen
uuidgen - command-line utility to create a new UUID value
root@localhost:/home/e2_install/bin# ./uuidgen
0d0e0a9e-6ad2-4705-bf59-28cc123c7819
root@localhost:/home/e2_install/sbin# pwd
/home/e2_install/sbin
root@localhost:/home/e2_install/sbin# ls -alp
total 38348
drwxr-xr-x 2 root root 4096 Mar 11 15:35 ./
drwxr-xr-x 8 root root 4096 Mar 11 15:34 ../
-rwxr-xr-x 1 root root 1133616 Mar 11 15:35 badblocks
-rwxr-xr-x 1 root root 224440 Mar 11 15:35 blkid
-rwxr-xr-x 1 root root 2556448 Mar 11 15:35 debugfs
-rwxr-xr-x 2 root root 1400768 Mar 11 15:35 dumpe2fs
-rwxr-xr-x 1 root root 1125880 Mar 11 15:35 e2freefrag
-rwxr-xr-x 4 root root 3017992 Mar 11 15:35 e2fsck
-rwxr-xr-x 1 root root 1406040 Mar 11 15:35 e2image
-rwxr-xr-x 3 root root 1846760 Mar 11 15:35 e2label
-rwxr-xr-x 2 root root 1400768 Mar 11 15:35 e2mmpstatus
-rwxr-xr-x 1 root root 6818 Mar 11 15:35 e2scrub
-rwxr-xr-x 1 root root 4139 Mar 11 15:35 e2scrub_all
-rwxr-xr-x 1 root root 1169152 Mar 11 15:35 e2undo
-rwxr-xr-x 1 root root 73376 Mar 11 15:35 e4crypt
-rwxr-xr-x 1 root root 1156416 Mar 11 15:35 e4defrag
-rwxr-xr-x 1 root root 43120 Mar 11 15:35 filefrag
-rwxr-xr-x 3 root root 1846760 Mar 11 15:35 findfs
-rwxr-xr-x 1 root root 258936 Mar 11 15:35 fsck
-rwxr-xr-x 4 root root 3017992 Mar 11 15:35 fsck.ext2
-rwxr-xr-x 4 root root 3017992 Mar 11 15:35 fsck.ext3
-rwxr-xr-x 4 root root 3017992 Mar 11 15:35 fsck.ext4
-rwxr-xr-x 1 root root 26112 Mar 11 15:35 logsave
-rwxr-xr-x 4 root root 2012000 Mar 11 15:35 mke2fs
-rwxr-xr-x 4 root root 2012000 Mar 11 15:35 mkfs.ext2
-rwxr-xr-x 4 root root 2012000 Mar 11 15:35 mkfs.ext3
-rwxr-xr-x 4 root root 2012000 Mar 11 15:35 mkfs.ext4
-rwxr-xr-x 1 root root 15632 Mar 11 15:35 mklost+found
-rwxr-xr-x 1 root root 1474328 Mar 11 15:35 resize2fs
-rwxr-xr-x 3 root root 1846760 Mar 11 15:35 tune2fs
-rwxr-xr-x 1 root root 77672 Mar 11 15:35 uuidd
badblocks
badblocks - search a device for bad blocks
基础用法
root@localhost:/home/e2_install/sbin# badblocks /dev/sdb1 -v
Checking blocks 0 to 29791
Checking for bad blocks (read-only test): done
Pass completed, 0 bad blocks found. (0/0/0 errors)
blkid
blkid - command-line utility to locate/print block device attributes
基础用法
root@localhost:/home/e2_install/sbin# blkid
/dev/sda1: UUID="4ecc9964-8fe6-4055-81f9-30534f38b329" TYPE="ext4"
/dev/sda5: UUID="a1b7d171-a9e6-4adf-9675-648af528a3c1" TYPE="swap"
/dev/sdb1: UUID="085d84cc-e885-46de-8237-3391bdd37fbc" SEC_TYPE="ext2" TYPE="ext3"
debugfs
debugfs - ext2/ext3/ext4 file system debugger
dumpe2fs
dumpe2fs - dump ext2/ext3/ext4 filesystem information
e2freefrag
e2freefrag - report free space fragmentation information
e2fsck, fsck.ext2, fsck.ext3,fsck.ext4
e2fsck - check a Linux ext2/ext3/ext4 file system
root@localhost:/home/dev/e2fsprogs-1.45.0/build# e2fsck /dev/sdc1
e2fsck 1.45.0 (6-Mar-2019)
/dev/sdc1: clean, 11/7456 files, 2338/29792 blocks
e2image
e2image - Save critical ext2/ext3/ext4 filesystem metadata to a file
e2label
e2label - Change the label on an ext2/ext3/ext4 filesystem
e2mmpstatus
e2mmpstatus - Check MMP status of an ext4 filesystem
e2scrub
e2scrub - check the contents of a mounted ext[234] filesystem
e2scrub_all
e2scrub_all - check all mounted ext[234] filesystems for errors.
e2undo
e2undo - Replay an undo log for an ext2/ext3/ext4 filesystem
e4crypt
e4crypt - ext4 filesystem encryption utility
e4defrag
e4defrag - online defragmenter for ext4 filesystem
filefrag
filefrag - report on file fragmentation
findfs
findfs - Find a filesystem by label or UUID
fsck
fsck - check and repair a Linux file system
logsave
logsave - save the output of a command in a logfile
mke2fs,mkfs.ext2,mkfs.ext3,mkfs.ext4
mke2fs - create an ext2/ext3/ext4 filesystem
mklost+found
mklost+found - create a lost+found directory on a mounted Linux second extended file system
resize2fs
resize2fs - ext2/ext3/ext4 file system resizer
tune2fs
tune2fs - adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
uuidd
uuidd - UUID generation daemon