-
Notifications
You must be signed in to change notification settings - Fork 8
NetBSD UEFI
NetBSD supports UEFI firmware (BIOS replacement) and work very well even under Hyper-V
Worked pretty well without any issue.
Tested Host:
- HW: MSI-7250 board, AMD Opteron X2 dual core, 8GB RAM
- OS Hypervisor: Windows Server 2012R2 with Hyper-V Role and Hyper-V Manager
Tested Guest:
- NetBSD 10 RC1
- UEFI Mode (knowns as "Generation 2" under Hyper-V)
How I installed it:
curl -fLO https://cdn.netbsd.org/pub/NetBSD/NetBSD-10.0_RC1/images/NetBSD-10.0_RC1-amd64-install.img.gz
gzip -dkv NetBSD-10.0_RC1-amd64-install.img.gz
# WARNING! Conversion must be done at NON-NTFS filesystem (FAT32 or exFAT), probably
# due broken sparese files support in QEMU
qemu-img convert -p -f raw -O vhdx NetBSD-10.0_RC1-amd64-install.img nbsd10rc1-install.vhdx
- Now copy
nbsd10rc1-install.vhdx
to target Hyper-V disk where it will be used. IMPORTANT! Target must be on NTFS (Hyper-V depends on specific NTFS features to run VM!) - Also create new empty VHDX for installation Target (where we will install NetBSD). Here is Windows PowerShell example:
$vhd="C:\Hyper-V\Virtual Disks\nbsd10rc1-uefi.vhdx"
new-vhd -Path $vhd -Dynamic -SizeBytes 30GB -BlockSizeBytes 1MB `
-LogicalSectorSizeBytes 512 -PhysicalSectorSizeBytes 4096
Important: I use block-size 1MB (default is 32MB) to avoid excessive VHDX size (because with 32MB blocks, there has to be 32MB of all zeroes to reclaim such block as unused - which is very unlikely).
New in Hyper-V create VM and specify:
- 1 or more CPU
- Generation 2 (UEFI)
- 2GB RAM (or more)
- attach existing disk - and specify full path to target disk, in my
case
C:\Hyper-V\Virtual Disks\nbsd10rc1-uefi.vhdx
(there we will install NetBSD) - after Finish select "SCSCI controller" and
Add existing disk - this time
nbsd10rc1-install.vhdx
(this contains NetBSD installation files) - now go to Firmware
- disable "Secure" Boot (!)
- ensure that boot order is
-
nbsd10rc1-uefi.vhdx
(empty disk where will be NetBSD installed) -
nbsd10rc1-install.vhdx
NetBSD installation disk - Network (not used, but I don't know how to remove it)
-
And start VM - the installation should proceed fine without any issues...
Proxmox VM:
- OS Type:
Linux 6.x - 2.6 kernel
(intentional - to avoid emulating too old hardware) - Machine:
Default (i440fx)
- BIOS:
OVMF (UEFI)
- 1xCPU,
host
passtrough - 2GB RAM
- Disk: Virtio BLK, 32GB
And here is GPT partition layout:
$ sysctl hw.disknames
hw.disknames = ld0 dk0 dk1 dk2 cd0
$ fdisk ld0
...
Partition table:
0: GPT Protective MBR (sysid 238)
start 1, size 67108863 (32768 MB, Cyls 0-4177/85/4)
PBR is not bootable: Bad magic number (0x0000)
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
No active partition.
Drive serial number: 0 (0x00000000)
$ gpt show ld0
start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 30 Unused
64 262144 1 GPT part - EFI System
262208 62664576 2 GPT part - NetBSD FFSv1/FFSv2
62926784 4182016 3 GPT part - NetBSD swap
67108800 31 Unused
67108831 32 Sec GPT table
67108863 1 Sec GPT header
Now using Wedges to access GPT partitions:
$ dkctl ld0 listwedges
/dev/rld0: 3 wedges:
dk0: 1369ba6d-3be2-49f6-afc6-0e5faf5a10b9, 262144 blocks at 64, type: msdos
dk1: 9a447701-b2bf-49cd-b21a-86b066eff3d9, 62664576 blocks at 262208, type: ffs
dk2: 05fde297-57bc-4a4c-8622-18c4ab5985a8, 4182016 blocks at 62926784, type: swap
Example mounting read-only ESP partition with UEFI loader:
mount -r -t msdos /dev/dk0 /mnt
- Original boot loader is
/usr/mdec/bootx64.efi
-
bootx64.efi
source in under/usr/src/sys/arch/i386/stand/efiboot/bootx64
Copyright © Henryk Paluch. All rights reserved.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License