DEV Community

loading...
Cover image for OpenBSD vm on GCE/GCP - (2/2) Cloud Part

OpenBSD vm on GCE/GCP - (2/2) Cloud Part

nabbisen profile image Heddi Nabbisen Updated on ・3 min read

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

✿ ✿ ✿

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.

$ 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
Enter fullscreen mode Exit fullscreen mode

Step 3: Upload the image to Google Cloud Storage

Is it prepared, a bucket of Google Cloud Storage?
If not, access Dashboard and execute "CREATE BUCKET".

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

First, upload the file:

$ 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.
Enter fullscreen mode Exit fullscreen mode

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

$ rm openbsd-64-amd64.tar.gz
Enter fullscreen mode Exit fullscreen mode

Next, create image from the uploaded file.

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

$ 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].
Enter fullscreen mode Exit fullscreen mode

Create image:

$ 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
Enter fullscreen mode Exit fullscreen mode

Delete a used resource file in the bucket as needed:

$ gsutil rm gs://[your-bucket]/openbsd-64-amd64.tar.gz
Enter fullscreen mode Exit fullscreen mode

Step 4: Create an instance on GCE

First of all, to sign in Google Cloud Console is required.
And then, choose menus: [Compute Engine] - [VM instances]:

OK. Let's start creating an instance:

Set "Boot Disk" with uploaded OpenBSD virtual image:

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

Execute creation:

Now it's done!

✿ ✿ ✿

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":

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


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".

But the response stops at this line...

Do I have a wrong memory?

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

✿ ✿ ✿

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 🕊

Discussion (2)

Collapse
rdahlstrand profile image
Rickard Dahlstrand

Hi,

If you change the line:

console "/usr/libexec/getty std.9600" vt220 off

to

console "/usr/libexec/getty std.9600" vt220 on

in "/etc/ttys" everything should start working with the serial console.

Thanks for an excellent tutorial.

Rickard.

Collapse
nabbisen profile image
Heddi Nabbisen Author • Edited

Hi Rickard,

Thank you so much for your great suggestion :)
Actually, I was in trouble because I didn't know how to enable GCP serial console.
I have updated my post "(1/2)".

Heddi.

Forem Open with the Forem app