I try to recreate a bigger disk image file based on this one by the following steps:
# Obtain the partion table info on the original disk image file:
$ sudo parted openwrt-19.07.7-x86-64-combined-ext4.img u s p
Model: (file)
Disk /home/werner/vmware/openwrt-19.07.7-x86-64-combined-ext4.img: 558080s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 512s 33279s 32768s primary ext2 boot
2 33792s 558079s 524288s primary ext2
# Extract the partion image files:
$ dd if=openwrt-19.07.7-x86-64-combined-ext4.img of=0.img ibs=512 obs=1M skip=512 count=32768 oflag=direct,sync status=progress
$ dd if=openwrt-19.07.7-x86-64-combined-ext4.img of=1.img ibs=512 obs=1M skip=33792 count=524288 oflag=direct,sync status=progress
# Create a new empty but big disk image file with the same partition table type:
$ dd if=/dev/zero of=disk.img bs=1024k seek=1k count=0
$ sudo parted disk.img mklabel msdos
Then use gparted
to create two partitions on it with unformatted file system and activate the boot flag on the 1st partition, as shown below:
$ sudo parted disk.img u s p
Model: (file)
Disk /home/werner/vmware/disk.img: 2097152s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 2048s 206847s 204800s primary boot
2 206848s 2097151s 1890304s primary
Rewrite the partition image files onto the newly created image:
$ sudo kpartx -av disk.img
add map loop11p1 (253:2): 0 204800 linear 7:11 2048
add map loop11p2 (253:3): 0 1890304 linear 7:11 206848
$ sudo losetup --show -fP 0.img
/dev/loop12
$ sudo losetup --show -fP 1.img
/dev/loop13
$ sudo dd if=/dev/loop12 of=/dev/mapper/loop11p1 bs=1M oflag=direct,sync status=progress
16+0 records in
16+0 records out
16777216 bytes (17 MB, 16 MiB) copied, 0.993139 s, 16.9 MB/s
$ sudo dd if=/dev/loop13 of=/dev/mapper/loop11p2 bs=1M oflag=direct,sync status=progress
253755392 bytes (254 MB, 242 MiB) copied, 14 s, 18.1 MB/s
256+0 records in
256+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 14.8922 s, 18.0 MB/s
$ sudo kpartx -dv disk.img
Change the PARTUUID
info in the /boot/grub.cfg
to reflect the new value of the image file. Then convert it to vmdk format, which can be tested in a vmware workstation:
$ qemu-img convert -f raw -O vmdk disk.img disk.vmdk
But it turns out that the newly created image file failed to boot within vmware, while the vmdk image converted from the original openwrt official imaga can boot successfully.
Any hints for this problem will be highly appreciated.
Regards,
HY