Google Groups

Re: FreeBSD support

Paul Rashidi Dec 18, 2013 10:49 AM
Posted in group: gce-discussion
Hello Dave and all,

 We've had a few posts regarding getting up and running with FreeBSD over the past few days. The team has put together a best-effort posting that will get most, if not all, of you up and running. That being said, we need to remind you that FreeBSD is being supported on Google Compute Engine by the community. The instructions are being provided as-is and without warranty.

1. Download, build, and install qemu stable-1.6.on your local machine.

Download information can be found here:

Note: Version 1.6 or greater is required and we aren't able to support qemu install/setup questions and there are alternative virtual environments with UI tools that can be used in place of qemu.

2. Download FreeBSD.


3. Create qemu disk image.

`qemu-img create disk.raw 10g`

> Formatting 'disk.raw', fmt=raw size=10737418240

Note: the disk format must be raw.

4. Launch a qemu VM and boot from the FreeBSD ISO.

qemu-system-x86_64 --enable-kvm -smp 1 -m 3750m -net nic,model=virtio -net user -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd,physical_block_size=4096 -drive if=none,id=hd,file=disk.raw,cache=none -cdrom FreeBSD-9.2-RELEASE-amd64-disc1.iso

Note: The --enable-kvm parameter allows for increased speed but is not required and should be left off if you are running the qemu command in a virtual environment such as Google Compute Engine.

5. Install FreeBSD.

a) Select ‘Install’ from the initial installer screen.

b) Select ‘No’ for non-default keyboard mapping.

c) Choose a temporary hostname such as `freebsdhost.`

d) Select ‘OK’ to select the default installed packages.

e) Choose ‘Guided’ for partitioning setup.

f) Select ‘Entire disk’ for the partition setup.

g) Click ‘Finish’ for the Partitioning Editor confirmation.

h) Choose ‘Commit’ to start formatting the disk image.

i) Select (and remember) a password for root account. This should obviously be a very strong password.

j) Select "Virtio networking adapter" during Network Configuration.

h) Choose ‘Yes’ to configure IPv4.

i) Choose ‘Yes’ for DHCP.

j) Select ‘No’ for IPv6.

k) Configure DNS resolution to use as your DNS server and `google.internal.` as your search directive.

l) Confirm that your machine clock is UTC.

m) Install sshd and ntpd to run at boot time.

n) Select ‘Yes’ for crash dumps.

o) Select ‘No’ for additional user accounts. We will configure them later.

p) Select ‘Exit’ to finish with the installer and choose ‘Yes’ to fall into a shell for a few more manual steps.

6. Additional system configuration.

Type the following commands to setup a few last items.

Serial console configuration

`echo 'console="comconsole"' >>/etc/rc.conf`

`echo ‘console=”comconsole”’ > /boot/loader.conf`

`sed -I -e “/hostname/d” /etc/rc.conf`

`echo -Dh >/boot.config`

Networking commands:

`cat <<EOF >/etc/dhclient.conf

interface "vtnet0" {

 supersede subnet-mask;



Time server config:

`sed -I -e “/server/d” /etc/ntp.conf`

`echo “server” >> /etc/ntp.conf`

Hosts entry:

`echo “ metadata” >> /etc/hosts`

7. Add a first-time login user and enable password based ssh logins.

a) Create a local user , set [and remember] its non-empty password: `adduser`.

b) Add the local user you created to the ‘wheel’ group.

`pw user mod <user> -G wheel`

c) Allow password-based ssh logins.

`sed -I -e “s/#PasswordAuthentication no/PasswordAuthentication yes/” /etc/ssh/sshd_config`

8. Install additional GCE packages

Make sure public DNS works:

`echo “nameserver” >> /etc/resolv.conf`

a) Install sudo, python, and wget:

`pkg_add -r sudo`

`pkg_add -r python`

`pkg_add -r wget`

d) Install gsutil (GCS command line tool)


`tar xfz gsutil.tar.gz -C /usr/local/share`

`ln -s /usr/local/share/gsutil/gsutil /usr/local/bin`

e) Install gcutil (GCE command line tool)


`tar xfz gcutil-1.12.0.tar.gz -C /usr/local/share`

`ln -s /usr/local/share/gcutil-1.12.0/gcutil /usr/local/bin`

Remove public DNS server

`sed -I -e “/” /etc/resolv.conf`

9) Shutdown qemu VM Instance.


10) Create a GCE image on your local machine.

a.) Install Cloud SDK onto your local machine using these instructions.

b) Package the qemu image

`tar -Szcf freebsd.tar.gz disk.raw`

c) Copy the tarball to GCS.

`gsutil mb gs://<my cloud storage bucket>`

`gsutil cp freebsd.tar.gz gs://<my cloud storage bucket>`

Note: Your cloud storage bucket can be created in Google Cloud Console under the Google Cloud Storage tab of your enabled Project.  Also, you are uploading a complete image and this step's length is dependent on your internet connection. Don't perform this step while tethering. :)

d) Create GCE image.

`gcutil addimage freebsd gs://<my cloud storage bucket>/freebsd.tar.gz`

Note: The creation of the image can take a little bit of time.

11) Start a FreeBSD instance on GCE.

a) Create an instance.

`gcutil addinstance freebsd --image=freebsd --zone=us-central1-a --machine_type=n1-standard-1`

b) Now get the instance external IP.

`gcutil getinstance freebsd | grep external-ip`

> |   external-ip          | A.B.C.D

c) ssh into your instance.

`ssh <user>@A.B.C.D`

The following steps would also need to be performed in order for the FreeBSD image to operate in a similar manner to the Debian and Centos Images that many use on Google Compute Engine. If you'd like to help we do take contributions.

Update the following to support FreeBSD and Install onto image in Step 8.

Feel free to post here if you have questions but do remember this is being offered in a best-effort fashion.

Thank you and happy computing!

Paul Rashidi