Difference between revisions of "How to modify an initrd"

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search
(added new page)
 
m (Page also valid for LS Live)
 
(10 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 +
{{Articles|Hacking|LSPro|LSLive|KuroboxPro|LS1|HG|Kurobox|LSQuad}}
 
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.
  
 
== ppc-based boxes ==
 
== ppc-based boxes ==
BEWARE: this info is for the original firmimg.bins which were burned to flash. If you flash uboot only you can place the initrd + kernel also to /boot/ instead.
+
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.
 
the kernel and the initrd both are inside the firmimg.bin-files which are inside the firmware-update-packages.
Line 9: Line 10:
  
 
sourcecode:  
 
sourcecode:  
  http://downloads.linkstationwiki.net/ALL_LS_KB_PPC/DevelopmentTools/Flash/Utilities/firmimgtool.c
+
  http://downloads.nas-central.org/ALL_LS_KB_PPC/DevelopmentTools/Flash/Utilities/firmimgtool.c
  
 
here you have all the tools you need compiled for ppc:
 
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
+
  http://downloads.nas-central.org/ALL_LS_KB_PPC/DevelopmentTools/Flash/Utilities/flash_dev_tools_ppc.tar.gz
  
 
  Usage: ./firmimgtool [-icmkr] <firmimg_filename>
 
  Usage: ./firmimgtool [-icmkr] <firmimg_filename>
Line 57: Line 58:
 
  [initrd.img] initrd.buffalo password:
 
  [initrd.img] initrd.buffalo password:
  
try one of these
+
try one of these ([http://www.terastation.org/wiki/Firmware_password source of passwords])
 
  1NIf_2yUOlRDpYZUVNqboRpMBoZwT4PzoUvOPUp6l
 
  1NIf_2yUOlRDpYZUVNqboRpMBoZwT4PzoUvOPUp6l
 
  aAhvlM1Yp7_2VSm6BhgkmTOrCN1JyE0C5Q6cB3oBB
 
  aAhvlM1Yp7_2VSm6BhgkmTOrCN1JyE0C5Q6cB3oBB
Line 68: Line 69:
 
We use dd to get rid of the header, unzip the resulting image.gz and loop-mount the file
 
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
+
  dd if=initrd.buffalo of=initrd.gz ibs=64 skip=1
  gunzip image.gz
+
  gunzip initrd.gz
 
  mkdir INITRD
 
  mkdir INITRD
  mount -t ext2 -o loop image INITRD  
+
  mount -t ext2 -o loop initrd INITRD  
  
 
there we are...in the folder INITRD you now have loop-mounted the initrd...make your changes as you want.
 
there we are...in the folder INITRD you now have loop-mounted the initrd...make your changes as you want.
Line 77: Line 78:
 
after making your changes do do this to get the initrd in a bootable condition again:
 
after making your changes do do this to get the initrd in a bootable condition again:
 
   
 
   
  HELP NEEDED HERE
+
  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
 
  mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n initrd -d initrd.gz initrd.buffalo
?
+
 
 +
== Links ==
 +
* [[Examine ARM9 Firmware without Updating]]

Latest revision as of 19:37, 20 April 2010

This pages describes how to modify the initrds aka ramdisks of the linkstations/terastations/kuroboxes.

Contents

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.nas-central.org/ALL_LS_KB_PPC/DevelopmentTools/Flash/Utilities/firmimgtool.c

here you have all the tools you need compiled for ppc:

http://downloads.nas-central.org/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 (source of passwords)

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=initrd.gz ibs=64 skip=1
gunzip initrd.gz
mkdir INITRD
mount -t ext2 -o loop initrd 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:

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

Links