Creating a custom OpenBSD RAM disk

Ingredients

 * One OpenBSD system with enough space to build a release and with the compilers install set installed. This guide assumes you have OpenBSD 4.6.
 * The src.tar.gz for your OpenBSD version.
 * The sys.tar.tgz for your OpenBSD version.
 * The cdboot and cdbr files for your OpenBSD version.

Disclaimer (or: My lawyer made me do it)
This guide is just that – a guide. No responsibility is taken, implied or otherwise, for any liability for any damage whatsoever, be it immediate, as a residual effect or otherwise, caused by following this guide. OpenBSD’s developers will not answer any support requests regarding any issues that arise from following this guide. If it breaks, you get to keep both pieces.

Instructions
LINK instbin                                   bin/rsh > –c boot.cat –o cd46.iso > isofiles/
 * 1) Unpack the src.tar.gz and sys.tar.gz into the /usr/src directory.
 * 2) Compile and install crunchgen:
 * 3) cd /usr/src/usr.sbin/crunchgen
 * 4) make && make install
 * 5) Compile the special tools used in the ramdisk:
 * 6) cd /usr/src/distrib/special
 * 7) make
 * 8) Edit /usr/src/distrib/i386/ramdisk_cd/list.local and add the path to the program you wish to add. For instance, to add rsh to the ram disk, add the following to the lines like it:
 * 1) Build the ram disk:
 * 2) cd /usr/src/distrib/i386/ramdisk_cd
 * 3) make
 * 4) Build an iso image:
 * 5) mkdir isofiles
 * 6) cp /path/to/your/cdbr isofiles
 * 7) cp /path/to/your/cdboot isofiles
 * 8) mkdir isofiles/{etc,4.6/i386}
 * 9) cp bsd.rd isofiles/etc/4.6/i386
 * 10) mkhybrid –r –V "OpenBSD 4.6 Backup" –b cdbr \
 * 1) Burn the CD, or fire it up in your favourite VM.
 * 2) Profit!
 * 1) Profit!

Other uses

 * You could also use the bsd.rd image and pxeboot from your CD and boot systems over a network using this ram disk you created.
 * You could add additional drivers to the ramdisk kernel to support devices needed to install your system. Be sure to modify /usr/src/sys/arch/i386/RAMDISK_CD to add the drivers you require. If the drivers aren't in GENERIC, this will necessitate a full release build, which is beyond the scope of this document.
 * You could modify the install scripts to perform a certain purpose. I created one that would allow the user to backup and restore their entire system to a central server.

Final word
Above all, you are responsible for whatever you do when you follow this guide. If it breaks, you get to keep both pieces.

In any case, good luck and have fun – that’s what it’s all about.

Accolades
Source: Creating a custom OpenBSD RAM Disk