max-boehm / qnap-utils

Utilities to unpack QNAP firmware images and QPKG files
60 stars 23 forks source link

[Feature] Option to compress the firmware properly? #3

Open ivo-gofilex opened 4 years ago

ivo-gofilex commented 4 years ago

Hi there,

Sorry for opening a feature request without your permission, but I have spent the past couple of months trying to extract and compress the firmware for the TS-469U because I would like to add the Pagekite script to the internal flash memory, so that I can reach the QNAP remotely even if the ports are not open or when for instance the RAID is broken (and thus only the internal flash is booted).

I was successful in adding the pagekite script to /usr/share/ in rootfs2.bz, but I can't seem to find a way to add something to for example the initrd, I think because I haven't been able to properly repack the initrd.boot file (the system just hangs on boot).

My question is; do you happen to know a way to properly compress the initrd.boot again?

Thanks for your hard work!

max-boehm commented 4 years ago

Hi @ivo-gofilex I‘m sorry I don‘t know that. There is also initrd.boot.cksum file which probably needs to match.

ivo-gofilex commented 4 years ago

Thanks for your response @max-boehm. I had already tried patching the cksum, which is indeed mandatory for the firmware to flash, but even though it updates fine, it simply won't boot afterwards.

galaxy4public commented 2 years ago

@ivo-gofilex , packing initrd/initramfs requires some magic/knowledge. Basically, what you need to do to create a compatible initrd/initramfs file is the following:

# cd /path/to/unpacked/initramfs
# find . -print0 | cpio --null --create --verbose --format=newc | gzip --best > /boot/custom-initramfs.cpio.gz

Hope this helps (even if it is an year later response ;) )

ivo-gofilex commented 2 years ago

@galaxy4public thank you so much for replying to me. However, I have abandoned the project not long after asking here. Later firmwares are signed and I have explored other ways to achieve close to the result I wanted.

Having said that, I really want to find out if I can make it work if I knew this earlier, so I will try it later with an older firmware :)