This section provides a brief cookbook to creating your own bootable CD complete with XMAME and any Rom files you may have. Please note that the author has not fully tested this process and accepts no resposibility for any damage or frustration you may cause. It is also your responsibility to make sure that you do not infringe any copyright via the use of Roms of software for which you have no license agreement.
Note well that my C programming skills are "rusty", and the two programs provided are at best "flaky".
In order to create a bootable CD the following actions are required:-
1) create a stripped down version of GNU/Linux and adapt the filesystem to read only
2) install XMAME.SVGALIB, your roms and the menu system
3) create a bootable ISO image
4) write the image to a CD
I have based all of the operations around Redhat 6.2, simply because "it works", I have tried to create a system based upon later kernels, but had problems with the creation of a fully working bootable ramdisk image. Also the earlier kernel seemed to like my CD drive, whereas later versions didn't seem to work properly.
This whole process can be made much simpler,by using an ISO image that I have already created. However it is over 300Mb in size and I do not have this much ftp/http space available, email me if you can provide this and I will upload a much simpler set of instructions.
I am assuming that you have access to another GNU/Linux system aside from the one you will use to create your CD, this is important as you are going to have to compile some programs using GCC, and in order to save space we don't want to install GCC upon the stripped down system. I guess you could install GCC, compile your programs and then remove it if you wish, personally I can't be bothered.
Right, lets get started !
First get hold of a copy of Redhat 6.2 and burn it to a CD, you can find the ISO image here if you want some help in burning the ISO image to CD then look here
Now, install Redhat 6.2 to a partition or the complete hard disk of that computer you just happen to have lying around doing nothing. Remember that you are going to create an ISO image on this computer that is over 350Mb in size, so you need to have at least 800Mb worth of disk space for this partition and either a CD writer attached or a network connection to a computer with a CD writer.
When installing Redhat, make the following choices:-
From the first menu screen type "text" at the boot: prompt
Select your language version, follow prompts to Screen titled "Installation Type", here select "Install Custom System"
Follow the screens to partition your drive, make sure you select LILO as the boot loader, follow the other screens, create a root account, don't bother with any others. Then you should eventually get to the screen titled "Package Group Selection", deselect everything (unless you are going to burn your ISO on another PC, if so, leave "Networked Workstation" selected). Then select "Select individual packages", on the next screen, scroll down to "Applications/System" and select "mkisofs" you will need this later.
Now complete your installation of Redhat 6.2
On your usual GNU/Linux environment do the following
Download the latest version of XMAME from here
Compile XMAME for SVGALIB support, this is done by copying the makefile makefile.unix to Makefile and editing it such that the following line exists:-
..and all other DISPLAY_METHOD lines are commented out. A copy of the Makefile which I use is located here
Type make and you will soon find a copy of xmame.svgalib in the xmame directory.
Next download the CD Mounting utility from here and a copy of the crude Xmame.svgalib front end from here
Compile the CD Mounting utility with the following command:-
gcc -static -s -o cdmount cdmount.c
Compile the XMame.svgalib front end with the following command:-
gcc -static svgalib_menu_live_v1.c -lmenu -lncurses -o smenu
You should be left with two binaries, smenu and cdmount
On your Redhat 6.2 XMame system do the following:-
Create the directories for XMame and your Roms
mkdir /root/xmame/roms -p
Copy xmame.xvgalib, smenu and cdmount into /root/xmame
Copy your roms into /root/xmame/roms
Now create a script to launch XMame and the menu system:-
chmod +x /etc/rc.d/rc1.d/S99game
Check that it all works ok !
You should see a menu dialogue allowing you to select your Rom file, pressing ENTER should then run XMame with your Rom file
Now things start to get a little more involved, as we are going to run entirely from CD it is important that the OS runs from a read only filesystem. So the following changes are necessary:-
Change id:3:initdefault to id:1:initdefault
Find the line that looks something like: "/dev/hda2 swap swap defaults" and change it to "#/dev/hda2 swap swap defaults"
We have a read only file system and depmod writes to modules.dep (which we have made readonly)
chmod a-x /sbin/depmod
Again, we have a read only filesystem and cannot write to /etc/mtab, so:-
ln -s /proc/mounts /etc/mtab
Boot scripts write to these directories, later on we are going to create a ramdisk where /tmp will be mounted to, so we move these files and create symbolic links:-
mv loc lock-0
mv run run-0
mv tmp tmp-0
ln -s /tmp/var/lock .
ln -s /tmp/var/run .
ln -s /tmp .
The directories linked above need to be created in the rc.sysinit scriot, before other scripts try to use them
FIND the line: "action "Remounting root filesystem in read-write mode"....
ADD BELOW the line:-
mkdir -p /tmp/var/run /tmp/var/lock/subsys /tmp/var/lock/console
The whole system will crash if you try to shutdown after booting from CD-ROM due to the unusual filesystem mount. so:-
FIND the lines: "/sbin/fuser -k -m $sig $remaining > /dev/null"
ADD BEFORE this line:-
Making a bootable CD is split into two stages, first a Ramdisk image is created, this is used as the first boot image and mounts the CD filesystem.. Next the ramdisk is loaded within a linux boot sector and written to the CD along with the readonly filesystem that has been previously created.
/sbin/mkinitrd -v -f /boot/initrd-game.img 2.2.14-5.0 (note insert your kernel image version here if different)
zcat /boot/initrd-game.img > /tmp/initrd-game
mount -o loop /tmp/initrd-game /mnt/tmp
mkdir -p mnt/cdrom
mv bin dev etc lib mnt/cdrom
ln -s mnt/cdrom/* .
ln -s mnt/cdrom/usr mnt/cdrom/sbin mnt/cdrom/var mnt/cdrom/root .
mkdir tmp chmod 1777 tmp
cp -a /dev/hd[abcd]* /dev/scd0 /dev/sda* mnt/cdrom/dev
cp -p /root/xmame/cdmount .
echo "Mounting CD-ROM from Ramdisk"
mount -t proc none /proc
echo 0x100 > /proc/sys/kernel/real-root-dev
/sbin/losetup -d /dev/loop
gzip -9 < /tmp/initrd-game > /boot/initrd-game.img
When you are testing you may find that you need to carry out these operations more than once, to make life a little bit easier I have created two shell scripts, this one for making and mounting a ramdisk image and this one for unmounting it.
The CDROM needs a boot image to boot from, this is created by making a boot floppy and then adding the ramdisk image to it:-
INSERT A FLOPPY DISK
/sbin/mkbootdisk -v 2.2.14-5.0 (insert your kernel image version here if different)
mount /dev/fd0 /mnt/floppy
cp -p /boot/initrd-game.img /mnt/floppy/initrd-game.img
MAME CD is SIMPLY the GREATEST thing SINCE sliced BREAD
<or insert your own boot message>
/sbin/lilo -r /mnt/floppy
dd if=/dev/fd0 of=/images/boot.img bs=18k
Next you will create a complete filesystem for the bootable CD.
TZ=UTC mkisofs -R -J -o MAMECD.iso -b images/boot.img -x /tmp -x /proc
This will leave you with a file /tmp/MAMECD.iso which is a complete image of your bootable system, this needs to be written to a CDR (or RW although some CD drives will not boot CDRW disks). This can be done under linux using:-
cdrecord -v dev=<your cd writer> speed=<your speed> -pad -dao MAMECD.iso
Or by using a Windows CD burning package
You can boot the CD using one of two methods:-