File:  [NetBSD Developer Wiki] / wikisrc / users / spz / moderndisk.mdwn
Revision 1.28: download - view: text, annotated - select for diffs
Mon May 7 06:42:28 2018 UTC (3 years, 2 months ago) by wiki
Branches: MAIN
CVS tags: HEAD
web commit by spz: errant :, as pointed out by soda@

    1: ## UEFI-Boot, GPT and raidframe
    2: 
    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.
    4: 
    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: 
    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: 
   14: if your disks have 4k native sectors, use -s 256M.
   15: 
   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:
   17: 
   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
   24: 
   25: then raid the raids:
   26: 
   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:
   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
   55:     raidctl -I `date +%Y%m%d00` raid0
   56:     raidctl -i raid0
   57: 
   58: raid0 is supposed to have the root on it:
   59: 
   60:     raidctl -A softroot raid0
   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
   82:     raidctl -I `date +%Y%m%d01` raid1
   83:     raidctl -i raid1
   84:     raidctl -A yes raid1
   85: 
   86: the home raid (raid2) gets built the same as the swap raid, apart from taking a long time in the raid -i stage.
   87: 
   88: ### system raid: with disklabel
   89: 
   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
   93:      -> 2 partitions, a and e, 26G and 10G respectively, a starting at 0
   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
  106: 
  107: align to 4k for somewhat better performance
  108: 
  109:     gpt add -a 4k -l home raid2
  110: 
  111: and newfs:
  112: 
  113:     newfs -O2 name=home
  114: 
  115: 
  116: ### put an OS on
  117: 
  118:     mount /dev/raid0a /targetroot
  119:     mkdir /targetroot/var /targetroot/home
  120:     mount /dev/raid0e /targetroot/var
  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: 
  131: ### bootability
  132: 
  133:     mkdir /targetroot/entropy
  134: 
  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: 
  144: copy the uefi boot things to both:
  145: 
  146:     mount name=uefiboot1 /mnt
  147:     mkdir -p /mnt/EFI/boot
  148:     cp /usr/mdec/*.efi /mnt/EFI/boot
  149:     cat > /mnt/boot.cfg
  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
  152:     menu=Drop to boot prompt:prompt
  153:     default=1
  154:     timeout=5
  155:     clear=1
  156:     ^D
  157:     umount /mnt
  158: 
  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: 
  161:     mount name=uefiboot2 /mnt
  162:     mkdir -p /mnt/EFI/boot
  163:     cp /usr/mdec/*.efi /mnt/EFI/boot
  164:     cat > /mnt/boot.cfg
  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
  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
  169:     menu=Drop to boot prompt:prompt
  170:     default=1
  171:     timeout=5
  172:     clear=1
  173:     ^D
  174:     umount /mnt
  175: 
  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: 
  178: ### configure the system (manually, colorful curses elided. sysinst Needs Work.)
  179: 
  180:     chroot /targetroot su -
  181: 
  182:     passwd root
  183: 
  184:     cd /etc
  185:     cat > fstab
  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
  190:     kernfs          /kern           kernfs  rw
  191:     ptyfs           /dev/pts        ptyfs   rw
  192:     procfs          /proc           procfs  rw
  193:     tmpfs           /tmp            tmpfs   rw,-s128m
  194:     ^D
  195: 
  196:     mkdir /kern /proc
  197: 
  198:     vi rc.conf
  199:      -> hostname, dhcpcd, wscons, sshd, random_file=/entropy/entropy-file, ...
  200: 
  201: fix up timezone if necessary:
  202: 
  203:     rm localtime && ln -s /usr/share/zoneinfo/<yourzone> localtime
  204: 
  205: edit wscons.conf for the encoding of your keyboard if not US
  206: 
  207: add users, edit security.conf and daily.conf
  208: 
  209: reboot from disk

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