use ramdisk as root file system

Trellix78 at Trellix78 at
Fri Sep 3 16:02:01 CEST 2004

Here's a step-by-step way to do an initial ramdisk:
Much of this is from memory an bits of notes.  I'm assuming that the
elfboot system is being used, along with kernel 2.4 or greater.
The way I did it is to have the boot system interrupted in the ramdisk
without ever getting to init, but it's simple to go all the way using
the full init or the busybox version.
Ok, here's how to build the ramdisk:
1. enable ramdisk and initial ramdisk support in the kernel
2. at the prompt, type (without quotes) "#>dd if=/dev/zero of=initrd bs=1k 
   that'll build an 8 megabyte ramdisk so substitute 8000 for the needed size
3. build the filesystem using: 
   "#>/sbin/mke2fs -F -m0 initrd"
4. the file can then be mounted by typing
   "#>mount -t ext2 -o loop initrd /mnt/initrd"
    Make sure /mnt/initrd exists.
5. copy all needed files to /mnt/initrd
   The next part can be done a couple of different ways.
   One way is to have a script called linuxrc (or some other) in
   the root filesystem of initrd that sets everything up and then
   drops to a shell. 
   Another way is to have init in the usual place,
   with /etc/inittab set to run a setup script, along with
   agetty to monitor the serial port.
   One other way is to use busybox's init.  You can get
   an automatic login that way by just starting a shell 
   on the console by having this in inittab:
   "ttyS0::respawn:/bin/sh".  Busybox init can also run
   without an /etc/inittab file.  It'll automatically detect
   that the console is on the serial port and put a shell there.

Now, to booting with etherboot.  Serial console support needs
to be compiled into the kernel.  I used mkelfImage from the freebios
util directory to make a combined kernel and initrd elf image.
Here's the actual command:
#> mkelfImage --kernel=<path-to-kernel> --ramdisk=<path-to-initrd> --output=<output-file-name> --command-line="root=0100 rw init=/linuxrc console=ttyS0,115200n8"

The rw is there to enable initrd to be read/write.  The init=/linuxrc should be
taken out if /sbin/init is to be used. I used the major and minor
numbers but root=/dev/ram0 can be used.  Make sure ACPI is turned off the first time around.
That should work.

More information about the coreboot mailing list