Introduction
Installing NetBSD-10 on the Raspberry Pi 4 is much the same as installing it on the Raspberry Pi 3. Refer to this article for more details: Installing NetBSD-10 on Raspberry Pi 3.
There are however some differences:
- The Raspberry Pi 4 uses different EEPROM to boot the system and can boot directly from GPT partitions.
- The Raspberry Pi 4’s UEFI firmware is capable of booting NetBSD-10.
For further information on updating the Raspberry Pi 4’s EEPROM, please refer to this link: Raspberry Pi boot EEPROM.
NetBSD Installation Steps
Several steps are required to install NetBSD. The following sections explain each step in greater detail.
Step 1: Create GPT Partitions
The first step in installing NetBSD is to create required GPT partitions. In this example, a microSD card is used, which is detected as sd0 device:
gpt destroy sd0
gpt create -f sd0
gpt add -a 1m -l "EFI-system" -t efi -s 128m sd0
gpt add -a 1m -l "NetBSD-root" -t ffs -s 8g sd0
gpt add -a 1m -l "NetBSD-swap" -t swap -s 4g sd0
gpt add -a 1m -l "NetBSD-var" -t ffs -s 4g sd0
gpt add -a 1m -l "NetBSD-opt" -t ffs sd0
Step 2: Create File Systems
Execute dkctl to display the wedges currently mapped to partitions. Note that wedge mappings are dynamic and may differ on your system:
dkctl sd0 listwedges
/dev/rsd0: 5 wedges:
dk1: EFI-system, 262144 blocks at 2048, type: msdos
dk2: NetBSD-root, 16777216 blocks at 264192, type: ffs
dk3: NetBSD-swap, 8388608 blocks at 17041408, type: swap
dk4: NetBSD-var, 8388608 blocks at 25430016, type: ffs
dk5: NetBSD-opt, 90914816 blocks at 33818624, type: ffs
Use the wedge mappings shown above to create the necessary file systems. Note that raw special devices should be used; therefore, the wedges specified in the newfs commands should be /dev/rdkN, where N is the wedge ID:
newfs_msdos -F 32 /dev/rdk1
for i in rdk2 rdk4 rdk5
do
newfs -B le -O 2ea /dev/${i} || break
done
The EFI partition is formatted as a FAT32 file system, while the remaining partitions (excluding swap) are formatted as NetBSD little-endian (option "-B le") UFS file systems. If you are using the NetBSD big-endian (evbarm-aarch64eb) port, adjust the newfs byte-order option accordingly to create big-endian file systems.
Step 3: Mount File Systems and Extract Files
Mount all file systems:
mkdir /mnt-netbsd-root && mount -o log NAME=NetBSD-root /mnt-netbsd-root &&
mkdir /mnt-netbsd-root/boot && mount -t msdos NAME=EFI-system /mnt-netbsd-root/boot &&
mkdir /mnt-netbsd-root/var && mount -o log NAME=NetBSD-var /mnt-netbsd-root/var &&
mkdir /mnt-netbsd-root/opt && mount -o log NAME=NetBSD-opt /mnt-netbsd-root/opt
Download Raspberry Pi 4 UEFI firmware, NetBSD EFI bootloader, and NetBSD sets. Note that the X11 sets are not included, as the Raspberry Pi 4 will be used in headless/server mode in this setup:
ftp https://github.com/pftf/RPi4/releases/download/v1.50/RPi4_UEFI_Firmware_v1.50.zip
ftp https://cdn.netbsd.org/pub/NetBSD/NetBSD-10.1/evbarm-aarch64/installation/misc/bootaa64.efi
mkdir netbsd_sets
for i in base comp etc games kern-GENERIC64 man misc modules rescue text
do
ftp -o netbsd_sets/${i}.tar.xz https://cdn.netbsd.org/pub/NetBSD/NetBSD-10.1/evbarm-aarch64/binary/sets/${i}.tar.xz || break
done
Install UEFI firmware and NetBSD bootloader into boot partition:
unzip -d /mnt-netbsd-root/boot RPi4_UEFI_Firmware_v1.50.zip
mkdir -p /mnt-netbsd-root/boot/EFI/BOOT && cp bootaa64.efi /mnt-netbsd-root/boot/EFI/BOOT
sync
Extract NetBSD sets:
for i in base comp etc games kern-GENERIC64 man misc modules rescue text
do
tar -C /mnt-netbsd-root -xpf netbsd_sets/${i}.tar.xz || break
done
sync
Step 4: Configure NetBSD
Create the /etc/fstab file:
cat > /mnt-netbsd-root/etc/fstab << 'EOF'
NAME=EFI-system /boot msdos rw 0 0
NAME=NetBSD-root / ffs rw,noatime,log 1 1
NAME=NetBSD-var /var ffs rw,noatime,log 1 1
NAME=NetBSD-opt /opt ffs rw,noatime,log 1 2
NAME=NetBSD-swap none swap sw,dp 0 0
kernfs /kern kernfs rw
procfs /proc procfs rw
ptyfs /dev/pts ptyfs rw
tmpfs /var/shm tmpfs rw,-m1777,-sram%25
EOF
Create the additional mount points and the time zone symlink:
mkdir /mnt-netbsd-root/kern /mnt-netbsd-root/proc /mnt-netbsd-root/home
ln -sf ../usr/share/zoneinfo/Europe/London /mnt-netbsd-root/etc/localtime
Create the /etc/rc.conf file:
cat >> /mnt-netbsd-root/etc/rc.conf << 'EOF'
rc_configured=YES
critical_filesystems_local="${critical_filesystems_local} /opt"
hostname="rp4"
domainname="home.lan"
# Static IP config
net_interfaces="genet0"
ifconfig_genet0="inet 192.168.1.1 netmask 255.255.255.0"
dns_search="home.lan"
dns_nameservers="192.168.1.254"
defaultroute="192.168.1.254"
# Dynamic IP config
#dhcpcd=YES
#dhcpcd_flags="-qM genet0"
ip6addrctl=YES
ip6addrctl_policy="ipv4_prefer"
ntpdate=YES
sshd=YES
devpubd=YES
EOF
Step 5: Clean Up
Finally unmount all file systems and remove temporary mount points:
sync &&
umount /mnt-netbsd-root/boot &&
umount /mnt-netbsd-root/opt &&
umount /mnt-netbsd-root/var &&
umount /mnt-netbsd-root &&
rm -rf /mnt-netbsd-root
Step 6: First Boot
Attach the microSD card or USB disk to the Raspberry Pi 4 and power it on.
To enable automatic boot from a specific device, you may need to modify the UEFI firmware boot order: at the UEFI boot screen, press Esc, then navigate to Boot Maintenance Manager → Boot Optins → Change Boot Order, and move the microSD card and USB drive to the top of the list.
To disable the UEFI 3 GiB memory limit, follow these steps: at the UEFI boot screen, press Esc, then navigate to Device Manager → Raspberry Pi Configuration → Advanced Configuration, and disable the 3 GiB memory limit option.
Review afterboot(8), then carry out any additional configuration as required.
Note that the newly installed system will have an empty /etc/openssl/certs directory, which may cause problems when connecting to TLS enabled sites. To resolve this, generate the certificates using the /etc/rc.d/certctl_init script. This only needs to be done once, on the first boot:
/etc/rc.d/certctl_init onestart
No comments:
Post a Comment