How to modify an initrd
From NAS-Central Buffalo - The Linkstation Wiki
Mindbender (Talk | contribs) (→ppc-based boxes) |
m |
||
| Line 1: | Line 1: | ||
| + | {{Articles|Hacking|LSPro|KuroboxPro|LS1|HG|Kurobox}} | ||
This pages describes how to modify the initrds aka ramdisks of the linkstations/terastations/kuroboxes. | This pages describes how to modify the initrds aka ramdisks of the linkstations/terastations/kuroboxes. | ||
Revision as of 10:34, 31 August 2007
This pages describes how to modify the initrds aka ramdisks of the linkstations/terastations/kuroboxes.
ppc-based boxes
BEWARE: this info is for the original firmimg.bins which were burned to flash. If you flash uboot as a replacement for the stock bootloader you can place the initrd + kernel also to /boot/ instead.
the kernel and the initrd both are inside the firmimg.bin-files which are inside the firmware-update-packages.
so we need to extract both from the firmimg.bin first. some smart japanese guys wrote a tool called firmimgtool.
sourcecode:
http://downloads.linkstationwiki.net/ALL_LS_KB_PPC/DevelopmentTools/Flash/Utilities/firmimgtool.c
here you have all the tools you need compiled for ppc:
http://downloads.linkstationwiki.net/ALL_LS_KB_PPC/DevelopmentTools/Flash/Utilities/flash_dev_tools_ppc.tar.gz
Usage: ./firmimgtool [-icmkr] <firmimg_filename>
-i : show firmimg_file information
-c : cut out from firmimg_file
-m : merge into firmimg_file
-k <filename> : kernel image filename
-r <filename> : ramdisk image filename
-f <filename> : copy headers from file
-h : show this help message
Now we extract kernel.gz and the initrd.gz:
./firmimgtool -c -k kernel.gz -r initrd.gz firmimg.bin
afterwards you should have a kernel.gz and a initrd.gz in the same folder.
unpack initrd.gz
gunzip initrd.gz
and loop mount it
mkdir INITRD mount -o loop initrd INITRD
now you can change everything you want by changing it in the folder INITRD....if you unmount it all changes are saved.
After applying the changes you need to reassemble the firmimg.bin... this works that way:
umount INITRD gzip initrd ./firmimgtool -m -k kernel.gz -r initrd.gz firmimg.bin -f firmimg.bin.103
and voila, the new firmimg.bin is ready for flashing.
mipsel-based
the firmimg.bin is encrypted unfortunately. LNI knows how to do this, but he hasn`t published this.
arm9-based boxes
All these boxes feature UBoot as the stock bootloader. The uboot bootloader loads initrd.buffalo from /dev/sda1.
The initrd.buffalo is named initrd.img in the firmware-update-packages. initrd.img is (like the hddrootfs) a password protected zip-file.
just unzip it and supply the right password.
unzip initrd.img Archive: initrd.img [initrd.img] initrd.buffalo password:
try one of these
1NIf_2yUOlRDpYZUVNqboRpMBoZwT4PzoUvOPUp6l aAhvlM1Yp7_2VSm6BhgkmTOrCN1JyE0C5Q6cB3oBB YvSInIQopeipx66t_DCdfEvfP47qeVPhNhAuSYmA4 IeY8omJwGlGkIbJm2FH_MV4fLsXE8ieu0gNYwE6Ty
for the LS Pro it is YvSInIQopeipx66t_DCdfEvfP47qeVPhNhAuSYmA4 for example.
the initrd.buffalo still is not the real initrd....as it is booted from uboot is has a 64 byte long header. We use dd to get rid of the header, unzip the resulting image.gz and loop-mount the file
dd if=initrd.buffalo of=image.gz bs=1 skip=64 gunzip image.gz mkdir INITRD mount -t ext2 -o loop image INITRD
there we are...in the folder INITRD you now have loop-mounted the initrd...make your changes as you want.
after making your changes do do this to get the initrd in a bootable condition again:
HELP NEEDED HERE ? mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n initrd -d initrd.gz initrd.buffalo ?

