Annotation of wikisrc/Installation_on_UEFI_systems.mdwn, revision 1.3
1.1 wiki 1: ## Installing NetBSD 8.0 on a x86 system with UEFI
1.3 ! wiki 3: Modern x86 machines have UEFI instead of BIOS firmware. Unfortunately, as of the NetBSD 8.0 release the installer did not fully support this setup.
1.1 wiki 4:
1.3 ! wiki 5: For NetBSD-current and NetBSD 9 the installer has been enhanced, it should automatically do the right thing for your machine, no matter if it has BIOS or UEFI firmware, or how big the disks are.
! 7: This tutorial (__only for NetBSD 8.x!__) shows how to semi-manually do it. For simplicity we assume that you have booted the UEFI install image from a USB stick and want to install NetBSD onto the whole disk in the machine.
1.1 wiki 8:
9: ### Getting out of the Installer
11: The install image will offer a menu item to exit the install system. Using that will drop you to a shell prompt.
13: ![screenshot of sysinst main menu](https://netbsd.org/images/misc/uefi/01_exit_installer.png "Exit the Installer")
15: ### Identifying Disks
17: At the shell prompt let us find out what disks we have and which one we want to install to. We can find out what disk devices have been recognized by the kernel via the sysctl program:
19: # sysctl hw.disknames
20: hw.disknames = ld0 wd0 cd0 sd0 dk0 dk1
22: This output is from a typical desktop machine. Depending on details a SSD will show up as *ld* (NVME device) or *wd* (SATA device). Hard disks usually show up as *wd* as well. Other disks may show up as *ld* or *sd* (SCSI, SAN, RAID, ...). USB sticks typically show up as *sd* devices.
24: So here we have a SSD as ld0, a hard disk as wd0, a blueray drive as cd0, and the install image on USB stick as sd0.
26: The *dk* devices are logical wedges (partitions) on the hardware devices, and this early after boot we usually see them in order, that is: dk0 and dk1 are partitions on the installer USB stick sd0. We can verify that by asking for a list of wedges on sd0:
28: # dkctl sd0 listwedges
29: /dev/rsd0: 2 wedges:
30: dk0: EFI system, 262144 blocks at 2048, type: msdos
31: dk1: 2dfc926e-42bd-43fb-9bb5-b227c2c3fc99, 2560000 blocks at 264192, type: ffs
33: Let us look at another example, this time from a typical notebook:
35: # sysctl hw.disknames
36: hw.disknames = wd0 dk0 dk1 dk2 dk3 sd0 dk4 dk5
1.2 wiki 38: Here the internal SSD is showing up as wd0, and has Windows pre-installed (dk0 .. dk3). The install image USB stick again shows up as sd0 with two wedges dk4 and dk5.
1.1 wiki 39:
40: Just to be sure let us check which device the installer booted from:
42: # dmesg | fgrep "root on"
43: root on dk5
45: and verify this is indeed on sd0:
47: # dkctl sd0 listwedges
48: /dev/rsd0: 2 wedges:
49: dk4: EFI system, 262144 blocks at 2048, type: msdos
50: dk5: 2dfc926e-42bd-43fb-9bb5-b227c2c3fc99, 2560000 blocks at 264192, type: ffs
52: Now for fun check the internal ssd:
54: # dkctl wd0 listwedges
55: /dev/rwd0: 4 wedges:
56: dk0: EFI system partition, 204800 blocks at 2048, type: msdos
57: dk1: Microsoft reserved partition, 32768 blocks at 206848, type:
58: dk2: Basic data partition, 409602048 blocks at 239616, type:
59: dk3: 2d02bc12-8433-4e41-ac12-f89167b1a93e, 1024000 blocks at 499093504, type:
61: **NOTE**: if you keep following this tutorial on a machine like the above, the windows installation will be destroyed and all data lost!
63: You can check more details about individual disks by extracting parts of the kernel output from the dmesg output. Assuming we want to install onto disk wd0, let us check for it:
65: # dmesg | fgrep wd0
66: wd0 at atabus4 drive 0
67: wd0: <WDC WD4002FFWX-68TZ4N0>
68: wd0: drive supports 16-sector PIO transfers, LBA48 addressing
69: wd0: 3726 GB, 7752021 cyl, 16 head, 63 sec, 512 bytes/sect x 7814037168 sectors
70: wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA moded 6 (Ultra/133)
71: wd0(ahcisata1:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 6 (Ultra/133) (using DMA)
1.2 wiki 73: **NOTE** for this tutorial screenshots have been created using VirtualBox. The following example uses a strange tiny 30 GB (virtual) hard disk. Also on VirtualBox it is quite tricky (or impossible?) to actually boot from a USB device - instead the USB install image was converted to a virtual disk image, and the machine booted from that. This makes the install image show up as *wd1*.
1.1 wiki 74:
75: Here are the target disk details:
77: ![screenshot of wd0 dmesg details](https://netbsd.org/images/misc/uefi/02_hard_disk_details.png "Disk Details")
79: ### Size Calculations
81: So now that we have identified the disk and got the details, we need to plan our disk layout.
1.2 wiki 83: We will need two partitions, one for UEFI to boot from, and the NetBSD root disk partition. Depending on planned use for the machine, we also will want a swap partition. This should not be smaller than the machine's RAM size, so in case of a kernel panic a crash dump can be saved and recovered on next reboot. For this example let us calculate with 8 GB RAM and no special needs for more swap.
1.1 wiki 84:
85: So we have a 30 GB disk, we subtract 8 GB of swap and a bit of space for the UEFI boot partition. That leaves us with (rounded down) 21 GB of space for the main NetBSD partition.
87: ### Partitioning and Formating the Disk
89: **NOTE** we are about to fully destroy all contents on this disk! Please stop if you are unsure or have no proper backup!
91: Just to make sure, we kill any old partition data on the disk:
93: # gpt destroy wd0
95: Next we create a new partition table and add the partitions with the sizes calculated above (the EFI partition usually is quite small):
97: # gpt create wd0
98: # gpt add -a 2m -l "EFI system" -t efi -s 128m wd0
99: # gpt add -a 2m -l NetBSD -t ffs -s 21g wd0
100: # gpt add -a 2m -l swap -t swap wd0
1.2 wiki 102: Then we check the result:
1.1 wiki 103:
104: # gpt show wd0
106: Note that the kernel messages between the commands also show us the wedge names (dk0...dk4) of the individual partitions we have just created. The mapping between partitions on a disk and wedge (dk) devices is not fixed, you can see below that managing partitions removes all old wedge devices and adds new ones.
108: ![screenshot of wd0 partitioning](https://netbsd.org/images/misc/uefi/03_create_gpt.png "Partitioning the Disk")
110: Just to make double sure, let us list the wedges on wd0 explicitly:
112: # dkctl wd0 listwedges
114: Now we need to format the EFI partition as type msdos, and the NetBSD partition as type ffs. Also we create a directory "EFI/boot" on the EFI partition and copy the bootloaders there.
116: The commands for this are:
118: # newfs_msdos /dev/rdk2
119: # mount -t msdos /dev/dk2 /mnt
120: # mkdir -p /mnt/EFI/boot
121: # cp /usr/mdec/*.efi /mnt/EFI/boot
122: # umount /mnt
123: # newfs -O 2 dk3
125: and it looks like this:
127: ![screenshot of wd0 formatting](https://netbsd.org/images/misc/uefi/04_manual_init.png "Formatting the Disk")
129: ### Main Installation
131: Now we are mostly done. We can leave the shell and return to the installer (sysinst). Type Ctrl-D or use the "exit" command.
133: Back in sysinst we choose "Install NetBSD to hard disk":
135: ![screenshot of sysinst](https://netbsd.org/images/misc/uefi/05_back_in_sysinst_install.png "Back in Sysinst")
137: The next steps are mostly the same as for other sysinst installations. We have to confirm (but actually all harm is already done as we manually repartitioned the disk above):
139: ![screenshot of sysinst asking for install confirmation](https://netbsd.org/images/misc/uefi/06_yes_i_mean_it.png "Are we sure?")
141: Since we already prepared everything, we can select a preformatted wedge (which we did name "NetBSD" above):
143: ![screenshot of sysinst selecting the target disk](https://netbsd.org/images/misc/uefi/07_select_target_wedge.png "Select the target wedge")
145: *NOTE* if you paid close attention, you will notice a bug in this screenshot. The dk1@wd1 wedge (right above the real target) would be dk1@sd0 on real hardware. That is: this is the install image root partition, which we currently have mounted. Sysinst should not offer this wedge here - a bug that might be fixed before the actual 8.0 release (but not in time for this tutorial).
147: Not quite usefull in this semi-manual setup, but sysinst asks again for confirmation:
149: ![screenshot of sysinst asking for confirmation again](https://netbsd.org/images/misc/uefi/08_go_for_it.png "Are we still sure?")
151: Sysinst does not know about the EFI boot partition, but it recognizes there is a swap partition on the same disk as the target partition we have selected. It correctly assumes that we will want to use this for swapping and offers to add it to the installed systems swap configuration:
153: ![screenshot of sysinst offering the swap partition](https://netbsd.org/images/misc/uefi/09_use_my_swap.png "Use the swap partition?")
155: Now just follow the remaining sysinst steps - they are the same as all other x86 NetBSD installations.
CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb