OpenBSD vm on GCE/GCP - (2/2) Cloud Part
Tags: openbsd, gcp, gce, vm
Published: 2018-10-31 14:06:27

---
title: OpenBSD vm on GCE/GCP - (2/2) Cloud Part
published: true
description: OpenBSD is a secure, minimal and great OS which isn't officially supported by Google Compute Engine (GCE) of Google Cloud Platform (GCP). This is a tutorial how to create a OpenBSD virtual machine on GCE.
tags: openbsd, gcp, gce, vm
cover_image: https://thepracticaldev.s3.amazonaws.com/i/zplb8i1n2azjg30n53yi.jpg
series: OpenBSD vm on GCE/GCP
---

*\* Note: This post is divided into two parts. The former part is:*

{% link https://dev.to/nabbisen/openbsd-vm-on-gcegcp---12-local-part-gp3 %}


<center>✿ ✿ ✿</center>


### Step 2: Convert VDI image to RAW image for GCE and compress it to upload

We have created a virtual machine image where OpenBSD is installed.
Next step is to convert it to a compressed raw image as to upload to Google Cloud Storage.

```shell-session
$ cd "~/VirtualBox VMs/openbsd-64-amd64/" # where you created the image

$ # convert image
$ VBoxManage internalcommands converttoraw openbsd-64-amd64.vdi disk.raw
$ # compress it
$ tar -Szcf openbsd-64-amd64.tar.gz disk.raw

$ rm disk.raw # if necessary
```


### Step 3: Upload the image to Google Cloud Storage

Is it prepared, a bucket of [Google Cloud Storage](https://console.cloud.google.com/storage)?
If not, access [Dashboard](https://console.cloud.google.com/storage) and execute "CREATE BUCKET".

Let's go to the steps to manage Google Cloud.
`gsutil` commands are available:

First, upload the file:

```shell-session
$ gsutil cp -a public-read openbsd-64-amd64.tar.gz gs://[your-bucket]/openbsd-64-amd64.tar.gz

Copying file://openbsd-64-amd64.tar.gz [Content-Type=application/x-tar]...
| [1 files][370.1 MiB/370.1 MiB]  986.6 KiB/s
Operation completed over 1 objects/370.1 MiB.
```

*\* Note: When finishing uploading, you can delete the local file if necessary:*

```shell-session
$ rm openbsd-64-amd64.tar.gz
```

Next, create image from the uploaded file.

*\* Note: When you are in a retry action, you might have to delete the previous image:*

```shell-session
$ gcloud compute --project [your-project] --quiet images delete openbsd-64-amd64

Deleted [https://www.googleapis.com/compute/v1/projects/[your-project]/global/images/openbsd-63-amd64].
```

Create image:

```shell-session
$ gcloud compute --project [your-project] images create openbsd-64-amd64 --source-uri gs://[your-bucket]/openbsd-64-amd64.tar.gz

Created [https://www.googleapis.com/compute/v1/projects/[your-project]/global/images/openbsd-64-amd64].
NAME              PROJECT               FAMILY  DEPRECATED  STATUS
openbsd-64-amd64  [your-project]                            READY
```

Delete a used resource file in the bucket as needed:

```shell-session
$ gsutil rm gs://[your-bucket]/openbsd-64-amd64.tar.gz
```


### Step 4: Create an instance on GCE

First of all, to sign in [Google Cloud Console](https://console.cloud.google.com/) is required.
And then, choose menus: [Compute Engine] - [VM instances]:

![](https://thepracticaldev.s3.amazonaws.com/i/c0nka6mg5u57l2x6mm43.jpg)

OK. Let's start creating an instance:

![](https://thepracticaldev.s3.amazonaws.com/i/j8opko52d744bb1ihzzj.jpg)

Set "Boot Disk" with uploaded OpenBSD virtual image:

![](https://thepracticaldev.s3.amazonaws.com/i/jqmdbzablwvvpr5ysxr2.jpg)

*\* Note: Your image is found at the "Custom Images" list:*

![](https://thepracticaldev.s3.amazonaws.com/i/k3yktdebqair5s9zoyj5.jpg)

Execute creation:

![](https://thepracticaldev.s3.amazonaws.com/i/qmi4ee1cjyi0vhxanh98.jpg)

Now it's done!

![](https://thepracticaldev.s3.amazonaws.com/i/72lx39mefw32x5u0r1d7.jpg)


<center>✿ ✿ ✿</center>


## Usage

We can access our virtual machine via `ssh` commands like these: `ssh user@host` or `ssh host -l user`.

I hope to type `ssh` brings happiness to you, too : )
You will see the message "Welcome to OpenBSD":

![](https://thepracticaldev.s3.amazonaws.com/i/p4e87u38aw4guxr8talp.jpg)

After running an instance, we can build various servers like these:

{% link https://dev.to/nabbisen/setting-up-openbsds-httpd-web-server-4p9f %}
{% link https://dev.to/nabbisen/installing-postgresql-server-on-openbsd-1kc0 %}

---

#### Option: A small unsolved question left to me

I seem to have been able to manage OpenBSD vm on GCE by "Connect to serial console" after "Enable connecting to serial ports".

![](https://thepracticaldev.s3.amazonaws.com/i/bxpuwzu73de11ahnpz1k.jpg)

![](https://thepracticaldev.s3.amazonaws.com/i/vfysz6jz49wpejr1a1pr.jpg)

But the response stops at this line...

![](https://thepracticaldev.s3.amazonaws.com/i/ijh5mluc7bbdwomyvx51.jpg)

Do I have a wrong memory?

If you have some knowledge or solution, I'll be glad to hear from you : )


<center>✿ ✿ ✿</center>


## Outro

After all, I made my understanding deeper about not only creating an OpenBSD image but also creating custom images for cloud computing.
It was a very good experience to me.

Well, we sometimes need to patch the system or update the packages for the sake of security or/and improvement.
So I'm planning to write about post-installation settings of OpenBSD.

Happy serving 🕊