Well, Google Cloud Platform (GCP) is one of my favorite cloud computing platforms because of its functionality and pricing.
Unhappily, Google Compute Engine (GCE), its Infrastructure as a Service (IaaS) component, doesn't support OpenBSD officially.
This post is about how to create an OpenBSD virtual machine (vm) on GCE/GCP.
The key factors are 2x2:
- To create a virtual machine:
- Use serial console.
- Prepare for virtual network interface, vio0. (It's OK just to use DHCP.)
- To set up GCP:
- Upload RAW image.
gsutilcommands to create cloud image.
Here are the operation steps:
Create VDI disk where OpenBSD is installed
Convert VDI image to RAW image for GCE and compress it to upload
by VBoxManage commands
Upload the image to Google Cloud Storage
by gsutil commands
Create an instance on GCE
by Google Cloud Console
- OS: OpenBSD 6.4 amd64
- OpenBSD installer
Google Cloud Storage
- A bucket is required to upload virtual image temporarily.
- Google Cloud SDK
Create a virtual machine for OpenBSD with VirtulBox:
* Note: According to GCP's Free Products, the storage size of GCE must be less than 30 GBytes if you want to let it free to use.
Add OpenBSD installer media, install64.iso, to "Storage":
Let's start the guest OS:
Proceed installation like these settings:
keyboard layout : [your-language] hostname : [your-hostname] network : "em0" -> "dhcp" -> "none" -> "done" domain, dns : (default) (or [your-domain]) password for root : [your-password] sshd : "yes" x windows system : "no" com0 : "no" # Because we'll set it up after installation by editing /etc/boot.conf user : "no" (or create someone) allow root login : "yes" # If you set it "no", be sure to create a ssh-allowed user.
* Caution: It's absolutely necessary to have a ssh-allowed user in order to manage the machine at the end of this tutorial. So don't forget to allow root login or create a ssh-allowed user. Moreover, validate the config "allow root login" as needed.
disk : "wd0" -> "W"hole -> Use "A"uto layout (or edit layout)
* Note: You can choose to edit layout by manual partitioning.
location of sets : (default) # "cd0" -> (default) # 6.4/amd64 -> "-game*" # optional: exclude more which is not necessary like "-x* -man*" -> "done" -> "yes"
After installation, halt it:
# halt # and power off guest
We need to add some settings to the virtual machine.
- Eject the installer media from "Storage" settings of VirtualBox.
- Boot the machine again.
- Wait util the initial OS settings at rebooting finish.
Then, operate the guest OS as follows:
# echo 'set tty com0' > /etc/boot.conf # activate serial connection # echo 'dhcp' > /etc/hostname.vio0 # register GCE virtual network # # check file content # cat /etc/boot.conf set tty com0 # cat /etc/hostname.vio0 dhcp
Next change the line in "/etc/ttys" in order to enable GCP serial console:
(thanks to Rickard Dahlstrand)
- console "/usr/libexec/getty std.9600" vt220 off secure + console "/usr/libexec/getty std.9600" vt220 on secure
It's also possible to change it after creating vm on GCP.
When all been done, shutdown it:
# shutdown -p now
If You need multithreading, add this setting:
# echo 'hw.smt=1' > /etc/sysctl.conf # # check file content # cat /etc/sysctl.conf hw.smt=1
* Note: OpenBSD 6.4 release announcements explain as follows:
amd64 now uses eager-FPU switching to prevent FPU state information speculatively leaking across protection boundaries.
Because Simultaneous MultiThreading (SMT) uses core resources in a shared and unsafe manner, it is now disabled by default. It can be enabled with the new hw.smt sysctl(2) variable.
set tty com0 means to use the serial port as a console.
Therefore, in order to manage the guest OS next time, we need to set "Enable Serial Port" before running it:
* Note: This post is divided into two parts. The latter part is: