gzipembedded-linuxinitrd

Reversing the effects of mkimage to get an original gzipped file back


We develop for a specific embedded device at our company, and part of that is making initial root disks that get loaded onto the devices over ethernet via netboot. We've experienced some problems, and as a result, the original folder with the contents of the initial root disks was lost along with its backups, but we do still have the initrd images, that have been created by gzipping the contents of a ramdisk that's been mounted as a local loop device, and then running mkimage on the gzipped file. Is there any way to undo the effects of mkimage and obtain the original gzipped content so that we can recover the original images ?


Solution

  • Are you talking about u-boot's mkimage? If so, you can recover the original by removing the first 64 bytes.

    dd if=<image> of=<recovered file> bs=64 skip=1