Installation of operating system on Proxmox VE can be done in various methods. The most common is installation from ISO image, but there is another option of using a ready Qcow2 image. QCOW2 (QEMU Copy-On-Write 2) is a popular image format used in the space of Virtual Machines known to provide excellent compression and cloning speed. This image format is loved by many because of its effective space usage reduction and the short time required for data replication hence general improved VM performance.

If you’re using Proxmox Virtual Environment, it’s pretty simple and straightforward procedure to import Qcow2 OS image. This method is commonly used when migrating a VM instance from other virtualized environments such as KVM or OpenStack. In this short tutorial, we are honored to present you with the necessary steps to download, import qcow2 image, and run an instance of FreeBSD 14 operating system on Proxmox VE.

Download FreeBSD 14 Qcow2 image

FreeBSD is the most popular BSD open source operating system that can be installed on amd64, i386, aarch64, and riscv64 hardware. FreeBSD supports a variety of peripherals and configurations and is suitable for hosting production services, software development, or for Internet Service Provision.

Visit FreeBSD 14 Downloads page and get the latest VM image release.

FreeBSD Import Qcow2 Image 01

FreeBSD 14 release comes with everything needed to run a system, this includes the source code for the kernel and other utilities bundled in the base distribution. FreeBSD 14.0 got lots of improved hardware support, and it now has 1024 CPU cores limit up from 256 limit. Other updates are OpenZFS file-system and upgraded LLVM Clang toolchain, among other additions. All the new improvements are meant to guarantee better stability, performance, and security

In my local system the file is inside the Downloads folder.

$ ls FreeBSD-14.0-RELEASE-amd64.qcow2.xz
FreeBSD-14.0-RELEASE-amd64.qcow2.xz

Let’s copy the file to Proxmox VE server.

scp FreeBSD-14.0-RELEASE-amd64.qcow2.xz pve03:

Login to your Proxmox server.

ssh pve03

Create FreeBSD Virtual Machine

Extract downloaded file since it has .xz compression format.

unxz -v FreeBSD-14.0-RELEASE-amd64.qcow2.xz 

If you are missing check How To Extract .xz files on a Linux System.

$ ls FreeBSD-14.0-RELEASE-amd64.qcow2
FreeBSD-14.0-RELEASE-amd64.qcow2

After extracting the file, resize the base image to desired disk size. We are setting the size and image name in the variables provided below.

SIZE=40G
IMAGE=FreeBSD-14.0-RELEASE-amd64.qcow2
qemu-img resize $IMAGE $SIZE

List network bridges in your system.

$ brctl show
bridge name	bridge id		STP enabled	interfaces
vmbr0		8000.6c4b9008749b	no		enp0s31f6
							tap100i0
							tap102i0
							tap103i0
							veth114i0
vmbr30		8000.6c4b9008749b	no		enp0s31f6.30

Check storage pools in your Proxmox VE server.

# pvesm status
Name              Type     Status           Total            Used       Available        %
extra_data     lvmthin     active       122404864         7026039       115378824    5.74%
local              dir     active       100597760        38148936        62448824   37.92%
local-lvm      lvmthin     active       832888832        28901242       803987589    3.47%

Some other parameters are required when creating the virtual machine such as network bridge name, default RAM size, CPU cores and storage domain. We can set the values as variables for ease of use or update.

#Default network bridge name
BRIDGE=vmbr0 

#Default VM Ram size
RAM=4096 

#Default CPU cores
CORES=1 

#Storage pool name to use, check with pvesm status
STORAGE=local-lvm

Get the next VM ID to be used.

VMID=$(pvesh get /cluster/nextid)

Create a Virtual Machine instance template. We will import Qcow2 image into this.

qm create $VMID --memory $RAM --cores $CORES  --net0 virtio,bridge=$BRIDGE --scsihw virtio-scsi-pci

After creating a Virtual Machine we need to import the base image into the actual VM storage disk.

# qm importdisk $VMID $IMAGE $STORAGE
importing disk 'FreeBSD-14.0-RELEASE-amd64.qcow2' to VM 105 ...
  Logical volume "vm-105-disk-0" created.
transferred 0.0 B of 40.0 GiB (0.00%)
transferred 417.8 MiB of 40.0 GiB (1.02%)
transferred 835.6 MiB of 40.0 GiB (2.04%)
transferred 1.2 GiB of 40.0 GiB (3.05%)
transferred 1.6 GiB of 40.0 GiB (4.07%)
transferred 2.0 GiB of 40.0 GiB (5.08%)
....
transferred 39.6 GiB of 40.0 GiB (98.88%)
transferred 40.0 GiB of 40.0 GiB (99.89%)
transferred 40.0 GiB of 40.0 GiB (100.00%)
transferred 40.0 GiB of 40.0 GiB (100.00%)
Successfully imported disk as 'unused0:local-lvm:vm-105-disk-0'

Attach the disk into the Virtual Machine after importation succeeds.

# qm set $VMID --scsihw virtio-scsi-pci --virtio0 $STORAGE:vm-$VMID-disk-0
update VM 105: -scsihw virtio-scsi-pci -virtio0 local-lvm:vm-105-disk-0

Change the boot order to start with SCSI or VirtIO block device.

# qm set $VMID --boot c --bootdisk virtio0
update VM 105: -boot c -bootdisk virtio0

Set a name to the VM instance.

VMNAME=FreeBSD-14
qm set $VMID --name $VMNAME

Set the VM to start on system boot

qm set $VMID --onboot 1

Start the VM instance from the terminal or web interface.

qm start $VMID

From Proxmox VE web console you can see the process of starting the instance.

FreeBSD Import Qcow2 Image 02

If you encounter an error shown in the screenshot when you try to start the VM

FreeBSD Import Qcow2 Image 03

Then edit the VM hardware settings and set Display to “Default”.

FreeBSD Import Qcow2 Image 04 1

Enable SSHD Service

For remote access to FreeBSD virtual machine we just configured, we need to enable OpenSSH server service. The package should be installed already in the OS, we just need to enable it.

Add the line sshd_enable=YES to enable automatic start of SSH service in the VM.

echo sshd_enable=YES|tee -a /etc/rc.conf

The service is not started by default, let’s make sure it’s running.

service sshd start

Since we didn’t perform the installation from ISO, we will need to change the root user password to a known password. This can be done with the help of passwd command while passing the username as an option.

passwd root

Install vim package to help you edit

pkg install vim

Edit the file and enable SSH password authentication and root user access through ssh. This can be a temporary measure to enable you copy your SSH public key over then disable.

# vim /etc/ssh/sshd_config
PasswordAuthentication yes
PermitRootLogin yes

Here is a screenshot from my file edit.

FreeBSD Import Qcow2 Image 06

Restart sshd service after saving the changes into the file.

service sshd restart

From your local workstation system copy your ssh public key.

ssh-copy-id root@FreeBSDIP

Test ssh access with the key and not password authentication.

Last login: Sat Apr 13 07:14:55 2024 from 192.168.1.151
FreeBSD 14.0-RELEASE (GENERIC) #0 releng/14.0-n265380-f9716eee8ab4: Fri Nov 10 05:57:23 UTC 2023

Welcome to FreeBSD!

Release Notes, Errata: https://www.FreeBSD.org/releases/
Security Advisories:   https://www.FreeBSD.org/security/
FreeBSD Handbook:      https://www.FreeBSD.org/handbook/
FreeBSD FAQ:           https://www.FreeBSD.org/faq/
Questions List:        https://www.FreeBSD.org/lists/questions/
FreeBSD Forums:        https://forums.FreeBSD.org/

Documents installed with the system are in the /usr/local/share/doc/freebsd/
directory, or can be installed later with:  pkg install en-freebsd-doc
For other languages, replace "en" with a language code like de or fr.

Show the version of FreeBSD installed:  freebsd-version ; uname -a
Please include that output and any error messages when posting questions.
Introduction to manual pages:  man man
FreeBSD directory layout:      man hier

To change this login announcement, see motd(5).
root@freebsd:~ #

Thereafter, you are free to disable password authentication and restart sshd service.

PasswordAuthentication no

Adding a user on FreeBSD system

Our system only has root user but we can add extra users in our FreeBSD. The following example adds a user called freebsd and sets a password for the user. We are also adding the user to wheel system group to allow sudo privileges.

pw useradd freebsd -m
passwd freebsd
pw groupmod wheel -m freebsd

Install sudo package to allow users perform privilege escalation.

pkg install -y sudo

Once the package has been installed, all root privilege to a user.

# export EDITOR=vim
# visudo
# add to last line
freebsd    ALL=(ALL:ALL) ALL

Copy ssh public key for passwordless authentication

 ssh-copy-id freebsd@FreeBSDIP

Test SSH access as user created

$ ssh freebsd@FreeBSDIP
freebsd@freebsd14:~ $ sudo su -
Password: <INPUT-USER-PASSWORD>
root@freebsd:~ #

We can confirm the user is able to login and assume root user privileges using sudo. In this article we’ve been successful in importing a Qcow2 image of FreeBSD 14 in our Proxmox VE server. We proceeded to perform normal extra steps of enabling SSH and adding a standard user into the system. A similar process can be used for any other operating system distributed in Qcow2 image format. Thank you for visiting our website and enjoy your week/weekend ahead.

LEAVE A REPLY

Please enter your comment!
Please enter your name here