VyOS on Packet.net

From VyOS Wiki
Jump to: navigation, search

About Packet

Packet is a bare metal hosting company with equipment in 15 data centers around the world. VyOS can be deployed on Packet using its custom iPXE support, using a serial over SSH console known as SOS.

VyOS installation on Packet.net

VyOS defaults to a console baud rate of 9600, which is not compliant with packet.net’s SOS. As such, the squashfs image will need to be unpacked, config.boot.default updated to the correct serial number/BAUD rate and the squashfs image recreated.

VyOS 1.8 (stable) or above is required due to an issue where the “fetch” command is ran prior to network loading:

Preparation

Install needed tools:

# sudo apt update && sudo apt install squashfs-tools

Fetch image file:

# wget https://downloads.vyos.io/release/1.1.8/vyos-1.1.8-amd64.iso

Create directory for the image:

# mkdir /tmp/iso

Mount the image:

# sudo mount -o loop vyos-1.1.8-amd64.iso /tmp/iso

Create directory for the squashfs:

# mkdir /tmp/squashfs

Unsquash it:

# sudo unsquashfs -f -d /tmp/squashfs/ /tmp/iso/live/filesystem.squashfs

Configuration

Now we need to change the TTY and BAUD rate in the boot config file /tmp/squashfs/opt/vyatta/etc/config.boot.default. Change line 32 from

console {
             device ttyS0 {
             speed 9600

to

console {
             device ttyS1 {
             speed 115200

Rebuilding the image

Now the squashfs can be rebuilt, the compression method and block size that were used in the original image file are needed. Check the original image file, look for the lines Compression and Block Size:

# unsquashfs -s /tmp/iso/live/filesystem.squashfs

Create a new image file using the determined compression method and block size values:

# sudo mksquashfs /tmp/squashfs/ /tmp/filesystem.squashfs -comp gzip -b 131072

Installation

A server for booting VyOS might be within the same Packet data center that you are bringing VyOS up in (for quick boots), or you can boot from your laptop with a proxy tunnel like ngrok, or you can use an existing web server somewhere on the Internet.

The following files need to be hosted on a public URL somewhere. This URL needs to be added to the iPXE data below: (Note: the URL must be an IP address, host names are not allowed)

  • /tmp/iso/live/vmlinuz
  • /tmp/iso/live/initrd.img
  • /tmp/filesystem.squashfs

A custom iPXE option is needed for the installation, set the user data to the following:

#!ipxe
dhcp
set base http://<webserver IP address>
kernel ${base}/vmlinuz  
initrd ${base}/initrd.img
imgargs vmlinuz initrd=initrd.img boot=live config console=ttyS1,115200n8 ip=${net0/ip}::${net0/gateway}:${net0/netmask}     fetch=${base}/filesystem.squashfs
boot

Source / Acknowledgement

Based on https://gist.github.com/mikeburgh/7fef199dfc0e4edf20b1292a69500159 by Mike Burgh. Additional edits from Ed Vielmetti, Packet.