Booting SmartOS on Packet with Custom iPXE and Terraform

Packet recently made available their custom iPXE feature, allowing users to PXE boot an OS of their choice, and I found this incredibly intriguing, so I decided to try something out; running SmartOS on Packet’s bare-metal platform.

I didn’t need much to get started:

  1. A SmartOS ISO (or the platform release archive): https://wiki.smartos.org/display/DOC/Download+SmartOS
  2. I elected to setup a simple webserver on an Ubuntu host, and mounted my SmartOS ISO, copied the files to my webroot:
apt-get update; apt-get install apache2 -y; mkdir /var/www/html/smartos
wget https://us-east.manta.joyent.com/Joyent_Dev/public/SmartOS/smartos-latest.iso
mount -o loop smartos-latest.io /mnt/
cp -fr /mnt/* /var/www/html/smartos/

3. Added smartos.txt to my webroot:

#!ipxe
dhcp
set base-url http://YOUR_HOST_IP_ADDRESS
kernel ${base-url}/smartos/platform/i86pc/kernel/amd64/unix
initrd ${base-url}/smartos/platform/i86pc/amd64/boot_archive
boot

— — — — — — — — — — 
Update:
based on a tip from the folks at Quatumsi.com, if you’d like to have the system treat this as a host using a physical USB would (i.e. mounting /usbkey over this iPXE boot in order to persist many kinds of data between reboots), you should modify the above configuration with the additional kernel arguments:

kernel ${base-url}/smartos/platform/i86pc/kernel/amd64/unix -B smartos=true,console=ttyb,ttyb-mode="115200,8,n,1,-"
module ${base-url}/smartos/platform/i86pc/amd64/boot_archive type=rootfs name=ramdisk

— — — — — — — — — —

Note: if you do this on an existing Apache host, make sure to update the relative path to your base-url to your smartos directory.

This does:

i. calls out the network DHCP server for an address
ii. sets the base URL for your ipxe configuration to the Apache host you specified above, and sets the kernel and initrd path relative to that Apache webroot.
iii. boots according to this specification.

4. Login to your Packet.net account, and deploy a new server. In your Operating System selection, select “Custom iPXE” and provide the URL for your setup script (i.e. http://1.2.3.4/smartos.txt )

5. Once deployed, on your Packet node page, you can access the newly deployed node’s console:

and you’ll see the iPXE prompt pull down the configuration, required files, and boot according to this specification.

As with any SmartOS build, you’ll find the default root password in platform/root.password and you can login via the above console and begin configuring your SmartOS node:

Like what you read? Give Joseph D. Marhee a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.