这里假设分区表都是正确的,我们拿上面的文章举例子:
1 2 3 4 5 6 7 8 9 10 11 |
# fdisk -l OMP120.img Disk OMP120.img: 29.8 GiB, 31937527808 bytes, 62377984 sectors 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: 0x000d89e6 Device Boot Start End Sectors Size Id Type OMP120.img1 * 2048 1026047 1024000 500M 83 Linux OMP120.img2 1026048 59691007 58664960 28G 8e Linux LVM |
一个sectors是512k,分区表尾部规划的空间结尾是59691007,那么切除偏移是
1 |
truncate --size=$[(59691007+1)*512] OMP120.img |
[......]