Building the Solaris Kernel in 73 Easy Steps

Everyone and their grandmother builds Linux kernels. Many people build BSD, and some brave men even compile the OS X kernel every now and then. Why not compile your own Solaris kernel for a change?

There is lots of documentation scattered out there, many pieces, incomplete, outdated and over-generalized tutorials. This will walk you through installing Solaris, adding all components required for building, and actually compiling a kernel in 73 easy steps.

I won’t give you any options, because options make everything more complicated. We’re installing Solaris on a dedicated machine, the versions of the build system and the target kernel/system will match and we’re targeting x86/x64 only.

  1. Get a physical computer with maybe a GB of RAM and significantly more than 10 GB of disk space. VMware and VirtualBox seem to have issues with current builds (b97-b99).
  2. Navigate to
  3. Download the latest build of OpenSolaris Express Community Edition (Nevada). You can’t compile a kernel on any other Solaris distribution. Get Nevada. If you want to run a specific build, hack the URL and replace the build number; older builds are available, but not linked to.
  4. burn DVD
  5. boot DVD
  6. GRUB: “Solaris Express”
  7. select “Solaris Interactive”
  8. make your language perference
  9. choose Networked
  10. DHCP yes
  11. IPv6 no
  12. Kerberos no
  13. Name Service: none
  14. NFS domain derived by the system
  15. choose your time zone
  16. enter your root password
  17. reboot yes, eject yes
  18. media CD/DVD
  19. accept the license
  20. custom install
  21. no localizations
  22. no additional products
  23. Entire Group, Default (~7 GB)
  24. select your install HD – remember that this is a dedicated disk that will be wiped!
  25. accept a single Solaris MBR partition with all the space
  26. modify the layout: remove /export/home and allocate all to “/”, keep swap
  27. wait
  28. the system will reboot. remove the DVD
  29. wait a long time again – the GUI login screen will show up eventually, don’t log in on the console
  30. log in as root
  31. (b99 will hang after a short “About Gnome” screen, hit Ctrl+Alt+Backspace to kill the X-Server and log in again)
  32. Administration -> Users and Groups, Add User
  33. log out
  34. log in as user
  35. find out what compiler you need: says you need Sun Studio 11 up to b99, and Sun Studio 12 starting with b100.
  36. click on the linked Sun Studio
  37. it might say “Chinese-Simplified” as language, but the file is correct.
  38. don’t use the download manager, just click on the file and choose “Save File”
  39. Navigate to
  40. choose your build of your installed system (don’t say “current”, that’s newer!)
  41. download “ON Source”: on-src.tar.bz2
  42. download “ON Specific Build Tools (i386)”: SUNWonbld.i386.tar.bz2
  43. download “ON Binary-Only Components (debug, i386): on-closed-bins.i386.tar.bz2
  44. All Applications -> Accessories -> Terminal
  45. fix the prompt:
    echo "export PS1='h:W u$ '" >> .bashrc
  46. add onbld to the PATH:
    echo "PATH=/opt/onbld/bin:$PATH" >> .bashrc
  47. close the window and start a new terminal, or ssh into the machine; you can get your IP with
    /usr/sbin/ifconfig -a
  48. su
  49. bash
  50. cd /opt
  51. bzip2 -cd /export/home/username/Desktop/sunstudio*.tar.bz2 | tar xf -
  52. cd /export/home/username/Desktop
  53. bzip2 -cd SUNWonbld*.tar.bz2 | tar xf -
  54. pkgadd -d onbld SUNWonbld
  55. y
  56. close Terminal window, open a new one
  57. mkdir work
  58. cd work
  59. bzip2 -cd ~/Desktop/on-closed-bins*.tar.bz2 | tar xf -
  60. bzip2 -cd ~/Desktop/on-src*.tar.bz2 | tar xf -
  61. cd usr/src/tools
  62. mkdir proto
  63. ln -s /opt proto
  64. cd ../../..
  65. cp usr/src/tools/env/ .
  66. vi
  67. set GATE to “work” (base directory name)
  68. set CODEMGR_WS to “/export/home/username/$GATE” (full path)
  69. set STAFFER to your username
  70. set VERSION to “$STAFFER” to have your name in the kernel version
  71. bldenv ./
  72. cd usr/src/uts
  73. dmake all

(If it complains with “illegal option -m64”, your compiler is too old. Get Sun Studio 12. If anything fails, read the README from the download page for updates on the build you’re using.)

Now if we only knew what to do with that kernel!

1 thought on “Building the Solaris Kernel in 73 Easy Steps”

  1. I’d like to try this some day. I’ve actually downloaded the ON source tar file a couple of weeks ago.

    But … what comes after dmake all?

    What will the dmake all command do?
    Where will it output the binaries?
    How do I confirm that it worked?
    How do I install and/or boot that kernel?


Leave a Comment