How to install FreeBSD 11 on Google Cloud Compute

How can I deploy or install FreeBSD version 11.x Unix operating system on the Google cloud engine? Do I need to create my own FreeBSD disk image to start with the Google Cloud Compute?

It is true that the Google Compute Engine support for Debian, Ubuntu, RHEL, SUSE, and FreeBSD Unix. However, create an instance page only display handful of operating systems as follows:

Fig.01: On VM creation page only Linux and Windows are available

How to install FreeBSD 11 on Google Cloud Compute

You can easily create FreeBSD based VM using the following procedure:

Install gcloud SDK on Linux

First, make sure that Python 2.7 is installed on your Linux based desktop system using the type command/command command:
$ type -a python
$ /usr/bin/python --version

Next use the curl command or wget command to grab file:
$ wget
Use tar command to untar the tarball and install it:
$ tar zxvf google-cloud-sdk-221.0.0-linux-x86_64.tar.gz

Initialize the gcloud SDK:
$ gcloud init
In your browser, log in to your Google user account when prompted and click Allow to grant permission to access Google Cloud Platform resources. Verify that it is working:
$ gcloud auth list

A note about snap based installation

You can install google cloud sdk using the snap command on a Linux based system:
$ sudo snap install google-cloud-sdk --classic
$ gcloud init

How to install gcloud SDK on Mac OS X/macOS

Type the following commands:
$ wget
Extract tar.gz file using the tar command and install sdk:
$ tar -zxvf google-cloud-sdk-221.0.0-darwin-x86_64.tar.gz
$ ./google-cloud-sdk/
$ gcloud init
$ gcloud auth list

Get list of gcloud compute images

Type the following command:
$ gcloud compute images list --project freebsd-org-cloud-dev --no-standard-images
$ gcloud compute images list
--project freebsd-org-cloud-dev
--no-standard-images | grep -i freebsd-11-2

$ gcloud compute images list
--project freebsd-org-cloud-dev
--no-standard-images | grep -i freebsd-12

Click to enlage

How to deploying FreeBSD 11.2 on Google cloud

The syntax is:
$ gcloud compute instances create {INSTANCE} --image freebsd-11-2-release-amd64

You need minimum 32GB disk space. So here is my command to create a VM in us-central1-c zone, n1-standard-1 machine type, and boot disk set to 60GB SSD storage:
$ gcloud compute instances create "nixcraft-freebsd11"
--zone "us-central1-c"
--machine-type "n1-standard-1"
--network "default" --maintenance-policy "MIGRATE"
--image "freebsd-11-2-release-amd64" --image-project=freebsd-org-cloud-dev
--boot-disk-size "60"
--boot-disk-type "pd-ssd"

Sample outputs:

Fig.02: FreeBSD 11 on Google Compute Engine Deployed

How to ssh into FreeBSD 11 Google cloud compute server?

Simply type the following command:
$ gcloud compute ssh {INSTANCE}
$ gcloud compute ssh {INSTANCE} --zone "us-central1-c"
$ gcloud compute ssh nixcraft-freebsd11
--zone "us-central1-c"
--project "mybsdvms-nixcraft-156800"
$ ssh -i ~/.ssh/my-gcs [email protected]

Sample session:

Fig.03: SSH into my Google cloud server powered by FreeBSD 11

How do I list my Google compute VMs?

Type the following command from your Unix/Linux desktop:
$ gcloud compute instances list
Sample outputs:

backup-1            us-central1-c  n1-standard-1       RUNNING
nixcraft-freebsd11  us-central1-c  n1-standard-1       RUNNING

How do I login as root user?

Simply type the command:
$ sudo -s

How do I install a bash shell?

Simply type the following pkg command to install a bash shell on FreeBSD 11, run:
# pkg install bash
Sample outputs:

Fig.04: Howto Install BASH in FreeBSD using pkg Command

How do I upgrade my FreeBSD 11.x hosted on Google compute?

Run the following command to update base system:
# freebsd-update fetch
# freebsd-update install
## [optional but needed for the FreeBSD kernel and other stuff] ##
# reboot

Run the following command to update installed packages to the latest version:
# pkg update
# pkg upgrade

Sample outputs:

Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (5 candidates): 100%
Processing candidates (5 candidates): 100%
The following 4 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
	sudo: 1.8.20p2_2 -> 1.8.20p2_3
	python27: 2.7.13_6 -> 2.7.13_7
	curl: 7.54.1 -> 7.55.1
	ca_root_nss: 3.31 -> 3.32

Number of packages to be upgraded: 4

13 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/4] Fetching sudo-1.8.20p2_3.txz: 100%  891 KiB 912.5kB/s    00:01    
[2/4] Fetching python27-2.7.13_7.txz: 100%   10 MiB  10.9MB/s    00:01    

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.