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: http://wiki.qemu.org/Download
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 169.254.169.254 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 255.255.0.0;
}
EOF`
Time server config:
`sed -I -e “/server/d” /etc/ntp.conf`
`echo “server 169.254.169.254” >> /etc/ntp.conf`
Hosts entry:
`echo “169.254.169.254 metadata.google.internal 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 8.8.8.8” >> /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)
`/usr/local/bin/wget http://storage.googleapis.com/pub/gsutil.tar.gz`
`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)
`/usr/local/bin/wget http://dl.google.com/dl/cloudsdk/release/artifacts/gcutil-1.12.0.tar.gz`
`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 “/8.8.8.8/d” /etc/resolv.conf`
9) Shutdown qemu VM Instance.
`poweroff`
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.
https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/google-startup-scripts
https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/google-daemon
https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/gcimagebundle
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!
--
© 2013 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to the Google Groups "gce-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gce-discussio...@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/22daa5ed-3a40-4848-b629-ee6af57296e0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
© 2013 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
I've been unable to access the FreeBSD instance from *outside* GCE no matter what I try. Externally, ssh always fails at SSH2_MSG_KEXINIT:```shell$ ssh -vo UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no ans...@173.255.113.12
OpenSSH_6.2p2, OpenSSL 0.9.8y 5 Feb 2013debug1: Reading configuration data /etc/ssh/ssh_configdebug1: Connecting to 173.255.113.12 [173.255.113.12] port 22.debug1: Connection established.debug1: permanently_set_uid: 0/0debug1: identity file /root/.ssh/id_rsa type -1debug1: identity file /root/.ssh/id_rsa-cert type -1debug1: identity file /root/.ssh/id_dsa type -1debug1: identity file /root/.ssh/id_dsa-cert type -1debug1: identity file /root/.ssh/id_ecdsa type -1debug1: identity file /root/.ssh/id_ecdsa-cert type -1debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_6.2_hpn13v11 FreeBSD-20130515debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2_hpn13v11 FreeBSD-20130515debug1: match: OpenSSH_6.2_hpn13v11 FreeBSD-20130515 pat OpenSSH*debug1: SSH2_MSG_KEXINIT sent```
ifconfig vtnet0 mtu 1460
interface "vtnet0" {
supersede subnet-mask 255.255.0.0;
}
Many thanks for the help, Paul.
ubuntu_12_04.tar: POSIX tar archive (GNU)
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/CAL%2BY1nsXjfpaSeGJ6Ei777uW_jBzOvhaGVbs76dZV8eBhtEFJw%40mail.gmail.com.
I was able to install FreeBSD on GCE in a very direct way, without the hurdles of Qemu, gcutil, and the FreeBSD installer. All are great tools, but I think my apporach is somewhat more suitable for GCE, or at least much simpler. Much of this is well-known practice for installing manually, with some fluff for managing it as a disk image, as well as the few odd networking requirements of GCE (MTU and netmask).
My basic approach is to:
* Use my FreeBSD machine at home to build a self-hosting "rescue" disk image for GCE.
* Start a temporary Linux machine in GCE from a provided image.
* Copy my image from home to a raw block device.
* Start a FreeBSD machine in GCE using that block device as the root.
Once bootstrapped, I used this "rescue" machine to turn up more machines, then shut down this machine. I kept this "rescue" disk image handy for future rescues and turn-ups. Naturally, this is the bare minimum; you'll still want to install gcutil and stuff once you have your space bootstrapped. Although I typically prefer ZFS, I used UFS here for a smaller memory footprint and because the data on this filesystem is not precious. Either GPT or legacy partitioning schemes work.
1. On your FreeBSD machine at home, create a disk image:
# truncate -s 2G /tmp/rescue.img
# mdconfig -a -t vnode -f /tmp/rescue.img
[adjust below if it says other than md0]
2a. Partition it with gpart:
# gpart create -s gpt /dev/md0
# gpart add -s 222 -t freebsd-boot -l rescue-boot md0
# gpart add -t freebsd-ufs -l rescue-root md0
# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 md0
# newfs -U /dev/md0p2
# mount /dev/md0p2 /mnt
2b. OR partition it the legacy way:
# fdisk -B -b /boot/boot0 /dev/md0
# bsdlabel -w -B /dev/md0s1
# newfs -U /dev/md0s1a
# mount /dev/md0s1a /mnt
3. Install the base OS:
# tar -C /mnt -xpf base.txz
# tar -C /mnt -xpf doc.txz
# tar -C /mnt -xpf games.txz
# tar -C /mnt -xpf kernel.txz
# tar -C /mnt -xpf lib32.txz
[Add ports.txz and/or src.txz if you prefer.]
4. Configure stuff:
# chroot /mnt csh
# newaliases
# passwd root
[Set a password.]
# mkdir /root/.ssh
# cat > /root/.ssh/authorized_keys << EOF
[your key]
EOF
# echo '/dev/da0p2 / ufs rw,noatime,suiddir 1 1' > /etc/fstab [change da0p1 to da0s1a if old style partition tables]
# echo -Dh > /boot.config
# echo 'console="comconsole"' > /boot/loader.conf
# cat > /etc/rc.conf << EOF
console="comconsole"
hostname="rescue"
ifconfig_vtnet0="DHCP"
ntpd_enable="YES"
ntpd_sync_on_start="YES"
sshd_enable="YES"
EOF
# cat > /etc/ssh/sshd_config << EOF
PasswordAuthentication no
PermitRootLogin yes
UseDNS no
UsePAM no # Otherwise PAM will allow password auth.
Subsystem sftp /usr/libexec/sftp-server
EOF
# cat > /etc/ntp.conf << EOF
server 169.254.169.254 burst iburst
EOF
# cat > /etc/dhclient.conf << EOF
interface "vtnet0" {
supersede subnet-mask 255.255.0.0;
}
EOF
# cat > /etc/rc.local << EOF
ifconfig vtnet0 mtu 1460
EOF
# exit
(You may also want to change your timezone from UTC.)
5. Dismount the image:
# umount /mnt
# mdconfig -d -u md0
6. Start a Linux machine on GCE. If you'll be subsequently creating machines with ZFS, choose one with enough RAM.
7. Copy rescue.img to it. (Remember, it must be dismounted first.)
8. Create a blank disk for FreeBSD and attach it to your Linux machine. I suggest naming the disk Rescue.
9. cat rescue.img > /dev/sdb [assuming your FreeBSD disk is sdb]
10. Detach Rescue from your Linux machine.
11. Create a new machine with Rescue attached as root.
12. After allowing time for it to boot, you should be able to ssh in as root.
13. Destroy the Linux machine to save expense, if desired.
For the list archive, he used:
ifconfig_vtnet0="SYNCDHCP mtu 1460"
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/CAL%2BY1ntUOM%3DJAj%3DuniMY8_VeR6cqhT6PQMAZ5HBchuHQQnkE4Q%40mail.gmail.com.
The DHCP server is actually advertising the correct netmask (255.255.255.255), the thing that is going wrong for FreeBSD users appears to be the routing necessary to reach the gateway. Luckily we can fix this in the dhclient.conf. If you're using the default network configuration, 10.240.0.0/16, gateway 10.240.0.1, dhclient.conf should contain this:
interface "vtnet0" {
default classless-routes 32, 10, 240, 0, 1, 0, 0, 0, 0, 0, 10, 240, 0, 1;
}
This causes the /sbin/dhclient-script to install two static routes. The first route, from the [32, 10, 240, 0, 1, 0, 0, 0, 0] part, is saying that 10.240.0.1/32 is available directly on the network interface (RFC 3442 describes this as "Local Subnet Routes"). The second route, from the [0, 10, 240, 0, 1] part, is saying that the route to 0/0, the default route, is through the gateway 10.240.0.1.On most Linux distributions, the /sbin/dhclient-script automatically installs the x.x.x.x/32 route for the default router if the netmask for the interface is 255.255.255.255, which is why this problem hasn't come up with that software.
I've got 10-STABLE booting, running, and communicating between VMs and the outside world successfully in this configuration. More information about the classless-routes DHCP option can be found in RFC 3442.Hope this helps.
-- wac
As implied by email protocols, the information in this message is not confidential. Any middle-man or recipient may inspect, modify, copy, forward, reply to, delete, or filter email for any purpose unless said parties are otherwise obligated. As the sender, I acknowledge that I have a lower expectation of the control and privacy of this message than I would a post-card. Further, nothing in this message is legally binding without cryptographic evidence of its integrity.
--
© 2014 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/YWoa3Aa_49U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussio...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/dcda369e-37e6-402f-b06f-26adf0affd0c%40googlegroups.com.
I'm saw some pretty substantial drift from ACPI-safe on an n1-highcpu-8 that was CPU bound. i8254 seems more stable in a quick bit of testing I've done.
Hello Dave and all,
interface "vtnet0" {
supersede subnet-mask 255.255.0.0;
}
EOF`
...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 <a href="https://github.com/GoogleCloudPlatform/compute-image-packages/blob/
FYI the latest mfsBSD[1] image based off FreeBSD-10.0 amd64 works
brilliantly in GCE now, with no changes needed.
- download the mfsbsd image as disk.raw
- gnu-tar it
- upload to your google storage
- register the upload as a disk image
- spin up an mfsbsd image directly in GCE
```
curl -o disk.raw
http://mfsbsd.vx.sk/files/images/10/amd64/mfsbsd-se-10.0-RELEASE-amd64.img
gtar -Szcf mfsbsd-se-10.0-RELEASE-amd64.tar.gz disk.raw
gsutil cp mfsbsd-se-10.0-RELEASE-amd64.tar.gz gs://skunkwerks-images/
gcutil addimage mfsbsd10-0
gs://skunkwerks-images/mfsbsd-se-10.0-RELEASE-amd64.tar.gz
```
And then your usual:
```
gcloud compute instances create --zone $ZONE --project $PROJECT \
--image mfsbsd10-0 <new-instance>
gcloud compute instances get-serial-port-output <new-instance>
```
The serial output will of course stop partway through the mfsbsd boot
process when it switches consoles, if this worries you, it's still
possible to roll your own image.
...
I've been using the gcloud method to generate a freebsd instance. However I'm setting up nginx and can't get the welcome to nginx page to display. Usually when working with D.O. I just install nginx and go to http://ip_address and it works. I've read the linux tutorial on this and it seems like the same process pretty straight forward. Is their an entirely different process for FreeBSD?
Hello Dave and all,
--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.
https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/google-startup-scripts
https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/google-daemon
https://github.com/GoogleCloudPlatform/compute-image-packages/tree/master/gcimagebundle
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
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to the Google Groups "gce-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gce-discussio...@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/eba06c3b-7f41-47d4-a3fd-9f9dd8bfed7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.