[English] [Japanese]

Linux CD-ROM Game System

 
  YAMAMORI Takenori <yamamori@kt.rim.or.jp>

§ How do we make it ?

¶ Mechanism of booting

We have to well understand the mechanism of booting Linux in order to make this CD-ROM game system. At first I show the following that is a flowchart of the system start after the power supply switched on. It is a usual Linux system installed in a hard drive.

· The process to start Linux after being switched on
(in case of usual Linux installed in a hard drive)
  +--------------------+
  |  Power supply ON   |
  +--------------------+
            |
  +--------------------+
  |   PC BIOS starts   |
  +--------------------+
            |
  +---------------------------------------------------+
  | BIOS looks for a bootable media according to the  |
  | setting and loads a program(=LILO) written on MBR |
  | of a hard drive, and then LILO gains control.     |
  +---------------------------------------------------+
            |
  +---------------------------------------------------------------+
  | LILO loads a kernel(vmlinuz) and an initial RAM disk          |
  | (initrd)(*Note 1) by BIOS, and then the kernel gains control. |
  +---------------------------------------------------------------+
            |
            |  (BIOS is no longer used from now on)
            |
  +------------------------------------------+
  | The kernel expands initrd and mounts it  |
  | as a temporary root file system.         |
  +------------------------------------------+
            |
  +----------------------------------------------------------------------+
  | If an executable /linuxrc exists in the initrd,                      |
  | the kernel executes it(*Note 2).                                     |
  | Usually, /linuxrc is a shell script, which does necessary processing |
  | before mounting a real root file system.                             |
  | By the system that use SCSI hard drive as a real root file system, a |
  | SCSI module is loaded by an insmod command described in the /linuxrc.|
  +----------------------------------------------------------------------+
            |
  +--------------------------------------------------------------------+
  | After the /linuxrc is finished, the kernel mounts a real root file |
  | system which may be /dev/hda1 or /dev/sda1, for example(*Note 3),  |
  | and then executes sbin-init on the real root file system.          |
  +--------------------------------------------------------------------+
            |
  +----------------------------------------------+ <- In Vine 2.0, a message of
  | At first, init executes /etc/rc.d/rc.sysinit |   "Welcome to Vine Linux"
  | according to a description of /etc/inittab.  |   is displayed by a color
  +----------------------------------------------+   in execution of rc.sysinit.
            |
  +---------------------------------------+
  | Next, init executes /etc/rc.d/rc with |
  | a default run level as an argument.   |
  +---------------------------------------+
            |
  +----------------------------------------------------------------+
  | If it is run level 3, for example, /etc/rc.d/rc executes       |
  | shell scripts like SnnXXXX(nn=number) under /etc/rc.d/rc3.d    |
  | directory in order of S00XXXX to S99XXXX with a start argument.|
  +----------------------------------------------------------------+
            |
  +-----------------------------------------------------------------------+
  | According to a description of /etc/inittab, only mingetty(CUI login)  |
  | is activated in case of run level 3, or xdm(GUI login) is activated   |
  | moreover in case of run level 5, and then it becomes login wait state.|
  +-----------------------------------------------------------------------+

* Note 1:
In a system which has no SCSI but IDE hard drive, initrd is not loaded generally because Linux has been installed with the state not using initrd.
* Note 2:
When a device of real root file system specified by the LILO or other boot loader is initrd itself, /linuxrc is not executed.
* Note 3:
If kernel restructuring, making of initrd or installation of LILO is not appropriate, the system may be hanged up with an error message "Kernel panic: VFS: Unable to mount root fs ..." It is a cause that the system fails in a mount of "/" in this stage.

In this CD-ROM game system, the flowchart of the system start becomes like the following.

· The process to start Linux after being switched on
(In case of the CD-ROM game system)
  +--------------------+
  |  Power supply ON   |
  +--------------------+
            |
  +--------------------+
  |   PC BIOS starts   |
  +--------------------+
            |
  +-------------------------------------------------------------------+
  | BIOS looks for a bootable media according to the setting and      |
  | finds El Torito bootable CD-ROM with a floppy disk emulation mode.|
  +-------------------------------------------------------------------+
            |
  +----------------------------------------------------------------+
  | BIOS loads a program(=LILO) from a boot sector of the emulated |
  | floppy disk image in the CD-ROM, and then LILO gains control.  |
  +----------------------------------------------------------------+
            |
  +---------------------------------------------------------------------+
  | LILO loads a kernel (vmlinuz) and an initial RAM disk (initrd) from |
  | the emulated floppy disk by BIOS, and then the kernel gains control.|
  +---------------------------------------------------------------------+
            |
            |  (BIOS is no longer used from now on)
            |
  +------------------------------------------+
  | The kernel expands initrd and mounts it  |
  | as a temporary root file system.         |
  +------------------------------------------+
            |
  +-----------------------------------------------------------------------+
  | The kernel executes /linuxrc in the initrd.                           |
  | A special command of cdmount (described later) is executed according  |
  | to a description of /linuxrc so that the CD-ROM of the game system    |
  | is mounted on a /mnt/cdrom directory.                                 |
  | Furthermore, the kernel changes a device of real root file system to  |
  | the initrd itself by some commands in /linuxrc, and finishes /linuxrc.|
  +-----------------------------------------------------------------------+
            |
  +--------------------------------------------------------+
  | Because the real root file system is the initrd itself,|
  | the kernel just executes /sbin/init which is symbolic  |
  | linked to /mnt/cdrom/sbin/init in the CD-ROM.          |
  +--------------------------------------------------------+
            |
  +----------------------------------------------+ <- In Vine 2.0, a message of
  | At first, init executes /etc/rc.d/rc.sysinit |   "Welcome to Vine Linux"
  | according to a description of /etc/inittab.  |   is displayed by a color
  +----------------------------------------------+   in execution of rc.sysinit.
            |
  +-----------------------------------------------------------+
  | The default run level has been set to 1(single user mode) |
  | so that /etc/rc.d/rc is executed with an argument 1.      |
  +-----------------------------------------------------------+
            |
  +-------------------------------------------------------------------+
  | /etc/rc.d/rc executes a shell script under /etc/rc.d/rc1.d from   |
  | S00single sequentially(*Note). And a shell script of S99game made |
  | in this directory especially is executed last.                    |
  +-------------------------------------------------------------------+
            |
  +----------------------------------------------------------+
  | In S99game, a PATH is set, a floppy disk for a save-data |
  | is mounted, the X Window System is launched by xinit.    |
  | Just an execution command of a game has been written on  |
  | a .xinitrc so that the game starts directly.             |
  +----------------------------------------------------------+

* Note:
Originally, /etc/rc.d/rc script should execute each script under the /etc/rc/rc1.d directory sequentially, but in case of Vine Linux's run level 1, S00single itself executes each script such as S20random from its inside and finally invokes a single user shell.

The mechanism of booting is considerably complicated, but you should understand the abstract mentioned above. Basically, the CD-ROM for the game system itself is a copy of a usual Linux system which includes whole directory tree from the root. However, because we cannot mount the CD-ROM on the root directly, at first we mount initrd as root, and then we mount the CD-ROM on /mnt/cdrom in the inside of initrd. Here, we have to use symbolic links well so that the directory tree after the mount of the CD-ROM can be seen as the same as usual Linux.



§ The CD-ROM game system making procedure

By the way, it is the CD-ROM game system which needs no hard drive, but we have to install Linux on a hard drive once as a base system and set it in a condition that a game starts with a single user mode, in order to make the CD-ROM. That is, we have to do the following procedure.

V
V
V
V
V
V
V

To "Linux CD-ROM Game System" index


This page has been rewritten for the web from a manuscript of TECH Linux Vol. 2 "CD-ROM Game System" ASCII Corporation.
To "SunOS 4.1.4 the mystery" Home
© 2000 YAMAMORI Takenori
yamamori@kt.rim.or.jp