有关获取磁盘映像并缩小根(仿生)文件系统分区,然后截断映像以删除成为可用空间的部分的大量信息。就像 https://softwarebakery.com//shrinking-images-on-linux
所以基本上有三个步骤。使用 resize2fs 缩小分区上的文件系统,然后也减小分区的大小。最后删除图像文件中现在未使用的空间。
这是我遇到问题的第三部分。每次我尝试 dd 或 truncate 时,映像的所有分区都会被删除,就好像映像文件中的 GPT 分区表已被丢弃一样。
这是原始图像
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk rock64-base.img: 30310400 sectors, 14.5 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 159DCEDE-DBEA-4657-96D9-2CE178A96B7E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable …
Run Code Online (Sandbox Code Playgroud)