Difference between revisions of "FreeBSD Guest Notes"

From Proxmox VE
Jump to navigation Jump to search
(Add note regarding space required for jails and building from source)
 
(25 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
Tweaks and tips for better performance with FreeBSD on KVM.
+
Setting up a FreeBSD Guest on PVE.
 +
:'''Note:''' This has been tested with FreeBSD 13.1 RELEASE.
 +
 
 +
==Pre-Install==
 +
* Find the downloadable ([https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.1/ amd64 dvd1.iso version]).
 +
* Mimimum hardware ([https://docs.freebsd.org/en/books/handbook/bsdinstall/#bsdinstall-hardware requirements])
 +
** 2-4GB RAM
 +
** 8 GB drive space
 +
*** Full install without jails will use at least 5GB
 +
*** If you will be using jails and building kernel from source, use at least 35GB
 +
 
 +
==Create Install Media==
 +
* Option 1: (IDEAL) Using Proxmox GUI, local Storage > Download from URL, copy in ([https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.1/ ISO link]), query it to get file name, and use the contents of the provided ([https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.1/ CHECKSUM file]) to verify the download
 +
* Option 2: Using Proxmox GUI, local Storage > Upload file from your non-Proxmox machine
 +
* Option 3: (for server without internet) Download ISO image and burn to DVD or save to USB drive then transfer to server
  
:'''Note:''' This has only been tested with FreeBSD 9.0-RELEASE (and patch levels).
 
 
==Create VM==
 
==Create VM==
* Download the FreeBSD 9.0-amd64 DVD ISO (from [http://www.freebsd.org/where.html here]) and transfer it to your VM server.
+
* Use "Create VM" in GUI
* Create a new VM:
+
* In "Create: Virtual Machine" use these settings
** CPU: dual-socket or dual-core
+
** "General" - default settings
** RAM: 2GB (minimum)
+
** "OS"
** Network: Intel e1000 (bridged)
+
*** Set "ISO Image" to your downloaded ISO file
** Create a 32GB primary disk (scsi, qcow2)
+
** "System" - default settings
** Add FreeBSD 9.0-amd64 DVD ISO as an optical drive (scsi).
+
** "Disks"
 +
*** Set "Disk Size" to 8GB (or higher)
 +
** "CPU"
 +
*** dual-socket and/or dual-core
 +
** "Memory" - 2GB (minimum)
 +
** "Network" - Virtio
  
 
==Install FreeBSD==
 
==Install FreeBSD==
* Power on the VM.
+
* Start the VM.
* It should boot to the FreeBSD 9.0-amd64 DVD ISO.
+
* Boot menu with countdown will show - just wait and it should boot to the optical drive by default and start the installation
* System Components: Add "src".
+
* ([https://docs.freebsd.org/en/books/handbook/bsdinstall/#bsdinstall-start Installation guide])
* Disks: Guided, use entire disk.
+
* ([https://docs.freebsd.org/en/books/handbook/bsdinstall/#bsdinstall-components System Components])
* Network: Use ipv4 only (unless you also use ipv6).
+
** If you will be installing jail templates, make sure to check "System source tree"
 +
* Network
 +
** Choose vtnet0 VirtIO Networking Adapter
 +
** Use ipv4 ONLY, unless you also use ipv6
 +
* Disks
 +
** Auto (ZFS) Guided Root-on-ZFS, stripe virtual device, choose vtbd0 VirtIO Block Device
 +
** If you are planning to also transfer the image to another cloud host as a standalone OS, make sure they support ZFS, or change your selections accordingly
 
* Services: Add ntpd.
 
* Services: Add ntpd.
* This should leave you with FreeBSD 9 installed on the 32GB primary drive.
+
* Change any other configurations offered. When you get to "Final Configuration" you can select Exit
* Shut down the VM after installation.
+
* This should leave you with FreeBSD 13.1 RELEASE installed on the primary drive
* Remove the ISO from the VM's optical drive (set to empty).
+
* Reboot
* Verify the VM's boot order is set to the primary hard disk first.
+
* After reboot, check:
 +
** In VM > Hardware remove the ISO from the VM's optical drive (set to empty)
 +
** Verify in VM > Options the boot order is set to the primary hard disk first
 +
 
 
==First Boot==
 
==First Boot==
 
* Power on the VM and log in.
 
* Power on the VM and log in.
Line 35: Line 62:
 
</pre>
 
</pre>
 
* Reboot
 
* Reboot
==Enable Virtio==
 
* Install virtio-kmod:
 
<pre>
 
cd /usr/ports/emulators/virtio-kmod && make clean install
 
</pre>
 
* When prompted on each required package, accept defaults and OK.
 
* Copy the virtio modules into <code>/boot/kernel</code> directory:
 
<pre>
 
cp -Rp /usr/local/modules/* /boot/kernel/
 
kldxref /boot/kernel
 
</pre>
 
* Add the following to <code>/boot/loader.conf</code>:
 
<pre>
 
virtio_load="YES"
 
virtio_pci_load="YES"
 
virtio_blk_load="YES"
 
if_vtnet_load="YES"
 
virtio_balloon_load="YES"
 
</pre>
 
* Enable virtio for disk by changing your <code>/etc/fstab</code> entries to use the '''vtbd''' prefix. Example:
 
<pre>
 
# Device        Mountpoint      FStype  Options Dump    Pass#
 
/dev/vtbd0p2    /              ufs    rw      1      1
 
/dev/vtbd0p3    none            swap    sw      0      0
 
</pre>
 
* Enable virtio for network by changing the <code>ifconfig_em0="DHCP"</code> line in <code>/etc/rc.conf</code> to:
 
<pre>
 
ifconfig_vtnet0="DHCP"
 
</pre>
 
* Shutdown the VM
 
<pre>
 
shutdown -p now
 
</pre>
 
* Change VM's network and disk hardware to use virtio.
 
* Power on the VM.
 
* Verify that virtio is loading:
 
 
<pre>
 
<pre>
kldstat
+
reboot
 
 
Id Refs Address            Size    Name
 
1  12 0xffffffff80200000 11cdab0  kernel
 
2    5 0xffffffff813ce000 4ca0    virtio.ko
 
3    1 0xffffffff813d3000 5880    virtio_pci.ko
 
4    1 0xffffffff813d9000 5010    virtio_blk.ko
 
5    1 0xffffffff813df000 aeb0    if_vtnet.ko
 
6    1 0xffffffff813ea000 3210    virtio_balloon.ko
 
 
</pre>
 
</pre>
==Update Ports==
 
It is a good idea to keep your installed ports up to date. This section shows you how to do so.
 
:'''IMPORTANT:''' It is recommended practice to understand how port updates will impact your system. Some port upgrades can change the way the program works and can break the function of your machine. '''It is wise to do a full backup of your VM before updating ports.'''
 
* Update ports tree using [http://www.freebsd.org/doc/handbook/updating-upgrading-portsnap.html portsnap]:
 
<pre>
 
portsnap fetch update
 
</pre>
 
* Install portmaster:
 
 
==External Links==
 
* [http://viktorpetersson.com/2012/01/16/how-to-upgrade-freebsd-8-2-to-freebsd-9-0-with-virtio/ How to upgrade FreeBSD 8.2 to FreeBSD 9.0 with Virtio] - contains useful information on setting up virtio on freebsd 9.
 
* [http://www.freshports.org/emulators/virtio-kmod FreshPorts virtio-kmod] page.
 
* [http://www.freebsd.org/doc/handbook/updating-upgrading-portsnap.html FreeBSD Handbook - Portsnap: a Ports Collection Update Tool]
 

Latest revision as of 19:03, 6 January 2023

Setting up a FreeBSD Guest on PVE.

Note: This has been tested with FreeBSD 13.1 RELEASE.

Pre-Install

  • Find the downloadable (amd64 dvd1.iso version).
  • Mimimum hardware (requirements)
    • 2-4GB RAM
    • 8 GB drive space
      • Full install without jails will use at least 5GB
      • If you will be using jails and building kernel from source, use at least 35GB

Create Install Media

  • Option 1: (IDEAL) Using Proxmox GUI, local Storage > Download from URL, copy in (ISO link), query it to get file name, and use the contents of the provided (CHECKSUM file) to verify the download
  • Option 2: Using Proxmox GUI, local Storage > Upload file from your non-Proxmox machine
  • Option 3: (for server without internet) Download ISO image and burn to DVD or save to USB drive then transfer to server

Create VM

  • Use "Create VM" in GUI
  • In "Create: Virtual Machine" use these settings
    • "General" - default settings
    • "OS"
      • Set "ISO Image" to your downloaded ISO file
    • "System" - default settings
    • "Disks"
      • Set "Disk Size" to 8GB (or higher)
    • "CPU"
      • dual-socket and/or dual-core
    • "Memory" - 2GB (minimum)
    • "Network" - Virtio

Install FreeBSD

  • Start the VM.
  • Boot menu with countdown will show - just wait and it should boot to the optical drive by default and start the installation
  • (Installation guide)
  • (System Components)
    • If you will be installing jail templates, make sure to check "System source tree"
  • Network
    • Choose vtnet0 VirtIO Networking Adapter
    • Use ipv4 ONLY, unless you also use ipv6
  • Disks
    • Auto (ZFS) Guided Root-on-ZFS, stripe virtual device, choose vtbd0 VirtIO Block Device
    • If you are planning to also transfer the image to another cloud host as a standalone OS, make sure they support ZFS, or change your selections accordingly
  • Services: Add ntpd.
  • Change any other configurations offered. When you get to "Final Configuration" you can select Exit
  • This should leave you with FreeBSD 13.1 RELEASE installed on the primary drive
  • Reboot
  • After reboot, check:
    • In VM > Hardware remove the ISO from the VM's optical drive (set to empty)
    • Verify in VM > Options the boot order is set to the primary hard disk first

First Boot

  • Power on the VM and log in.
  • Set the time:
ntpdate -s pool.ntp.org
  • Update the system:
freebsd-update fetch
freebsd-update install
  • Reboot
reboot