Skip to content

Instantly share code, notes, and snippets.

@crcx
Created October 10, 2010 01:49
Show Gist options
  • Save crcx/618827 to your computer and use it in GitHub Desktop.
Save crcx/618827 to your computer and use it in GitHub Desktop.
Author: Charles Childers

Background

Retro originally ran directly on x86-based computers. Support for this was maintained through nine major releases, spanning four complete rewrites. With the tenth major release, this was dropped in favor of a hosted solution using a virtual machine and memory image.

It is now possible to build a static binary of the virtual machine, and run Retro directly over a Linux kernel, with no standard userland.

Building a Root Filesystem

You may need to be root for this:

Create a Disk Image

mkdir retro-on-linux
cd retro-on-linux
dd if=/dev/zero of=rootfs bs=1k count=20k
yes y|mkfs.ext2 rootfs

Mount It

mkdir /mount/retro
mount -o loop rootfs /retro
cd /mount/retro

Setup the Directories

cp -a /dev dev
mkdir etc sbin

Create the fstab

cat >etc/fstab <<EOF
/dev/ubd0 / ext2 defaults  0 1
EOF

Build and Install Retro

The first path should be adjusted to point to the directory where you have the Retro sources.

cd ~/retro
gcc -static vm/retro.c -o /mount/retro/sbin/init
cp retroImage /mount/retro

Unmount And Cleanup

cd ~/retro-on-linux
umount /mount/retro
rm -rf /mount/retro

Booting It

At this point you should have a rootfs file that's ready to be booted. This can be booted as an initrd, or via user mode linux (recommended):

wget http://user-mode-linux.sourceforge.net/linux-2.6.24-rc7.bz2
bunzip2 linux-2.6.24-rc7.bz2
chmod +x linux-2.6.24-rc7.bz2
./linux-2.6.24-rc7 ubd0=rootfs

Alternately, if you're somewhat crazy, this could be done on a real partition instead of a rootfs image, and add it to your grub or lilo configuration. (Being that I'm somewhat crazy, and have a bit of a soft spot for OS development, I'm going to look into building a bootable ISO for playing with on real hardware.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment