Tuesday, January 5, 2010

Creating a custom OpenBSD RAM Disk


  • 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.


  1. Unpack the src.tar.gz and sys.tar.gz into the /usr/src directory.
  2. Compile and install crunchgen:
    # cd /usr/src/usr.sbin/crunchgen
    # make && make install
  3. Compile the special tools used in the ramdisk:
    # cd /usr/src/distrib/special
    # make
  4. 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:
    LINK instbin                                    bin/rsh
  5. Build the ram disk:
    # cd /usr/src/distrib/i386/ramdisk_cd
    # make
  6. Build an iso image:
    # mkdir isofiles
    # cp /path/to/your/cdbr isofiles
    # cp /path/to/your/cdboot isofiles
    # mkdir isofiles/{etc,4.6/i386}
    # cp bsd.rd isofiles/etc/4.6/i386
    # mkhybrid –r –V "OpenBSD 4.6 Backup" –b 4.6/i386/cdbr \
    > –c boot.cat –o cd46.iso isofiles/
  7. Burn the CD, or fire it up in your favourite VM.
  8. 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.

No comments:

Post a Comment