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 https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-221.0.0-linux-x86_64.tar.gz
Use tar command to untar the tarball and install it:
$ tar zxvf google-cloud-sdk-221.0.0-linux-x86_64.tar.gz
$./google-cloud-sdk/install.sh
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 https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-221.0.0-darwin-x86_64.tar.gz
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/install.sh
$ 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
OR
$ gcloud compute images list \
--project freebsd-org-cloud-dev \
--no-standard-images | grep -i freebsd-11-2
OR
$ gcloud compute images list \
--project freebsd-org-cloud-dev \
--no-standard-images | grep -i freebsd-12
How to deploying FreeBSD 11.2 on Google cloud
The syntax is:
$ gcloud compute instances create {INSTANCE} --image freebsd-11-2-release-amd64 \
--image-project=freebsd-org-cloud-dev
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 user@public-IP
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:
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS backup-1 us-central1-c n1-standard-1 10.128.0.2 35.xxx.yyy.zz RUNNING nixcraft-freebsd11 us-central1-c n1-standard-1 10.128.0.3 35.ddd.aaa.cc 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:
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
🐧 2 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Cool article.
Great tutorial!
I’ve been running FreeBSD instances on Green for the better part of a year, (10-RELEASE, 11-CURRENT 11-STABLE lately) and the only reference I could find to get FreeBSD images was buried deep in an obscure thread on the FreeBSD forums. This writeup should be somewhere on the handbook. Perhaps a mini-chapter on deploying instances on different public clouds would be greatly beneficial. I’ve also got a couple of 9.x instances on Rackspace. AWS I haven’t tried yet. Or azure.