boot in recovery from fastboot, once in twrp enter adb shell, or use -> Advanced -> Terminal
fastboot boot recovery.img
be careful with
dd especially double check partition name and partition size.
/etc/recovery.fstab there might be just a symlink but no worry you can use it
dd will targeting the real partition.
ls -l /dev/block/bootdevice/by-name/system
dd if=/external_sd/system.img of=/dev/block/mmcblk0p99
if the file size is bigger than partition size it is strongly recommended to add parameters block size and count to limit the write process to maximum partition size, otherwise your cache and userdata partition may be destroyed.
beware files bigger than 4 GiB can not copied to MicroSD Card, so instead adb push
adb push system.img /dev/block/mmcblk0p99
How can I view the Android internal partition table?
if you are not sure about your system.img is sparsed image or LZ compressed, you can check the header for file system type / partition magic
ext4: 0xEF53 at offset 0x438
f2fs: 0xF2F52010 at offset 0x400
hexdump -C -n1088 system.img | grep 53.ef
hexdump -C -n1032 system.img | grep 10.20.f5.f2
if one of these magic is found the image can be loop mounted for testing, otherwise you need to convert file with
adbto latest version on your laptop. Older versions cannot handle big files