我想要实现的是安全收缩 ext2 文件系统,并确保我可以将下面的物理分区剪切/收缩到安全的最小值(不剪切文件系统块)。我已经检查了许多 HowTo-s,但仍然想询问在确定 dumpe2fs 报告的实际 ext2 使用情况时是否遗漏了某些内容。这是我的测试用例:
root@buster:/tmp# dd if=/dev/zero of=/tmp/del.img bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 0.429782 s, 2.4 GB/s
root@buster:/tmp# losetup -f --show /tmp/del.img
/dev/loop0
root@buster:/tmp# mkfs.ext2 /dev/loop0
mke2fs 1.44.5 (15-Dec-2018)
Discarding device blocks: done
Creating filesystem with 256000 4k blocks and 64000 inodes
Filesystem UUID: 217a401a-a001-46e8-8ca2-9602e927e2aa
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
root@buster:/tmp# mount /dev/loop0 /mnt/EXT2/
root@buster:/tmp# dumpe2fs /dev/loop0 | grep -E '(Block count|Block size)'
dumpe2fs 1.44.5 (15-Dec-2018)
Block count: 256000
Block size: 4096
据我所知,文件系统使用 1048576000 字节(256000*4096)
root@buster:/tmp# cp -pr /opt/Scripts/ /mnt/EXT2/
root@buster:/tmp# umount /mnt/EXT2
root@buster:/tmp# e2fsck -f /dev/loop0
e2fsck 1.44.5 (15-Dec-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/loop0: 457/64000 files (6.6% non-contiguous), 67098/256000 blocks
root@buster:/tmp# resize2fs -M /dev/loop0
resize2fs 1.44.5 (15-Dec-2018)
Resizing the filesystem on /dev/loop0 to 63894 (4k) blocks.
The filesystem on /dev/loop0 is now 63894 (4k) blocks long.
root@buster:/tmp# dumpe2fs /dev/loop0 | grep -E '(Block count|Block size)'
dumpe2fs 1.44.5 (15-Dec-2018)
Block count: 63894
Block size: 4096
收缩后,文件系统似乎使用 261709824 字节 (63894*4096) 我可以假设在 100% 的情况下,我也可以安全地将底层物理分区剪切/收缩到这些 261709824 字节吗?难道某些文件系统块在物理上仍然位于这 261709824 字节之后?