For the complete documentation index, see llms.txt. This page is also available as Markdown.

16.5 Installing FreeBSD on Alibaba Cloud Lightweight Server (UEFI/GPT)

This section demonstrates installing FreeBSD via UEFI + GPT on an Alibaba Cloud Simple Application Server, using Rocky Linux 9 as the intermediate host system for deployment.

Server Environment

Rocky Linux 9

Reset the server system to Rocky Linux 9. This distribution holds a mainstream position in the server market, and most service providers offer support.

Rescue Login

Configure rescue login.

Rocky Linux 9

Most of the operations described in this section are completed through VNC connection (rescue login).

Rocky Linux 9

For convenience, you can temporarily set rescue login as the default login method.

Rocky Linux 9

The rescue login interface is shown above. You can use the "Copy Command" option in the upper right corner to copy longer commands to the terminal for execution.

Verifying Whether the Server Is in a UEFI Environment

This section targets UEFI boot environments and GPT partition tables, so you must first confirm whether the server is using a UEFI boot environment and GPT partition table. Several methods are provided below for reference.

  • Determine whether the current system booted in UEFI or BIOS mode through the system firmware:

  • Determine the boot mode through the UEFI boot tool:

Server Disk Partition Layout

  • Determine through file system type and disk usage (also note that /dev/vda2 is mounted at /boot/efi, which indicates the system is using UEFI mode):

  • Determine through the static file system mount configuration:

  • View the UUID and file system type of block devices:

  • Probe file system information for a specified block device:

The BIOS Boot partition is used for compatibility with traditional BIOS booting.

Viewing System Hostname and System Information

Viewing Network Information

  • Display all network interfaces and their IP address information:

  • Display the system routing table:

  • List all PCI buses and their device information:

Installing FreeBSD via Raw Disk Image

Alibaba Cloud Simple Application Server supports installing FreeBSD via raw disk image. Please pay attention to the following warning before proceeding.

Warning

This operation will result in the loss of all data. Please complete data backup before proceeding. Based on testing, snapshots may not roll back correctly after the operation, but custom images can be used for indirect restoration.

Download and write the FreeBSD ZFS image to /dev/vda:

Parameter descriptions:

Parameter
Description

wget -qO- URL

-q silent mode, does not display download progress; -O- outputs downloaded content to standard output (stdout)

xzcat

Decompresses xz format files and outputs the decompressed content to standard output

dd of=/dev/vda

Writes input to the /dev/vda device (the entire disk, not a specific partition)

bs=4M

Sets block size to 4 MB, improving write efficiency

status=progress

Displays dd write progress

Writing FreeBSD ZFS image to the entire disk

Then, in the Alibaba Cloud management console, select "More Operations" and "Restart" in sequence.

Force reboot instance

Check the "Force reboot instance" option.

Reboot instance

Execute a forced reboot to enter FreeBSD.

Based on reader feedback and actual testing, installing or upgrading FreeBSD on paravirtualized platforms may encounter issues, such as problems with the VirtIO-BLK storage device driver on Alibaba Cloud.

FreeBSD system on first boot

At this point, when the FreeBSD system boots, at the loader menu interface (shown in the image above), press ESC to enter the "OK" command prompt.

Adjusting tunables

On this interface, enter set kern.maxphys=65536 to set the maximum physical I/O size of the kernel to 65536 bytes (large block I/O can sometimes trigger driver or cache issues), press Enter to confirm, then enter boot and press Enter to boot normally.

Then proceed with the normal installation process, selecting the ZFS partitioning method.

Installing FreeBSD system

After the FreeBSD system has fully booted, permanently set the maximum I/O buffer size in the boot loader configuration file:

Without this setting, the system may still get stuck at the boot interface on the next startup.

Next, list the FreeBSD system disk partition table and partition information:

It can be observed that the system has automatically expanded the disk capacity.

View the FreeBSD system network interface information:

You can verify network connectivity by pinging common websites.

Display kernel boot information and kernel logs:

Installing FreeBSD Indirectly via mfsBSD

mfsBSD is a minimal FreeBSD memory disk image that supports UEFI and ZFS environments, and can be used to install FreeBSD or serve as a rescue disk. The download address for mfsBSD is: mfsBSD and mfslinux.

Warning

Do not select any version with a suffix, such as special edition or mini edition. See the troubleshooting section.

Transfer the mfsBSD ISO image to Rocky Linux via WinSCP:

WinSCP file transfer

Write the mfsBSD ISO image to /dev/vda (block size 4 MB, with progress display):

Force reboot the instance to boot into mfsBSD. When entering the boot menu interface, configure kern.maxphys as described in the previous section, otherwise the hard disk cannot be properly recognized.

Warning

Do not use the minimal system mfsbsd-mini-14.2-RELEASE-amd64.iso as a substitute; it cannot adjust the tunable parameter kern.maxphys, resulting in boot failure.

mfsbsd-mini boot interface

Even after manually specifying the tunable parameter, it still fails.

mfsbsd-mini boot interface

After fully booting, enter the password to log in to the root account; the default password is mfsroot.

Observe the mfsBSD disk partition layout:

As can be seen, most partitions are marked as [CORRUPT], which will affect system installation, so the GPT partition table must be repaired first:

UFS Installation

Execute bsdinstall to start the installation; the process can be found in other related sections of this chapter.

UFS installation

After installation, connect to the FreeBSD machine using JuiceSSH:

UFS installation

ZFS Installation

In the Shell interface, execute the following command to manually load the ZFS kernel module:

No output indicates successful loading.

You can also verify the ZFS module loading status with the following command:

If there is relevant output, you can proceed to enter the command bsdinstall to start the normal installation process.

The machine in this experiment has only 1 GB of memory. After mfsBSD uses approximately 100 MB, the available memory is less than 800 MB. Therefore, specifying ZFS installation will result in a "Distribution extract failed" error:

Distribution extract failed

To view the actual error message, press Ctrl + C to return to the Shell interface, and observe through the following command:

"failed to reclaim memory" indicates a memory reclaim failure. The extraction process 1562 was forcibly terminated due to insufficient memory.

This requires further testing; interested readers can also submit a PR after testing.

Troubleshooting and Unfinished Business

Several methods were attempted during the actual operations in this section, but ultimately only two methods were relatively successful. To facilitate research by interested readers, the incomplete methods are listed here for future reference.

Error During Installation: sysctl: unknown oid 'vfs.zfs.min_auto_ashift'

Analyzing the error message: literally, this parameter is used to set ZFS 4K alignment, and the error indicates that the parameter is unknown. Therefore, the problem is first located in the ZFS module.

This is usually caused by not manually loading the ZFS kernel module in advance.

The solution is to execute the command kldload zfs to manually load the kernel module as described above.

This may be a long-standing but difficult-to-reproduce bug; see: FreeBSD Project. Bug 249157 - installer reports sysctl: unknown oid 'vfs.zfs.min_auto_ashift' when ZFS module not loaded[EB/OL]. [2026-03-26]. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=249157.

File System Does Not Support Online Shrinking

EXT2, EXT3, EXT4, and XFS file systems do not support online shrinking (Btrfs supports online shrinking but may have stability issues). There is currently no universal solution for this.

Cannot Find UEFI Boot Entry, Goes Directly to UEFI Shell After Booting

Cannot find UEFI boot entry

Confirm that the selected image actually supports UEFI booting; for example, mfslinux and TinyCore-current.iso do not support UEFI booting.

Cannot Find Root Partition

The image should be written to the entire disk (e.g., /dev/vda), not to a single partition (e.g., /dev/vda2), otherwise the following error may occur:

Not written to the entire disk, written to the EFI partition

Even if the root partition is manually specified, the following error may still occur:

Not written to the entire disk, written to the EFI partition

Installing FreeBSD via Ventoy

Ventoy is a new-generation multi-system bootable USB solution. Its project website is Ventoy.

The basic idea is to write Ventoy to the entire hard disk through a memory disk system, then mount the larger disk partition created by Ventoy to the memory disk, and write the FreeBSD system to this disk partition.

Then force reboot the instance to boot into Ventoy for system installation.

Ventoy Usage Method

Download the Ventoy Linux compressed package from the Nanjing University mirror:

Extract the Ventoy files and directories in the current directory:

Install Ventoy to the hard disk:

Ventoy installation interface

Ventoy2Disk.sh parameter descriptions:

  • -I: Force install

  • -g: Use GPT partition table

Verify the Ventoy installation through the command:

Verify Ventoy installation

Readers can learn more through Installing Ventoy on Linux — Command Line Interface.

Writing Ventoy Using Ventoy LiveCD

The Ventoy LiveCD download address is Installation Package.

Ventoy LiveCD is not Ventoy itself, but a memory disk system image used to install Ventoy. See: Ventoy Team. Ventoy LiveCD Usage Instructions[EB/OL]. [2026-03-26]. https://www.ventoy.net/en/doc_livecd.html.

After using dd to write the image to the entire hard disk, force reboot the instance; Ventoy LiveCD can boot normally.

Ventoy LiveCD boot interface

In the configuration options, allow all types of disks.

Ventoy configuration options

Install Ventoy to the entire disk.

Install Ventoy to disk

After force rebooting the instance, the system can correctly boot into Ventoy.

Ventoy boot menu

Ventoy currently does not support downloading ISO image files online.

Therefore, this method cannot proceed further.

You need to use another memory disk to write the image to the hard disk before booting Ventoy.

Writing Ventoy Using TinyCorePure64

TinyCorePure64 belongs to the Core project, which is a highly modular system that supports community-customized builds.

TinyCorePure64 can be entirely loaded into memory after booting, and all data will be lost after reboot.

The TinyCorePure64 download address is x86 Pure 64; after entering the page, click "Core Pure 64 Latest Build" and select "TinyCorePure64-16.2.iso" or a similar version to download.

Note

Do not mistakenly download "CorePure64"; CorePure64 does not support UEFI boot environments.

Warning

Writing to a block device with dd will overwrite all existing data on the disk, and this operation is irreversible. Please double-check that the device path specified by the of= parameter is correct.

Force reboot the instance to boot into TinyCorePure64.

Boot into TinyCorePure64

Select the last item "corew" because the default graphical interface (tc) may behave abnormally when executing commands via VNC. Additionally, the Ventoy graphical interface cannot run under its GUI because the libc format is incompatible.

Observe the partition layout:

TinyCorePure64 partition layout

View in detail:

TinyCorePure64 partition details

TinyCorePure64 is a minimal distribution that lacks many tools required by Ventoy, so they need to be installed manually.

Configure the Tiny Core Linux mirror source address, specifying the NetEase open source mirror as the download source:

Install exFAT tools, partition tools, FAT file system tools, Linux utility set, and certificate components:

Note

This package manager cannot run with root privileges.

Following the content in the above sections, install Ventoy to the entire disk. Then mount the disk generated by Ventoy to the memory disk.

Download the FreeBSD 15.0 Bootonly ISO image from the mirror to Ventoy using the specified user agent:

Force reboot the instance into Ventoy.

Ventoy boot menu

Set the tunable parameter kern.maxphys in the boot menu, then continue booting the FreeBSD system.

List the disk partition layout:

Disk partition layout

The disk is in read-only state, and no operations can be performed, including deleting the partition table, formatting, or using dd to write zeros.

All the above operations produce the following error:

Read-only disk error

Therefore, no installation operations can be performed.

Appendix: Useful Commands That May Be Needed

Example of unmounting the EFI partition:

Reformat the EFI partition as a FAT32 file system:

Warning

mkfs.vfat will format the specified partition, and existing data on the partition will be permanently lost. Please confirm the device path is correct.

View the file system type of the /dev/vda2 partition:

References

  • Ventoy. Ventoy — A New Bootable USB Solution[EB/OL]. [2026-04-17]. https://www.ventoy.net. Ventoy project homepage, a new-generation multi-system bootable USB solution that supports booting directly from ISO images.

  • FreeBSD Project. FreeBSD 15.0-RELEASE Release Notes[EB/OL]. [2026-04-17]. https://www.freebsd.org/releases/15.0R/relnotes/. FreeBSD 15.0 release notes, including VirtIO driver improvements and kernel tunable parameter changes.

Last updated