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.
- 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).
- Navigate to http://opensolaris.org/os/downloads/
- 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.
- burn DVD
- boot DVD
- GRUB: “Solaris Express”
- select “Solaris Interactive”
- make your language perference
- choose Networked
- DHCP yes
- IPv6 no
- Kerberos no
- Name Service: none
- NFS domain derived by the system
- choose your time zone
- enter your root password
- reboot yes, eject yes
- media CD/DVD
- accept the license
- custom install
- no localizations
- no additional products
- Entire Group, Default (~7 GB)
- select your install HD – remember that this is a dedicated disk that will be wiped!
- accept a single Solaris MBR partition with all the space
- modify the layout: remove /export/home and allocate all to “/”, keep swap
- wait
- the system will reboot. remove the DVD
- wait a long time again – the GUI login screen will show up eventually, don’t log in on the console
- log in as root
- (b99 will hang after a short “About Gnome” screen, hit Ctrl+Alt+Backspace to kill the X-Server and log in again)
- Administration -> Users and Groups, Add User
- log out
- log in as user
- find out what compiler you need: http://www.opensolaris.org/os/downloads/on/ says you need Sun Studio 11 up to b99, and Sun Studio 12 starting with b100.
- click on the linked Sun Studio
- it might say “Chinese-Simplified” as language, but the file is correct.
- don’t use the download manager, just click on the file and choose “Save File”
- Navigate to http://dlc.sun.com/osol/on/downloads/
- choose your build of your installed system (don’t say “current”, that’s newer!)
- download “ON Source”: on-src.tar.bz2
- download “ON Specific Build Tools (i386)”: SUNWonbld.i386.tar.bz2
- download “ON Binary-Only Components (debug, i386): on-closed-bins.i386.tar.bz2
- All Applications -> Accessories -> Terminal
- fix the prompt:
echo "export PS1='h:W u$ '" >> .bashrc
- add onbld to the PATH:
echo "PATH=/opt/onbld/bin:$PATH" >> .bashrc
- close the window and start a new terminal, or ssh into the machine; you can get your IP with
/usr/sbin/ifconfig -a
-
su
-
bash
-
cd /opt
-
bzip2 -cd /export/home/username/Desktop/sunstudio*.tar.bz2 | tar xf -
-
cd /export/home/username/Desktop
-
bzip2 -cd SUNWonbld*.tar.bz2 | tar xf -
-
pkgadd -d onbld SUNWonbld
-
y
- close Terminal window, open a new one
-
mkdir work
-
cd work
-
bzip2 -cd ~/Desktop/on-closed-bins*.tar.bz2 | tar xf -
-
bzip2 -cd ~/Desktop/on-src*.tar.bz2 | tar xf -
-
cd usr/src/tools
-
mkdir proto
-
ln -s /opt proto
-
cd ../../..
-
cp usr/src/tools/env/opensolaris.sh .
-
vi opensolaris.sh
- set GATE to “work” (base directory name)
- set CODEMGR_WS to “/export/home/username/$GATE” (full path)
- set STAFFER to your username
- set VERSION to “$STAFFER” to have your name in the kernel version
-
bldenv ./opensolaris.sh
-
cd usr/src/uts
-
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!
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?