![使用 resize2fs 缩小文件系统时如何计算正确的分区大小](https://linux22.com/image/182543/%E4%BD%BF%E7%94%A8%20resize2fs%20%E7%BC%A9%E5%B0%8F%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E6%97%B6%E5%A6%82%E4%BD%95%E8%AE%A1%E7%AE%97%E6%AD%A3%E7%A1%AE%E7%9A%84%E5%88%86%E5%8C%BA%E5%A4%A7%E5%B0%8F.png)
在 GNU/Linux 上使用 resize2fs 缩小只读文件系统后,如何确定缩小的文件系统的正确分区条目?
远程主机初始分区方案:
Disk /dev/sda: 1,8 TiB, 1999844147200 bytes, 3905945600 sectors
Disk model: xxx
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: 0xf79ea8df
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 487423 485376 237M 83 Linux
/dev/sda2 487424 3841943551 3841456128 1,8T 83 Linux
/dev/sda3 3841943552 3883886591 41943040 20G 83 Linux
Command (m for help):
发出调整大小命令:
[root@home ~]# resize2fs /dev/sda2 200G
resize2fs 1.44.5 (15-Dec-2018)
Resizing the filesystem on /dev/sda2 to 52428800 (4k) blocks.
The filesystem on /dev/sda2 is now 52428800 (4k) blocks long.
当以 487424 作为起始扇区、大小为 8 乘以 52428800 * 512 字节块的 /dev/sda2 重新创建分区条目时,创建的分区是否确实覆盖了整个收缩的文件系统,如何证明这一点?
Disk /dev/sda: 1,8 TiB, 1999844147200 bytes, 3905945600 sectors
Disk model: xxx
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: 0xf79ea8df
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 487423 485376 237M 83 Linux
/dev/sda2 487424 419917824 419430401 200G 83 Linux
/dev/sda3 3841943552 3883886591 41943040 20G 83 Linux
Command (m for help):