Installing FreeBSD on old dedicated servers via Linux Rescue System

0 Shares
0
0
0
0

Introduction

Hetzner no longer offers a FreeBSD rescue system. For dedicated servers with full UEFI support, there is a tutorial that shows how to install FreeBSD with OpenZFS from a Linux rescue system. For older servers that only have minimal UEFI support and require a legacy BIOS boot, there is another way to install FreeBSD.

Prerequisites
  • The Hetzner dedicated server is booted into Linux rescue mode with SSH access working.
  • IPv6 network configuration parameters

Step 1 – Download the FreeBSD distribution archive

Download base.txz and kernel.txz from FreeBSD:

curl -O http://ftp2.de.freebsd.org/pub/FreeBSD/releases/amd64/14.0-RELEASE/base.txz
curl -O http://ftp2.de.freebsd.org/pub/FreeBSD/releases/amd64/14.0-RELEASE/kernel.txz

Step 2 – Download the VM container and install mfsBSD

We use the mfsBSD virtual machine to install FreeBSD on the system drives.

Download ISO image:

curl -O https://mfsbsd.vx.sk/files/iso/14/amd64/mfsbsd-14.0-RELEASE-amd64.iso

Step 3 – Launch the mfsBSD virtual machine from the ISO image

Server disks are transferred to the VM as SCSI devices using virtio.

In the following command, replace /dev/nvme0n1 and /dev/nvme1n1 as needed:

qemu-system-x86_64 -net nic -net user,hostfwd=tcp::1022-:22 -m 2048M -enable-kvm \
-cpu host,+nx -M pc -smp 2 -vga std -k en-us \
-cdrom ./mfsbsd-14.0-RELEASE-amd64.iso \
-device virtio-scsi-pci,id=scsi0 \
-drive file=/dev/nvme0n1,if=none,format=raw,discard=unmap,aio=native,cache=none,id=n0 \
-device scsi-hd,drive=n0,bus=scsi0.0 \
-drive file=/dev/nvme1n1,if=none,format=raw,discard=unmap,aio=native,cache=none,id=n1 \
-device scsi-hd,drive=n1,bus=scsi0.0 \
-boot once=d -vnc 127.0.0.1:0,password=on -monitor stdio

The SSH service inside the VM is available on port 1022 of the rescue system.

Set a VNC password to allow access to VNC (optional)

To connect to VNC you need to forward port 5900 using SSH!

(qemu) set_password vnc mfsroot
(qemu) 

Step 4 – Copy the distribution files to the VM

On the Linux rescue system root shell, run the following command:

scp -o Port=1022 base.txz kernel.txz root@localhost:

The root password inside the virtual machine is mfsroot.

Step 5 – Log into the VM

Use SSH to log into the VM from a shell on the rescue system:

ssh -p 1022 root@localhost

The password is mfsroot.

Check that the drives are visible:

dmesg | grep QEMU
cd0: <QEMU QEMU DVD-ROM 2.5+> Removable CD-ROM SCSI device
da0: <QEMU QEMU HARDDISK 2.5+> Fixed Direct Access SPC-3 SCSI device
da1: <QEMU QEMU HARDDISK 2.5+> Fixed Direct Access SPC-3 SCSI device

Step 6 – Install FreeBSD

Install FreeBSD with the zfsinstall script:

zfsinstall -d /dev/da0 -d /dev/da1 -r mirror -p zroot -s 16G -u .

This will install FreeBSD on the ZFS pool zroot using RAID-1 (mirroring) on both disks with 16GB of swap space on each disk.

The installed FreeBSD root filesystem is mounted on /mnt. Since we are running the current version of FreeBSD in a VM, we can now use chroot to configure the new installation:

mount -t devfs devfs /mnt/dev
chroot /mnt

Step 7 – Configure FreeBSD

Once we have used chroot to run a shell in the installed FreeBSD environment, we can complete the configuration.

  • Set a root password
passwd
  • Enable root login with password
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
  • Set the hostname and enable sshd and our newly created autodhcpd script

Create the file /etc/rc.conf with the following content:

cat << EOF > /etc/rc.conf
zfs_enable="YES"
hostname="myhost.mydomain"
sshd_enable="YES"
EOF

Step 8 – Configure Network Settings

If your server uses a RealTec-based network card, your interface name is most likely re0. If your server uses an Intel-based network card, it is named em0 or igb0. If in doubt, use Google to find out what your NIC is called in FreeBSD.

Add the following lines to the /etc/rc.conf file:

cat <<EOF >>/etc/rc.conf
ifconfig_em0="192.168.0.2/27"
static_routes="gateway default"
route_gateway="-host 192.168.0.1 -interface em0"
route_default="default 192.168.0.1"
ifconfig_em0_ipv6="inet6 2a01:4f8:0:0::2/64"
ipv6_defaultrouter="fe80::1%em0"
EOF

Step 9 – Cleaning

Exit the chroot environment and unmount the filesystems.

exit
sync
umount /mnt/dev
umount /mnt/var
umount /mnt/tmp
umount /mnt

You can shut down the qemu virtual machine or terminate the qemu process. With everything set up, you can restart the server on your FreeBSD distribution:

reboot

Result

تبریک می گویم! شما اکنون یک نصب FreeBSD دارید که به پشتیبانی کامل UEFI نیاز ندارد.
Leave a Reply

Your email address will not be published. Required fields are marked *


You May Also Like
Comparison of the best AI image editing models Qwen, UMO, Flux Kontext, Nano Banana

Comparison of the best AI image editing models Qwen, UMO, Flux Kontext, Nano Banana

This article provides an in-depth and practical review of AI models such as Qwen, UMO, Flux Kontext, and Nano Banana. These models offer specific features and capabilities based on different needs and infrastructures for image editing. With this article, you will achieve a better and more optimal choice of the right model for your projects.