Ramdisk

From ZeptoOS
Jump to navigationJump to search

Both CN Linux kernel and ION Linux kernel requires ramdisk to boot. Ramdisk images basically contain minimum Linux utilities, init scripts , configuration files, kernel modules, etc, which are required by OS boot process.

ION ramdisk is an ELF file that contains a cpio format archive of system files. Two ION ramdisk images are currently generated.

  • BGP-ION-ramdisk-for-CNL.elf
    • Default ION ramdisk for ZeptoOS
  • BGP-ION-ramdisk-for-CNK.elf
    • Use this one if you need to run IBM CNK on Compute node
    • IBM CIOD is used instead of ZOID

Our ION ramdisks are similar to IBM default ION ramdisk but we add some extra files to support our features. The extra files are located in ramdisk/ION/ramdisk-add. The build-ramdisk script from IBM BGP driver is used to create ION ramdisk. The default path of the build-ramdisk script is /bgsys/drivers/ppcfloor. The build-ramdisk script path can be configured by the main configure script.

CN ramdisk is also a gzip'ed cpio format archive of system files, but CN ramdisk is embedded into CN kernel image(BGP-CN-zImage-with-initrd.elf). CN ramdisk is created by our local ramdisk build script( ramdisk/CN/create-bgp-cn-linux-ramdisk.pl ). Both build-ramdisk and create-bgp-cn-linux-ramdisk.pl is a wrapper script of the Linux kernel's gen_init_cpio command.

How to create ramdisk images

CN kernel image, ION kernel image and ION ramdisk images are always (re-)created from prebuild objects if you type make at the top level directory (without any make target),

In case you actually need to create ION ramdisk individually (without rebuilding other images), you can do:

$ make bgp-ion-ramdisk-cnl

If you want to create CN ramdisk(technically create CN kernel image with new ramdisk contents), type:

$ make bgp-cn-linux

NOTE: ramdisk/CN/bgp-cn-ramdisk.cpio.gz is a newly built CN ramdisk.

How to modify ramdisk contents

You can customize ramdisk contents for your purpose, i.e., debugging, running your system software to BGP.


CN ramdisk

You can customize CN ramdisk by editing our CN ramdisk build script, which is ramdisk/CN/create-bgp-cn-linux-ramdisk.pl. You can add files with permission, delete files, creating device files, etc.

While we keep our CN ramdisk contents in ramdisk/CN/tree, you can add any file to the ramdisk as long as they are accessible from the script. You may be able to add login node's executables if they are a 32-bit PPC binaries and you copy all required files such as shared libraries, config files, etc.

Here is an useful example. Supposed that you need the od command in CN ramdisk. You can build the od command from source code from source code for CN ramdisk. If you want to do something quick, you can check see if login node's od command works or not.

$ file /usr/bin/od
/usr/bin/od: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), 
for GNU/Linux 2.6.4, dynamically linked (uses shared libs), for GNU/Linux 2.6.4, stripped
$ ldd /usr/bin/od
linux-vdso32.so.1 =>  (0x00100000)
libc.so.6 => /lib/ppc970/libc.so.6 (0x0fe8b000)
/lib/ld.so.1 (0xf7fe1000)

It is a 32-bit PPC executable and the current CN ramdisk has all necessary shared libraries, so you simply can use login node's od command. What you need to do is to add one command to a perl array named @cmdlists in ramdisk/CN/create-bgp-cn-linux-ramdisk.pl and type make to recreate the CN ramdisk.

$ vi ramdisk/CN/create-bgp-cn-linux-ramdisk.pl # the following line to @cmdlists 
     "file /bin/od   /usr/bin/od 0755  0  0",
$ make bgp-cn-linux

Now the CN ramdisk has /bin/od with file permission 0755, uid=0 and gid=0.

The line that you added is a gen_init_cpio command. You can also create a directory, device file, symbolick link, pipe file, socket file as well.

file <name> <location> <mode> <uid> <gid>
dir <name> <mode> <uid> <gid>
nod <name> <mode> <uid> <gid> <dev_type> <maj> <min>
slink <name> <target> <mode> <uid> <gid>
pipe <name> <mode> <uid> <gid>
sock <name> <mode> <uid> <gid>

<name>      name of the file/dir/nod/etc in the archive
<location>  location of the file in the current filesystem
<target>    link target
<mode>      mode/permissions of the file
<uid>       user id (0=root)
<gid>       group id (0=root)
<dev_type>  device type (b=block, c=character)
<maj>       major number of nod
<min>       minor number of nod

The order of the gen_init_cpio commands in @cmdlists is matter.They are interpreted and executed from top to bottom. You can't add a file to the directory that has not been created.

ION ramdisk

Unlike CN ramdisk, the range of customization is limited on ION ramdisk. You have no permission control. You can't create device nodes, etc. Currently we build the ION ramdisk using IBM build-ramdisk script by specifying add-on tree which contains our extra files.

What you can do are basically:

    • Add files
    • Overwrite files that are in the ramdisk created by build-ramdisk

Once you add files under ramdisk/ION/ramdisk-add/, they will be automatically added to the ramdisk. Here is an example to add a file(/etc/yourfile in this example) to the ION ramdisk.

$ vi ramdisk/ION/ramdisk-add/etc/yourfile
$ make bgp-ion-ramdisk-cnl

How to extract files from existing ramdisk image

If you want to extract file from existing ramdisk image, do the following steps (ION ramdisk only).

$ ./packages/tools/z-extract-cpio-from-ramdisk.sh  existingramdisk.elf  ramdisk.cpio
$ mkdir treeroot && cd treeroot
$ cpio -idv < ../ramdisk.cpio