It is not always necessary to rebuild a
SELF based ramdisk image if you want to modify or to extend it. Especially during development it is often eaiser to unpack it, modify it, and re-pack it again. To do so, you have to understand the internal structure of the
uRamdisk
(resp.
pRamdisk
) images files as used with the U-Boot
(old: PPCBoot) boot loader:
The
uRamdisk
image contains two parts:
- a 64 byte U-Boot header
- a (usually
gzip
compressed) ramdisk image
To modify the contents you have to extract, uncompress and mount the ramdisk image. This can be done as follows:
- Extract compressed ramdisk image (
ramdisk.gz
)
bash$ dd if=uRamdisk bs=64 skip=1 of=ramdisk.gz
21876+1 records in
21876+1 records out
- Uncompress ramdisk image (if it was a compressed one)
bash$ gunzip -v ramdisk.gz
ramdisk.gz: 66.6% -- replaced with ramdisk
- Mount ramdisk image
bash# mount -o loop ramdisk /mnt/tmp
Now you can add, remove, or modify files in the
/mnt/tmp
directory. If you are done, you can re-pack the ramdisk into a U-Boot image:
- Unmount ramdisk image:
bash# umount /mnt/tmp
- Compress ramdisk image
bash$ gzip -v9 ramdisk
ramdisk: 66.6% -- replaced with ramdisk.gz
- Create new U-Boot image (
new-uRamdisk
)
bash$ mkimage -T ramdisk -C gzip -n 'Simple Embedded Linux Framework' \
> -d ramdisk.gz new-uRamdisk
Image Name: Simple Embedded Linux Framework
Created: Sun May 4 13:23:48 2003
Image Type: PowerPC Linux RAMDisk Image (gzip compressed)
Data Size: 1400121 Bytes = 1367.31 kB = 1.34 MB
Load Address: 0x00000000
Entry Point: 0x00000000
Instead of re-packing into a U-boot ramdisk image you can of course also just extract the contents of the
SELF image and re-use it as base of a (known to be working) root filesystem.