There is a wonderful blog post about how to get a PXE server up and running to boot SmartOS. In this post I want to explain the next step, getting the booted SmartOS box fully functional.
As a start we provide a fully setup PXE server which everyone is welcome to use, you can use the boot script if you want to skip over the setup. Of cause if you rather set up your own you can just follow the instructions in the blog post and replace the iPXE script with the following:
#!ipxe dhcp set base-url http://pxe.fifo.cloud 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 boot
Creating the Host
Note, this is currently tested on x1.small and t1.small.x86 instances. Instances with Mellanox cards are not supported by SmartOS!
Now with that prepared the next step is to set up a server on packet, select ‘Custom iPXE’ as your OS and put in either our ixpe url or your own.
Before you continue with the installation press the ‘Manage’ button to go to the advanced settings. Scroll down all the way to the bottom and select ‘Persist PXE …’ – that way the server will keep botting via PXE after the installation
The server will then start to provision and after a while, you will be able to go to the details page. Find the buttonand click it to get an ssh command to connect to your server’s console.
While you are here you can note down the private (2) and public (1) IPs and gateways for your server as you’ll need them in the next step.
Installing SmartOS
Once you connected to the servers console the usual SmartOS installer will greet you. When going through it answer the questions as follows:
- Admin Interface: 1st nic
- Admin IP: Private IP (2)
- Admin Netmask: 255.255.255.240 (this is needed to be .240 no matter what packet says!)
- Admin Gateway: Private gateway (2)
- Headnode Gateway: Public Gateway (1)
- NTP, DNS, Disk: defaults (or adjust as desired), it will not be able to connect at this point!
A quick word to the netmask, packet hands out /31 ranges which ifconfig does not swallow on its own. We will use a setup service at the end of this tutorial to set it properly but the configuration needs to be set to 240 to ensure everything boots fine.
This is what the result should look like, you can save this and reboot.
Configuration
Once rebooted we will edit the /usbkey/config file and enter the values as follows:
admin_nic=<mac of 1st nic> # this does not need to be changed admin_ip=<admin ip from 2> # take from the vms networks admin_netmask=255.255.255.0 # this needs to be 240! admin_gateway=<admin gateway from 2> # take from the vms networks external_nic=<mac of 1st nic> # same as admin_nic external0_ip=<public ip form 1> # take from the vms networks external0_netmask=255.255.255.0 # this needs to be 240 external0_gateway=<public gateway> # take from the vms networks headnode_default_gateway=<public gateway> # take from the vms networks dns_resolvers=8.8.8.8,8.8.4.4 # chang if you like dns_domain=local # can be changed ntp_hosts=0.smartos.pool.ntp.org # can be changed hostname=smartos-test # use your own hostname
Note: For x1.small instances instead of the mac of the nic you can use an aggregate by adding the following line and use aggr0 instead of the mac in the _nic= lines. You can get the secondary mac by running: dladm show-phys -m
aggr0_aggr=<mac of nic 1>,<mac of nic 2>
To bring up networking we’ll need another reboot at this point. This is a good time to add additional public networks to your server if you want zones with public IPs to your server in the portal.
Once the server is rebooted we have a packet setup service that will grab some information and do the last bits of setup.
First set the netmask to waht packet expects:
ifconfig igb0 netmask 255.255.255.254 ifconfig external0 netmask 255.255.255.254
To install the script you can run:
curl -ks http://pxe.fifo.cloud/tools/install.sh | bash
or download the file and inspect it to be sure you want what it. The script will:
- install the SSH keys you asked Packet to add to the server
- correct the netmasks on the external and public interface
- set up routes for additional networks
A word to gateways, we’re setting up an additional interface with the IP 192.168.255.255 that functions as a gateway for public-facing zones, the setup script will in return set up all routes for this gateway.
The first zone
To create the first zone we import a dataset:
imgadm import 23b267fc-ad02-11e7-94da-53e3d3884fe0
Then write a zone description, use a public IP from your additional rage you added earlier.
{ "autoboot": true, "brand": "joyent", "image_uuid": "23b267fc-ad02-11e7-94da-53e3d3884fe0", "delegate_dataset": true, "max_physical_memory": 1024, "cpu_cap": 100, "alias": "test", "quota": "5", "resolvers": [ "8.8.8.8", "8.8.4.4" ], "nics": [ { "interface": "net0", "nic_tag": "admin", "ip": "<additional public ip>", "gateway": "192.168.255.255", "netmask": "255.255.255.255", "primary": true } ] }
you can then create the zone with the command
vmadm create -f /opt/zone.json
Due to a bug in vmadm you need to run two more commands to configure routing. Log into the zone and execute the commands:
route -p add 192.168.255.255 <zone ip> -interface route -p add default 192.168.255.255
That’s it, your server is now set up and your zone should be able to reach the internet and be reachable from the internet.
Leave a Reply