Notes

Programs Speedtouch Project Snoopy Project eciadsl Project Sabine's website The bread recipe Source Mage BeOS LinAC My resume Notes Donation
Programs
Speedtouch Project
Snoopy Project
eciadsl Project
Sabine's website
The bread recipe
Source Mage
BeOS
LinAC
My resume
Notes
Donation
en fr

Source Mage ISO boot design

BenoƮt PAPILLAULT, 2004/10/05

Presentation

We would like to build a bootable CD-ROM (on x86 and ppc platforms at least). To do so, we will use syslinux (x86) and yaboot (ppc). This both tools allow to load a linux kernel as well as an initial ramdisk. This article will show you the goals of this CD-ROM (what it could be used for) and a general description of a way to implement it, along with some explanations about technical points.

Goals

Our three goals are:

  1. First goal is to use the CD-ROM to install a SourceMage distribution. This mean that the CD-ROM will be used as a root filesystem.
  2. The second goal is to use the CD-ROM as a rescue CD-ROM to boot an already installed distribution on the hard drive. The location of this distribution will be given by the root= command line parameter.
  3. The third goal is a variant of the second one. In some cases, it is possible that the kernel used need additional modules to be able to mount the root filesystem. To do so, we will use an initial ramdisk.

How an initial ramdisk works

How an initial ramdisk works is quite simple, but some important details need to be described. First of all, a ramdisk is a file (either compressed with gzip or not) that contains a filesystem (ext3, ...). Advantage of using an initial ramdisk is that it is loaded in memory directly by the bootloader and not by the linux kernel. Such file can be used in two ways:
  • If the boot parameters have root=/dev/ram0.

    In this case, the ramdisk will be used exactly as a root filesystem and the executable /sbin/init present in this ramdisk will be launched with a process id (PID) of 1. This property allows to mount another filesytem, and to switch to this new filesystem as if the new filesystem was the root filesystem.

      mount /dev/hda2 /mnt
      cd /mnt
      pivot_root . initrd
      # mount /dev if needed
      exec chroot . /sbin/init "$@" < /dev/console > /dev/console 2>&1
    
  • If the boot parameters does not have root=/dev/ram0.

    In this case, the ramdisk is temporarily used as the root filesystem and the /linuxrc executable present in the ramdisk will be launched. Its process id (PID) will not be 1. When the /linuxrc execution ends, the real root filesystem is mounted and /sbin/init is launched.

Implementation

To implement our goals, the bootloader will have three entries:

  • install

    This is our first goal. The ramdisk will be loaded with root=/dev/ram0. If we had used devfs, we could have used root=/dev/cdroms/cdrom0. But this will not work on a system which has several CD-ROM drives because only the first one will be used. Thus, the ramdisk will deal with scanning all available CD-ROM drives and detecting the SourceMage CD-ROM with the help of /etc/sourcemage_version existing on it.

  • linux root=/dev/hda1

    This is our second goal. No ramdisk is loaded. The user must add a root= on the boot command line.

  • initrd root=/dev/hda1

    This is our third goal. A ramdisk is used only to load needed modules to access the root filesystem. As the second entry, the user must add a root= on the boot command line.

Documentations

Here are some sources of informations to go further:
Valid HTML 4.01! Valid CSS!
Benoit PAPILLAULT