UEFI-Boot, GPT and raidframe
I have a new machine that wants to boot UEFI, and it has two disks that I want to mirror. I have booted NetBSD-8.0_BETA-amd64-uefi-install.img off a USB stick, and went from sysinst to shell. This implies I have tools and sets (in /amd64/binary/sets) locally, and a /targetroot directory.
Several config files need to be created; I show them as "cat > file" because that shows what goes in there but by all means use a proper editor if you can't use cut+paste.
UEFI does not use installboot, but instead you create a UEFI boot partition which is msdos:
gpt create wd0
gpt create wd1
gpt add -l uefiboot1 -a 1024k -s 128M -t efi wd0
gpt add -l uefiboot2 -a 1024k -s 128M -t efi wd1
if your disks have 4k native sectors, use -s 256M.
while I'm here, also make the raid wedges and raided swap space. I have 1TB disks, and want enough swap to be able to dump my entire RAM if necessary:
gpt add -l raidsys1 -a 4k -s 36G -t raid wd0
gpt add -l raidsys2 -a 4k -s 36G -t raid wd1
gpt add -l raidswap1 -a 4k -s 24G -t raid wd0
gpt add -l raidswap2 -a 4k -s 24G -t raid wd1
gpt add -l raidhome1 -a 4k -s 870G -t raid wd0
gpt add -l raidhome2 -a 4k -s 870G -t raid wd1
then raid the raids:
check with dkctl wd0 listwedges and dkctl wd1 listwedges which dk devices represent the raid gpt wedges; sample output:
/dev/rwd0: 4 wedges:
dk2: uefiboot1, 262144 blocks at 2048, type: msdos
dk4: raidsys1, 75497472 blocks at 264192, type: raidframe
dk6: raidswap1, 50331648 blocks at 75761664, type: raidframe
dk8: raidhome1, 1827431816 blocks at 126093312, type: raidframe
and insert them instead of dk4 and dk5 if yours differ:
cat > /tmp/raid0.conf
START array
1 2 0
START disks
/dev/dk4
/dev/dk5
START layout
128 1 1 1
START queue
fifo 100
^D
and apply:
raidctl -C /tmp/raid0.conf raid0
raidctl -I `date +%Y%m%d00` raid0
raidctl -i raid0
raid0 is supposed to have the root on it:
raidctl -A softroot raid0
and the swap raid:
cat > /tmp/raid1.conf
START array
1 2 0
START disks
/dev/dk6
/dev/dk7
START layout
128 1 1 1
START queue
fifo 100
^D
and apply:
raidctl -C /tmp/raid1.conf raid1
raidctl -I `date +%Y%m%d01` raid1
raidctl -i raid1
raidctl -A yes raid1
the home raid (raid2) gets built the same as the swap raid, apart from taking a long time in the raid -i stage.
system raid: with disklabel
since uefi needs the rootfs 64 blocks after the end of the uefi partition, and the raidframe label already uses those up.
disklabel -e raid0
-> 2 partitions, a and e, 26G and 10G respectively, a starting at 0
newfs -O2 /dev/raid0a
newfs -O2 /dev/raid0e
swap raid
gpt create raid1
gpt add -a 4k -t swap -l swap raid1
home raid
gpt create raid2
align to 4k for somewhat better performance
gpt add -a 4k -l home raid2
and newfs:
newfs -O2 name=home
put an OS on
mount /dev/raid0a /targetroot
mkdir /targetroot/var /targetroot/home
mount /dev/raid0e /targetroot/var
mount name=home /targetroot/home
cd /targetroot
for i in base comp etc games kern-GENERIC man misc modules tests text; do
tar xzpf /amd64/binary/sets/$i.tgz
done
cd dev
./MAKEDEV all
bootability
mkdir /targetroot/entropy
create msdos filesystems on the uefiboot wedges:
dkctl wd0 listwedges
-> my uefiboot1 is dk2
newfs_msdos -F 32 -b 1024 /dev/rdk2
dkctl wd1 listwedges
-> my uefiboot2 is dk3
newfs_msdos -F 32 -b 1024 /dev/rdk3
copy the uefi boot things to both:
mount name=uefiboot1 /mnt
mkdir -p /mnt/EFI/boot
cp /usr/mdec/*.efi /mnt/EFI/boot
cat > /mnt/boot.cfg
menu=Boot normally:dev hd0b:;rndseed /entropy/entropy-file;boot hd0b:netbsd
menu=Boot single user:dev hd0b:;rndseed /entropy/entropy-file;boot hd0b:netbsd -s
menu=Drop to boot prompt:prompt
default=1
timeout=5
clear=1
^D
umount /mnt
usually the system will boot from wd0 aka hd0, but if that disk has a problem, depending on how dead it is you may want to boot from wd1-as-hd0 or wd1-as-hd1:
mount name=uefiboot2 /mnt
mkdir -p /mnt/EFI/boot
cp /usr/mdec/*.efi /mnt/EFI/boot
cat > /mnt/boot.cfg
menu=Boot normally:dev hd0b:;rndseed /entropy/entropy-file;boot hd0b:netbsd
menu=Boot single user:dev hd0b:;rndseed /entropy/entropy-file;boot hd0b:netbsd -s
menu=Boot normally from hd1b:dev hd1b:;rndseed /entropy/entropy-file;boot hd1b:netbsd
menu=Boot single user from hd1b:dev hd1b:;rndseed /entropy/entropy-file;boot hd1b:netbsd -s
menu=Drop to boot prompt:prompt
default=1
timeout=5
clear=1
^D
umount /mnt
If the system is going to be in an inconvenient location (so walking up to it with a memstick becomes a project), consider also putting an install kernel on uefiboot* as rescue++.
configure the system (manually, colorful curses elided. sysinst Needs Work.)
chroot /targetroot su -
passwd root
cd /etc
cat > fstab
/dev/raid0a / ffs rw 1 1
/dev/raid0e /var ffs rw 1 2
NAME=home /home ffs rw 1 3
NAME=swap none swap sw 0 0
kernfs /kern kernfs rw
ptyfs /dev/pts ptyfs rw
procfs /proc procfs rw
tmpfs /tmp tmpfs rw,-s128m
^D
mkdir /kern /proc
vi rc.conf
-> hostname, dhcpcd, wscons, sshd, random_file=/entropy/entropy-file, ...
fix up timezone if necessary:
rm localtime && ln -s /usr/share/zoneinfo/<yourzone> localtime
edit wscons.conf for the encoding of your keyboard if not US
add users, edit security.conf and daily.conf
reboot from disk