Since FreeBSD 10 finally has Hyper-V support already in the standard package of x64 release (x86 needs some tweaking), but Microsoft Azure does not yet have direct support for creating a FreeBSD-based virtual machine, I decided to tell you how to install FreeBSD 10 in azure. There is nothing particularly difficult, except that you will have to pour a lot into the cloud. And so - in order.
I don’t see taking iso and making zero sense, since the FreeBsd community releases ready-made images of virtual machines with the latest / stable releases. There we will take the necessary, already installed image in * .VHD format. Keep in mind - * .VDHX does not yet support azure.
On the other hand, if you already have an installed system, you can use it.
And so, we take the x64 release of FreeBSD 10 in the * .VHD format with
ftp.FreeBSD.org , the x86 build just won't start - keep in mind.
The choice of images there is big , you can both stable and current and even 11 to try, but for the sake of business. Take release. By the way, images are available in QEMU and VMWARE formats.
The first thing we will face is that the drive for azure should be fixed, not dynamic. That is, it must be exactly the same size as recorded in it. Dynamic extension is not supported by azure. Our Freebsd image unpacked occupies ~ 900mb, and the disk there is marked up as 20gb.
The good news is that the
Add-AzureVHD command from
Azure PowerShell is able to convert dynamic to fixed on the fly. Pouring 900mb instead of 20gb is a big difference. We will use it at the end.
')
The second. Since the image is “naked”, you need to adjust it a bit to work in azure. For this, you can use the Hyper-V hypervisor built into Windows or
Oracle VirtualBox . My processor does not support SLAT (Windows 8 requires SLAT for the hypervisor, and I didn’t want to install Windows Server 2012R2 just for the sake of this), so VirtualBox was chosen. But apparently qemu (the freebsd community seems to use it to create a VHD image) or VirtualBox is somehow not friendly with each other. You have to rebuild the disk using a third-party utility
VhdResize . In it, we change the size of the disk from 20480mb to 1mb more, to 20481mb. In this case, we leave the type of disk as Dynamic. The process is not long, so do not worry. This nonsense is required only for VirtualBox - it is quite possible that Hyper-V will pick up the disk and so (I can not check it).
Create a virtual machine with our already modified disk and boot into FreeBSD.
And here we have a choice. We can create a vm image (virtual machine - template), which will be configured by itself under azure or vm disk - here you are responsible for the configuration of the system under azure.
And so, what we need to create a disk, where we will set everything up:
Create the file /etc/rc.conf and write there:
ifconfig_hn0="SYNCDHCP" hostname="yourvmname.cloudapp.net" sshd_enable="YES"
hn0 - this will be the interface of the virtual network adapter in azure (in VirtualBox it will be em0, in case you need to download something from the network during setup).
Yourvmname is the name that you later give to the virtual machine in azure. Then you can change it, so that it is possible to choose it at random in rc.conf.
sshd_enable = "YES" - without this, the sshd daemon will not start. And so it is clear.
You can edit it using the ee editor (vi is a very obnoxious editor):
cd /etc ee rc.conf
then go to
/ etc / ssh and edit
sshd_config for login resolution for root.
Look for
#PermitRootLogin no , uncomment and write
yes , we get
PermitRootLogin yes . Otherwise, there will be no sense from sshd - we will not go under the root.
You also need to set a password for root through
passwd . By default it is not.
See for yourself about login permissions for root - you can create a user for ssh and root login is not allowed.That's all for creating a vm disk.
If you decide you want to make a vm image (image), that in the ideology of running machines in the cloud is the most correct solution, we will need something completely different.
We take
WALinuxAgent . It is needed to connect the virtual machine with the azure hypervisor and configure the system (provision). Install into the system:
python27, py27-asn1, sudo , copy to the waagent system in the
/ usr / sbin folder and install it:
/ usr / sbin / waagent -install .
You can read more about what WALinuxAgent does on their github page.
in rc.conf, we only need to add sshd launch and network:
ifconfig_hn0="SYNCDHCP" sshd_enable="YES"
waagent will add its own daemon launch to rc.conf during installation.
That's all for creating vm image.
At the moment, waagent starts with some problems (not everything does) and the team actively fixes it on the bugs I found.
If you are good at FreeBSD, you can tune everything for yourself. For example, I remove the delay when the system boots - why wait for the download for an extra 10 seconds if no one else can click anything there.
To do this, you will need to create a file loader.conf in the / boot folder and add to it:
beastie_disable="YES" autoboot_delay="-1"
And so, we finish setup and
shutdown -p nowThird. We need to fill this our disk in azure. Go to azure -> storage -> create a storage account (if not) -> container (if not).
We open
Azure PowerShell , we will become authorized (it seemed to me that it is the most convenient through Certificate method).
And fill the disk in azure storage:
Add-AzureVhd -Destination http://storage.blob.core.windows.net//.vhd -LocalFilePath :\vhd\.vhd
Fourth. It's simple. Go to Virtual Machines -> Disk or VM Image and create a disk or image from the file that we uploaded to storage.
Create disc:

Creating a vm image:

Next, switch to virtual machines and create a machine with our disk / image. Everything should now work.
If you initially created vm image, do not create disks with it - you will not be able to log in. It will start, but will not be available from the outside. And vice versa is also not necessary. Soon I hope to make a port for WALinuxAgent.
And here is the finished image in
Microsoft Depot . We take, we put and no nails.
That's all the difficulty with installing FreeBSD in azure.