Resize2fs 收缩操作会在文件系统中留下可用空间吗?

Resize2fs 收缩操作会在文件系统中留下可用空间吗?

我正在尝试将文件系统映像缩小到尽可能小的大小。我同意 resize2fs 将保留的文件系统块保留在适当的位置,但在收缩操作后,它会在文件系统中留下大约 400Mb 的可用空间。

这些是我正在执行的步骤:

aj@pop-os:~/disk_images$ sudo losetup -fP --show mcard.img 
/dev/loop0

aj@pop-os:~/disk_images$ sudo zerofree -v /dev/loop0p1
112082/2671282/3665210

aj@pop-os:~/disk_images$ sudo e2fsck -f /dev/loop0p1
e2fsck 1.46.5 (30-Dec-2021)
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/loop0p1: 191007/917504 files (0.3% non-contiguous), 993928/3665210 blocks

aj@pop-os:~/disk_images$ sudo resize2fs -Mp /dev/loop0p1
resize2fs 1.46.5 (30-Dec-2021)
Resizing the filesystem on /dev/loop0p1 to 1115084 (4k) blocks.
Begin pass 2 (max = 3444)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 112)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/loop0p1 is now 1115084 (4k) blocks long.

一切似乎都工作正常,并且确实将文件系统从 16Gb 缩小到 4.1Gb。但是,它确实在文件系统上留下了可用空间:

aj@pop-os:~/disk_images$ sudo mount /dev/loop0p1 xmnt/
aj@pop-os:~/disk_images$ df -h xmnt/
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0p1    4.1G  3.5G  434M  90% /home/aj/disk_images/xmnt

aj@pop-os:~/disk_images$ sudo umount xmnt/
aj@pop-os:~/disk_images$ sudo dumpe2fs -h /dev/loop0p1
(Output shortened for readability)
Block count:              1115084
Reserved block count:     47712
Free blocks:              162785
Block size:               4096

如您所见,收缩文件系统后,该df实用程序和dumpe2fs显示文件系统映像中剩余的可用空间。

这是为什么?如何让 resize2fs 实际减小文件系统大小,以便除了保留块之外没有可用空间?

相关内容