Annotation of wikisrc/users/spz/moderndisk.mdwn, revision 1.28

1.1       wiki        1: ## UEFI-Boot, GPT and raidframe
                      2: 
1.3       wiki        3: 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.
1.1       wiki        4: 
1.5       wiki        5: 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.
                      6: 
1.1       wiki        7: UEFI does not use installboot, but instead you create a UEFI boot partition which is msdos:
                      8: 
                      9:     gpt create wd0
                     10:     gpt create wd1
                     11:     gpt add -l uefiboot1 -a 1024k -s 128M -t efi wd0
                     12:     gpt add -l uefiboot2 -a 1024k -s 128M -t efi wd1
                     13: 
1.22      wiki       14: if your disks have 4k native sectors, use -s 256M.
1.1       wiki       15: 
1.7       wiki       16: 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:
1.1       wiki       17: 
1.21      wiki       18:     gpt add -l raidsys1   -a 4k -s 36G  -t raid wd0
                     19:     gpt add -l raidsys2   -a 4k -s 36G  -t raid wd1
                     20:     gpt add -l raidswap1  -a 4k -s 24G  -t raid wd0
                     21:     gpt add -l raidswap2  -a 4k -s 24G  -t raid wd1
                     22:     gpt add -l raidhome1  -a 4k -s 870G -t raid wd0
                     23:     gpt add -l raidhome2  -a 4k -s 870G -t raid wd0
1.1       wiki       24: 
                     25: then raid the raids:
                     26: 
1.26      wiki       27: check with dkctl wd0 listwedges and dkctl wd1 listwedges which dk devices represent the raid gpt wedges; sample output:
                     28: 
                     29:     /dev/rwd0: 4 wedges:
                     30:     dk2: uefiboot1, 262144 blocks at 2048, type: msdos
                     31:     dk4: raidsys1, 75497472 blocks at 264192, type: raidframe
                     32:     dk6: raidswap1, 50331648 blocks at 75761664, type: raidframe
                     33:     dk8: raidhome1, 1827431816 blocks at 126093312, type: raidframe
                     34: 
                     35: and insert them instead of dk4 and dk5 if yours differ:
1.1       wiki       36: 
                     37:     cat > /tmp/raid0.conf
                     38:     START array
                     39:     1 2 0
                     40: 
                     41:     START disks
                     42:     /dev/dk4
                     43:     /dev/dk5
                     44: 
                     45:     START layout
                     46:     128 1 1 1
                     47: 
                     48:     START queue
                     49:     fifo 100
                     50:     ^D
                     51: 
                     52: and apply:
                     53: 
                     54:     raidctl -C /tmp/raid0.conf raid0
1.8       wiki       55:     raidctl -I `date +%Y%m%d00` raid0
                     56:     raidctl -i raid0
1.1       wiki       57: 
                     58: raid0 is supposed to have the root on it:
                     59: 
1.9       wiki       60:     raidctl -A softroot raid0
1.1       wiki       61: 
                     62: and the swap raid:
                     63: 
                     64:     cat > /tmp/raid1.conf
                     65:     START array
                     66:     1 2 0
                     67: 
                     68:     START disks
                     69:     /dev/dk6
                     70:     /dev/dk7
                     71: 
                     72:     START layout
                     73:     128 1 1 1
                     74: 
                     75:     START queue
                     76:     fifo 100
                     77:     ^D
                     78: 
                     79: and apply:
                     80: 
                     81:     raidctl -C /tmp/raid1.conf raid1
1.8       wiki       82:     raidctl -I `date +%Y%m%d01` raid1
                     83:     raidctl -i raid1
1.10      wiki       84:     raidctl -A yes raid1
1.8       wiki       85: 
1.21      wiki       86: the home raid (raid2) gets built the same as the swap raid, apart from taking a long time in the raid -i stage.
1.1       wiki       87: 
1.21      wiki       88: ### system raid: with disklabel
1.2       wiki       89: 
1.21      wiki       90: since uefi needs the rootfs 64 blocks after the end of the uefi partition, and the raidframe label already uses those up.
                     91: 
                     92:     disklabel -e raid0
1.22      wiki       93:      -> 2 partitions, a and e, 26G and 10G respectively, a starting at 0
1.21      wiki       94: 
                     95:     newfs -O2 /dev/raid0a
                     96:     newfs -O2 /dev/raid0e
                     97: 
                     98: ### swap raid
                     99: 
                    100:     gpt create raid1
                    101:     gpt add -a 4k -t swap -l swap raid1
                    102: 
                    103: ### home raid
                    104: 
                    105:     gpt create raid2
1.12      wiki      106: 
1.15      wiki      107: align to 4k for somewhat better performance
1.12      wiki      108: 
1.21      wiki      109:     gpt add -a 4k -l home raid2
1.2       wiki      110: 
                    111: and newfs:
                    112: 
                    113:     newfs -O2 name=home
                    114: 
1.3       wiki      115: 
1.19      wiki      116: ### put an OS on
                    117: 
1.22      wiki      118:     mount /dev/raid0a /targetroot
1.19      wiki      119:     mkdir /targetroot/var /targetroot/home
1.22      wiki      120:     mount /dev/raid0e /targetroot/var
1.19      wiki      121:     mount name=home /targetroot/home
                    122:     cd /targetroot
                    123: 
                    124:     for i in base comp etc games kern-GENERIC man misc modules tests text; do
                    125:         tar xzpf /amd64/binary/sets/$i.tgz
                    126:     done
                    127: 
                    128:     cd dev
                    129:     ./MAKEDEV all
                    130: 
1.2       wiki      131: ### bootability
                    132: 
1.24      wiki      133:     mkdir /targetroot/entropy
                    134: 
1.2       wiki      135: create msdos filesystems on the uefiboot wedges:
                    136: 
                    137:     dkctl wd0 listwedges
                    138:      -> my uefiboot1 is dk2
                    139:     newfs_msdos -F 32 -b 1024 /dev/rdk2
                    140:     dkctl wd1 listwedges
                    141:      -> my uefiboot2 is dk3
                    142:     newfs_msdos -F 32 -b 1024 /dev/rdk3
                    143: 
1.23      wiki      144: copy the uefi boot things to both:
1.2       wiki      145: 
                    146:     mount name=uefiboot1 /mnt
                    147:     mkdir -p /mnt/EFI/boot
                    148:     cp /usr/mdec/*.efi /mnt/EFI/boot
1.25      wiki      149:     cat > /mnt/boot.cfg
1.27      wiki      150:     menu=Boot normally:dev hd0b:;rndseed /entropy/entropy-file;boot hd0b:netbsd
                    151:     menu=Boot single user:dev hd0b:;rndseed /entropy/entropy-file;boot hd0b:netbsd -s
1.25      wiki      152:     menu=Drop to boot prompt:prompt
                    153:     default=1
                    154:     timeout=5
                    155:     clear=1
                    156:     ^D
1.2       wiki      157:     umount /mnt
                    158: 
1.25      wiki      159: 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:
                    160: 
1.2       wiki      161:     mount name=uefiboot2 /mnt
                    162:     mkdir -p /mnt/EFI/boot
                    163:     cp /usr/mdec/*.efi /mnt/EFI/boot
1.25      wiki      164:     cat > /mnt/boot.cfg
1.27      wiki      165:     menu=Boot normally:dev hd0b:;rndseed /entropy/entropy-file;boot hd0b:netbsd
                    166:     menu=Boot single user:dev hd0b:;rndseed /entropy/entropy-file;boot hd0b:netbsd -s
1.28    ! wiki      167:     menu=Boot normally from hd1b:dev hd1b:;rndseed /entropy/entropy-file;boot hd1b:netbsd
        !           168:     menu=Boot single user from hd1b:dev hd1b:;rndseed /entropy/entropy-file;boot hd1b:netbsd -s
1.25      wiki      169:     menu=Drop to boot prompt:prompt
                    170:     default=1
                    171:     timeout=5
                    172:     clear=1
                    173:     ^D
1.2       wiki      174:     umount /mnt
1.1       wiki      175: 
1.25      wiki      176: 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++.
                    177: 
1.6       wiki      178: ### configure the system (manually, colorful curses elided. sysinst Needs Work.)
1.3       wiki      179: 
1.4       wiki      180:     chroot /targetroot su -
1.3       wiki      181: 
1.4       wiki      182:     passwd root
1.3       wiki      183: 
1.4       wiki      184:     cd /etc
                    185:     cat > fstab
1.21      wiki      186:     /dev/raid0a     /               ffs     rw 1 1
                    187:     /dev/raid0e     /var            ffs     rw 1 2
                    188:     NAME=home       /home           ffs     rw 1 3
                    189:     NAME=swap       none            swap    sw 0 0
1.4       wiki      190:     kernfs          /kern           kernfs  rw
                    191:     ptyfs           /dev/pts        ptyfs   rw
                    192:     procfs          /proc           procfs  rw
                    193:     tmpfs           /tmp            tmpfs   rw,-s128m
                    194:     ^D
1.5       wiki      195: 
1.20      wiki      196:     mkdir /kern /proc
                    197: 
1.4       wiki      198:     vi rc.conf
1.5       wiki      199:      -> hostname, dhcpcd, wscons, sshd, random_file=/entropy/entropy-file, ...
1.3       wiki      200: 
                    201: fix up timezone if necessary:
                    202: 
1.4       wiki      203:     rm localtime && ln -s /usr/share/zoneinfo/<yourzone> localtime
1.3       wiki      204: 
1.17      wiki      205: edit wscons.conf for the encoding of your keyboard if not US
                    206: 
1.3       wiki      207: add users, edit security.conf and daily.conf
                    208: 
1.22      wiki      209: reboot from disk

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb