How to modify an initrd

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search

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.


here you have all the tools you need compiled for ppc:
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.


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 (source of passwords)


for the LS Pro it is YvSInIQopeipx66t_DCdfEvfP47qeVPhNhAuSYmA4 for example.

the initrd.buffalo still is not the real 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=initrd.gz ibs=64 skip=1
gunzip initrd.gz
mkdir INITRD
mount -t ext2 -o loop initrd INITRD 

there we 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:

umount INITRD
rmdir INITRD
mv initrd.buffalo initrd.stock [backup just in case]
gzip initrd
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n initrd -d initrd.gz initrd.buffalo