Install NetBSD (Short and Sweet Version)
The NetBSD Guide has an extensive chapter on installing NetBSD that covers a wide range of scenarios. Its an invaluable resource maintained by volunteer contributors.
After performing a few installs, these are my personal notes of steps taken and choices made. A short and sweet version of the above Guide HOWTO.
NOTE
If disk encryption is required, see Manual NetBSD Installation with Disk Encryption.
1. Start Here
Throughout this guide, if you see square brackets []
in code blocks, that means the word of code (square brackets included) should be replaced with something else. This is detailed in the instructions before or after the code block.
This guide makes a few assumptions:
- Target device is amd64 architecture
- System uses UEFI to boot and a GPT partition table
- NetBSD install media prepared on a Linux/BSD system
- NetBSD is the sole OS on a single disk
- Network access during install uses a NetBSD supported wired interface
1.1 Download install image
Download the INSTALL image and the SHA512
file for verification:
$ wget -c https://cdn.netbsd.org/pub/NetBSD/NetBSD-10.1/images/NetBSD-10.1-amd64-install.img.gz
$ wget https://cdn.netbsd.org/pub/NetBSD/images/10.1/SHA512
Verify the image using sha512sum
:
$ sha512sum -c --ignore-missing SHA512
NetBSD-10.1-amd64-install.img.gz: OK
Decompress the image:
$ gunzip NetBSD-10.1-amd64-install.img.gz
1.2 Prepare USB install media
Plug in a USB stick and identify its device label. If the USB stick is mounted, unmount the device:
# umount /dev/[device_label]
For example, if the USB stick is mounted as sde1
:
# umount /dev/sde1
WARNING
Be very careful to note the proper device. All contents on the device will be lost!
Write the install image to the USB stick using the dd(1) command:
# dd if=NetBSD-10.1-amd64-install.img of=/dev/[device_label] bs=2M conv=fsync oflag=direct status=progress && sync
Using the previous example of sde1
, this command would replace [device_label]
with sde
(omit the partition number):
# dd if=NetBSD-10.1-amd64-install.img of=/dev/sde bs=2M conv=fsync oflag=direct status=progress && sync
2. Live Environment
Insert the USB install stick into the target device and boot. Select Option 1
(default) to Install NetBSD
.
After the installer has successfully booted into the NetBSD kernel, a prompt appears to select which language will be used for installation messages, followed by a prompt to select a different keyboard type if desired or leave unchanged.
Next up the menu-based sysinst program is launched:
NetBSD-10.1 Install System
>a: Install NetBSD to hard disk
b: Upgrade NetBSD on a hard disk
c: Re-install sets or install additional sets
d: Reboot the computer
e: Utility menu
f: Config menu
x: Exit Install System
2.1 Wipe Disk
WARNING
Be very careful to note the proper device. All contents on the device will be lost!
If the target device's storage was previously partitioned, securely wipe the disk before installing NetBSD.
Select >e: Utility menu
then >a: Run /bin/sh
.
Discover what disk devices and partitions have been recognized by the kernel using sysctl(8).
Example:
# sysctl hw.disknames
hw.disknames = wd0 dk0 dk1 dk2 dk3 sd0 dk4 dk5
NVMe devices show up as ld
and hard disks are identified by wd
. USB devices usually show up as sd
.
The dk
devices are partitions (know as wedges in NetBSD parlance) on the storage devices, and this early after boot are usually displayed in order, that is: dk0
through dk3
are wedges on the hard disk wd0
, and dk4
and dk5
on the USB installer sd0
.
Use dd
to overwrite the entire disk with zeroes:
# dd if=/dev/zero of=/dev/[disk_label] bs=2m
Using the above example of wd0
, this command would replace [disk_label] with:
# dd if=/dev/zero of=/dev/wd0 bs=2m
This operation will take a bit of time. With my 233G SSD, for example, it took approximately 15 minutes to zero out the disk.
Return to the installer:
# sysinst
2.2 Configure network
At the Install System
main menu, select >e: Utility menu
then >c: Configure network
.
Available interfaces
lists the network interfaces detected by the NetBSD installer.
EXAMPLE
With my target device Available interfaces
lists two: wn0
(wired) and iwn0
(wireless). I choose to configure the wired ethernet interface.
Network media (empty to autoconfigure) [autoselect]: <enter>
Perform autoconfiguration?
>a: Yes
Your host name: bsdbox
Your DNS domain [home]: home.arpa
The following are the values you entered.
[...]
Are they OK?
>a: Yes
>x: Exit
the Utilities
menu and return to the Install System
main menu.
3. Installation
NetBSD-10.1 Install System
>a: Install NetBSD to hard disk
Shall we continue?
>b: Yes
Under Available disks
I select my SATA disk identified as wd0
.
Select >a: Guid Partition Table (GPT)
for partitioning scheme.
For partition sizes select >b: Use default partition sizes
.
NetBSD proposes a default partition layout with 3 partitions:
- 128MB efi partition with
MSDOS
file system - remaining disk space (minus swap) for root partition with
FFSv2
file system - <size=RAM> swap partition with
swap
file system
Select >x: Partition sizes ok
and >b: Yes
to continue.
Under Select your distribution
choose either >a: Full installation
for a desktop install or >b: Installation without X11
for a server install.
Under Install from
select >a: CD-ROM / DVD / install image media
. Installation to target device begins.
When prompted to confirm that the network information entered earlier is accurate and should it be installed in /etc
, select >a: Yes
then Hit enter to continue
.
Set password for root
.
A warning may appear:
This system seems to lack a cryptographically strong pseudo random number generator. There is not enough entropy available to create secure keys (e.g. ssh host keys).
If so, select >a: Manually input random characters
and enter one line of random characters.
4. Configuration
Additional items I configure:
>b: Timezone
Default is UTC
; select whatever is appropriate (Example: Canada/Eastern
).
Ease the future installation of binary packages by installing and configuring the pkgin
package manager:
>e: Enable installation of binary packages
pkgin
will be fetched and installed from an FTP server. Confirm network information >a: Yes
, accept the defaults and select >x: Install pkgin and update package summary
to run the task, then Hit enter to continue
.
Enable remote access to this device by starting sshd
at boot:
>g: Enable sshd YES
Confirm datetime at boot and correct any drift:
>h: Enable ntpd YES
>i: Run ntpdate at boot YES
Create a user account:
>o: Add a user
Choose >a: Yes
to add user to group wheel
, user shell >a: /bin/sh
, and set password.
Exit configuration:
>x. Finished configuring
and Hit enter to continue
.
Reboot:
>d: Reboot the computer
System messages stream past, and finally:
NetBSD/amd64 (bsdbox.home.arpa) (constty)
login:
Welcome to NetBSD!
To shutdown/poweroff the system:
# shutdown -p now
TODO
Next: After the First Boot
5. Resources
- NetBSD INSTALL: Installation procedure for NetBSD/amd64
- NetBSD Wiki: Installing NetBSD on a x86 system with UEFI
- NetBSD Guide: Chapter 3. Example installation
You can like, share, or comment on this post on the Fediverse 💬
« Previous: Configure SSH on NetBSD for Passwordless Logins to Servers