[English] [Japanese]

Linux CD-ROM Game System

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

§ Adapting to a read-only file system

We have seen the appearance of the game system, but the file system is not adapted to a read-only file system yet.

So we have to do the following work so as to remove the problem that will appear when it goes read-only.

¶ Remove the swap

The CD-ROM system cannot use any swap, of course. Find a line in the contents of /etc/fstab as follows, and comment it out by "#":

----
#/dev/hda2  swap  swap  defaults
----

This change becomes effective when it reboots. Doing a command "/sbin/swapoff devicename" removes a swap immediately. In addition, we can display the use of current swap with a command "/sbin/swapon -s"


¶ Don't execute depmod

While testing it on a hard drive, we won't notice that the boot time goes extremely long for seeking under the directory /lib/modules by depmod command when the file system becomes CD-ROM. Moreover, the execution of depmod itself is meaningless because the file modules.dep is read-only and cannot be updated.

In boot, /etc/rc.d/rc.sysinit invokes depmod only if it has an execute permission. So we can drop the x permission of depmod as follows so that it isn't executed.

----
# chmod a-x /sbin/depmod
----

¶ Modifying /etc/mtab

The file /etc/mtab gets impossible to write, too. Then an indication of mount points will be corrupted. Actually, it doesn't harm playing a game, however, we can deal with it by using /proc/mounts as follows:

----
# rm /etc/mtab
# ln -s /proc/mounts /etc/mtab
----

You might think that it is good to move /etc/mtab under /tmp with a symbolic link pointing it simply, but it doesn't succeed because of a lock file.

Because we have changed /etc/mtab to a simbolic link to /proc/mounts, we need attention that a loopback mount won't free /dev/loop* even though it is unmounted. From now on, we must remember to execute the following command explicitly after unmounting a loopback mount.

# /sbin/losetup -d /dev/loop0

¶ Move /var/lock, /var/run, /var/tmp with symbolic links

As for /var/lock, /var/run, writing access occurs by execution of rc scripts. And of course, /var/tmp is written. So we move these directories to /tmp with symbolic links. Writing is possible under /tmp directory because /tmp becomes RAM disk which is a part of initrd finally.

----
# cd /var
# mv lock lock-0
# ln -s /tmp/var/lock .
# mv run run-0
# ln -s /tmp/var/run .
# mv tmp tmp-0
# ln -s /tmp .
----

Then we add the following description to rc.sysinit to create the directories that have been moved to /tmp in system boot.

Finding the 220th line neighborhood of /etc/rc.d/rc.sysinit that remounts the root filesystem,

# Remount the root filesystem read-write.
action "Remounting root filesystem in read-write mode" mount -n -o remount,rw /

we add the following command just after that.

mkdir -p /tmp/var/run /tmp/var/lock/subsys /tmp/var/lock/console

¶ Modifying the halt script

We won't notice before creating a CD-ROM actually, that an fuser command executed in a halt script of Vine 2.0 causes a problem.

The CD-ROM game system will hang up when the fuser command is executed in shutdown because of the unusual filesystem mount.

So we avoid it as follows. Finding the following line that will be the 81th line neighborhood of /etc/rc.d/init.d/halt,

/sbin/fuser -k -m $sig $remaining > /dev/null

add a break shell command to break a loop just before the fuser command line.

By this, we can shutdown the system cleanly even when it becomes a CD-ROM system.

Now, the adaptation to a read-only filesystem has been completed. Rebooting once now, we make sure the game starts.


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