freebsd_install.md (26003B)
1 FreeBSD new install instructions 2 ================================ 3 4 Download install image 5 ---------------------- 6 7 First, we'll need to download an install image from 8 https://www.freebsd.org/where.html. These instructions presume amd64 9 architecture, so we'll use an amd64-memstick image. 10 11 Once the image is downloaded, write it to a USB stick using `dd`. Using the 12 instructions in the FreeBSD Handbook here: 13 https://www.freebsd.org/doc/handbook/bsdinstall-pre.html. 14 15 16 Install from USB stick 17 ---------------------- 18 19 Boot from the USB stick in UEFI mode. The machine should now boot into the 20 FreeBSD installer. 21 22 1. Keyboard layout: USA (Caps Lock acts as Left Ctrl). 23 2. Set hostname (should include domain name). 24 3. Install `ports`. 25 4. Auto disk partition. Entire disk. GPT. 26 5. Network. Yes IPv4, no IPv6 unless you have IPv6 set up. For a non-networked 27 install select 'no' for both. We can set this up later. 28 6. Set clock to UTC. 29 7. Enable `sshd`, `ntpd`, `powerd`, `dumpdev`. 30 8. Set security hardening options (see below). 31 9. Add user with `wheel` additional group. 32 33 Once these steps are done, select the option to drop into a console session to 34 complete a few additional steps. 35 36 37 ### Set security hardening options 38 39 For an internet-facing server, it's worth locking it down. Use the following 40 options: 41 1. hide_uids 42 2. hide_gids 43 3. hide_jail 44 4. read_msgbuf 45 5. proc_debug 46 6. random_pid 47 7. clear_tmp 48 8. disable_syslogd 49 9. disable_ddtrace 50 10. enable_aslr 51 52 53 ### Set the console keyboard layout 54 55 The console keyboard layout can be temporarily changed using the `kbdcontrol` 56 command: 57 58 kbdcontrol -l jp.capsctrl 59 60 It can be permanently set by adding a line to `/etc/rc.conf`: 61 62 keymap=jp.capsctrl 63 64 For US keyboard layout with Caps Lock as Control, use `us.ctrl` for a Japanese 65 keyboard with Caps Lock as Control, use `jp.capsctrl`. You can find all layouts 66 in the `/usr/share/vt/keymaps` directory. 67 68 69 ### Configure the hostname 70 71 First we'll get the hostname set: 72 73 First, set domain-qualified hostname in `/etc/rc.conf`. 74 75 hostname="myhost.bracken.jp" 76 77 Next, update `/etc/hosts` to use domain name. Add raw hostname and 78 domain-qualified hostname after localhost entries. 79 80 ::1 localhost localhost.bracken.jp myhost myhost.bracken.jp 81 127.0.0.1 localhost localhost.bracken.jp myhost myhost.bracken.jp 82 83 84 ### Configure wired ethernet 85 86 Next, configure wired ethernet for DHCP. In `/etc/rc.conf`, add: 87 88 # SYNCDHCP forces startup to wait for dhclient to return, DHCP does not. 89 ifconfig_em0="SYNCDHCP" 90 91 Either SYNCDHCP or DHCP is acceptable. The default is DHCP. 92 93 94 ### Configure WiFi 95 96 If we need Intel WiFi, in `/boot/loader.conf`, add: 97 98 if_iwm_load="YES" 99 iwm8265fw_load="YES" 100 101 and then configure DHCP for WiFi in `/etc/rc.conf`: 102 103 wlans_iwm0="wlan0" 104 ifconfig_wlan0="WPA DHCP" 105 106 and set up the WiFi network and password in `/etc/wpa_supplicant.conf`: 107 108 network={ 109 ssid="my_ssid_name" 110 psk="my_password" 111 } 112 113 then ensure that no one but root can read the contents: 114 115 chmod go-rwx /etc/wpa_supplicant.conf 116 117 To assign a fixed IP address to always be returned by the router's DHCP server, 118 get the WiFi MAC address using `ifconfig wlan0`, then in the router, manually 119 assign a fixed IP address. 120 121 122 ### Configure sendmail 123 124 By default, sendmail operates localhost only. If you disable it, you'll need to 125 enable an alternative mail handler since the system assumes mail is available. 126 (See note below) 127 128 Given that we generally want to disable root login on all hosts, it's useful to 129 forward root's mail to a local user. To do so: 130 131 1. Edit `/etc/mail/aliases`. Forward root's mail to a local user (e.g. `chris`) 132 or a domain-qualified email address such as `chris@bracken.jp`. 133 2. Run `newaliases` to rebuild the random-access database populated from 134 `/etc/mail/aliases`. This is exactly the same as `sendmail -bi`. 135 136 See https://www.freebsd.org/doc/handbook/sendmail.html for details. 137 138 Note: you can get away with disabling email completely, but the daily, weekly, 139 monthly `periodic` jobs set up in `/etc/crontab` send email to root, so you'd 140 want to configure `periodic` to log output instead of emailing it. You can do 141 this by adding the following to `/etc/periodic.conf`: 142 143 daily_output=/var/log/daily.log 144 weekly_output=/var/log/weekly.log 145 monthly_output=/var/log/monthly.log 146 147 More details can be found in the `periodic` man page. 148 149 150 ### Set the console font 151 152 To list available fonts, run `vidfont`, an ncurses-based program that sets the 153 font to something legible when running. When it exits, it'll dump the selected 154 font name. 155 156 To set the font from a script, run: 157 158 vidcontrol -f FONTNAME 159 160 where `FONTNAME` is the name dumped by vidfont. 161 162 To permanently set the console font, edit `/etc/rc.conf`: 163 164 allscreens_flags="-f FONTNAME" 165 166 I find `terminus-b32` to be the most legible on a small screen. On a large 167 screen, `vgarom-8x14` or `vgarom-8x16` might be better. 168 169 A couple reference articles relating to framebuffer console fonts: 170 171 * [How to change console font type and size](https://lists.freebsd.org/pipermail/freebsd-questions/2018-February/281063.html) 172 * [CLI・CUIなワークステーションを作る](http://www.lufimia.net/cal/workstation/index.htm) 173 * [FreeBSDで日本語コンソールvtを使う](https://www.next-hop.net/~hiraga/FreeBSD/japanese-vt.shtml) 174 175 176 Reboot the machine 177 ------------------ 178 179 Once the above steps are done, run exit the shell and select to end the 180 installation and reboot. 181 182 183 Install initial packages 184 ------------------------ 185 186 Install general packages: 187 1. `pkg update -f` 188 2. Install doas: `pkg install doas` (alternatively install sudo) 189 3. Install zsh: `pkg install zsh` 190 4. Install bash: `pkg install bash` (only required for bazel) 191 5. Install vim: `pkg install vim-console` 192 6. Install tmux: `pkg install tmux` 193 194 If running on a VM under XCP-NG: 195 1. Install Xen guide utils: `pkg install xe-guest-utilities` 196 2. In /etc/rc.conf, add: `xenguest_enable="YES"` 197 198 Install file manager: 199 1. Run `pkg install mc` to install midnight commander. 200 201 Install mutt email support: 202 1. Run `pkg install mutt` to install mutt email client. 203 2. Run `pkg install abook` to install address book. 204 3. Run `pkg install notmuch` to install notmuch email indexer. 205 4. Run `pkg install isync` to install email syncing. 206 5. Run `pkg install msmtp` to install an SMTP plugin mutt can use. 207 6. Run `pkg install w3m` to install w3m browser. 208 7. Run `pkg install zathura zathura-pdf-poppler zathura-ps` to install zathura 209 PDF/PS viewer. 210 211 Install a gemini client: 212 1. Run `pkg install amfora` to install amfora gemini client. 213 214 Install newsreader support: 215 1. Run `pkg install newsboat` to install newsboard RSS reader. 216 217 Install developer packages: 218 1. Run `pkg install git` (agree to install all) to install git. 219 2. Run `pkg install tig` to install tig git client. 220 3. Run `pkg install python3 python` to install python. 221 4. Run `pkg install go` to install golang. 222 5. Run `pkg install nasm` to install nasm assembler. 223 6. Run `pkg install bazel` (note: requires `bash` at runtime) for bazel build. 224 7. Run `pkg install gn` to install generate ninja. 225 8. Run `pkg install ninja` to install ninja. 226 9. Run `pkg install cscope` to install cscope code analyzer. 227 10. Run `pkg install meson` to install meson build. 228 11. Run `pkg install cmake` to install cmake build. 229 230 Install static web site support: 231 1. Run `pkg install gohugo` to install hugo static site generator. 232 233 234 Set up doas 235 ----------- 236 237 Edit `/usr/local/etc/doas.conf` and add the following text: 238 239 permit nopass :wheel 240 permit :wheel cmd reboot 241 permit :wheel cmd shutdown 242 permit nopass keepenv root as root 243 244 245 Set up sudo (alternative to doas) 246 --------------------------------- 247 248 Prefer installing `doas` as described above, but leaving instructions here for 249 reference. 250 251 1. Edit `/usr/local/etc/sudoers` and uncomment the following line to enable sudo 252 access for members of the `wheel` group: 253 254 %wheel ALL=(ALL) ALL 255 256 1. Disable direct root login by editing the passwd file using the `vipw` 257 command. Find the row starting with `root:` and replace the hashed password 258 between the first and second colons on that line with `*`. The line should 259 look something like: 260 261 root:*:0:0::0:0:Charlie &:/root:/bin/csh 262 263 1. Type `:wq` to save and exit. 264 265 Now that sudo is set up, log in as a user in the `wheel` group on another 266 console (Use Ctrl-Alt-F1 through F8 to switch ttys) and run `sudo ls /root` to 267 verify everything is configured properly, then exit the root shell and continue 268 all further steps as a user in the `wheel` group. 269 270 271 Configure sshd 272 -------------- 273 274 Edit `/etc/ssh/sshd_config` and uncomment or edit each of the following lines to 275 disable password-based logins and allow only key-based authentication: 276 277 PasswordAuthentication no 278 ChallengeResponseAuthentication no 279 PubkeyAuthentication yes 280 281 Edit `/etc/rc.conf` to add: 282 283 sshd_enable="YES" 284 285 As root, start the sshd server: 286 287 service sshd start 288 289 Connect to the host via ssh from another machine: 290 291 ssh myhost 292 293 Copy any existing public key you want to be able to log in into 294 `~/.ssh/authorized_keys` on the new machine -- e.g. on the new host: 295 `cat > ~/.ssh/authorized_keys`. Then paste the public key you want to use to log 296 in, and type ctrl-d to save. You can find your public key in 297 `~/.ssh/id_rsa.pub` on the existing host you want to connect from. 298 299 300 Configure audio 301 --------------- 302 303 We may want to disable the PC speaker and its annoying beep. Edit 304 `/etc/sysctl.conf` and add the following: 305 306 # Disable the terminal bell. 307 kern.vt.enable_bell=0 308 309 Audio volumes themselves can be controlled via the `mixer` tool, which is part 310 of the FreeBSD base install. 311 312 313 Set up NVIDIA drivers 314 --------------------- 315 316 For systems with an NVIDIA card, we'll install the drivers, configure them to 317 load at boot, and add X11 config. 318 319 First install the drivers: 320 321 pkg install nvidia-driver 322 323 Next add the following line to `/boot/loader.conf`: 324 325 nvidia_load="YES" 326 327 Then add the following line to `/etc/rc.conf`: 328 329 kld_list="nvidia-modeset" 330 331 Next, create the file `/usr/local/etc/X11/xorg.conf.d/driver-nvidia.conf` with 332 the following contents: 333 334 Section "Device" 335 Identifier "NVIDIA Card" 336 VendorName "NVIDIA Corporation" 337 Driver "nvidia" 338 EndSection 339 340 Finally, reboot the system or run `kldload nvidia-modeset` to manually load the 341 driver. 342 343 344 Change shell to zsh 345 ------------------- 346 347 Log in as your user: 348 349 1. `chsh -s /usr/local/bin/zsh` 350 2. `exit` 351 352 Log in as user again: 353 354 1. `ssh-keygen -t rsa -b 4096 -C "chris@bracken.jp (hostname)"` 355 356 357 Configure Wayland 358 ----------------- 359 360 ### Install WM and apps 361 362 Add yourself to the `video` group: 363 364 pw groupmod video -m $USER 365 366 Install the DRM kernel module: 367 368 pkg install drm-kmod 369 370 Then, for Intel graphics, add the following line to `/etc/rc.conf`: 371 372 kld_list="i915kms" 373 374 Install the sway window manager: 375 376 pkg install sway \ # window manager 377 swaylock \ # lock screen 378 swayidle \ # idle manager 379 swaybg \ # background screen 380 dmenu \ # app launcher 381 grim \ # Wayland screenshot utility 382 slurp \ # Select a region in Wayland 383 wl-clipboard \ # command-line interface to Wayland clipboard 384 jq \ # command-line JSON parser 385 libnotify \ # command-line notification sender (notify-send) 386 mako # Notification daemon 387 388 Screenshots use the `grimshot` utility that I've checked into my dotfiles repo. 389 This can be found in the Sway repo `contrib` directory. This utility depends on 390 the `grim`, `slurp`, `wl-clipboard`, `jq`, and `libnotify` packages listed 391 above. 392 393 Install the alacritty terminal emulator: 394 395 pkg install alacritty 396 397 Install fonts: 398 399 pkg install webfonts 400 pkg install twemoji-color-font-ttf 401 pkg install noto 402 pkg install ja-font-ipa ja-font-ipa-uigothic ja-font-ipaex 403 404 Install Firefox web browser: 405 406 pkg install firefox # browser 407 pkg install openh264 # H264 video plugin 408 409 Install the mpv video player: 410 411 pkg install mpv 412 413 Install xdg-utils to get file associations to apps: 414 415 pkg install xdg-utils 416 417 418 Configure XWindows 419 ------------------ 420 421 As of 2022, Wayland works pretty well, and `xwayland` does a good job of 422 covering anything that still relies on X, but if you prefer an X11 desktop, 423 these instructions will cover things. 424 425 ### Install Xorg, WM, and apps 426 427 Install XWindows: 428 429 pkg install xorg 430 431 Install the i3 window manager: 432 433 pkg install i3 \ # window manager 434 i3status \ # status bar 435 i3lock \ # lock screen 436 dmenu \ # app launcher 437 xautolock \ # lock screen timeout manager 438 sxiv # image viewer 439 440 Install dunst for notifications: 441 442 pkg install dunst 443 444 Optionally, install compton compositor: 445 446 pkg install compton 447 448 Install urxvt terminal: 449 450 pkg install rxvt-unicode 451 452 Install flameshot screenshotting tool: 453 454 pkg install flameshot 455 456 Install fonts: 457 458 pkg install webfonts 459 pkg install twemoji-color-font-ttf 460 pkg install noto 461 pkg install ja-font-ipa ja-font-ipa-uigothic ja-font-ipaex 462 463 Then refresh the font cache: 464 465 fc-cache -f 466 467 Install Firefox web browser: 468 469 pkg install firefox # browser 470 pkg install openh264 # H264 video plugin 471 472 Install the mpv video player: 473 474 pkg install mpv 475 476 477 ### Configure X 478 479 Add the following line to `/etc/rc.conf`: 480 481 dbus_enable="YES" 482 483 Add yourself to the `video` group: 484 485 pw groupmod video -m $USER 486 487 Install DRM kernel module: 488 489 pkg install drm-fbsd12.0-kmod 490 491 Then set it to load at boot time by adding the following line to 492 `/etc/rc.conf`: 493 494 kld_list="/boot/modules/i915kms.ko" 495 496 In some instances, this seems to result in a kernel panic. If that 497 happens, install DRM from the `graphics/drm-kmod` port in the ports 498 tree. 499 500 501 ### Configure keyboard layout 502 503 In XWindows, the keyboard can be set using `setxkbmap`: 504 505 setxkbmap jp 506 507 It can be permanently set by adding the above line to `.xinitrc`. 508 509 To map Caps Lock into a control key: 510 511 setxkbmap -option ctrl:nocaps 512 513 514 ### Configure mouse 515 516 To configure natural scrolling, create the file 517 `/usr/local/etc/X11/xorg.conf.d/mouse.conf` with the following contents: 518 519 Section "InputDevice" 520 Identifier "Mouse1" 521 Driver "mouse" 522 Option "Protocol" "auto" 523 Option "Device" "/dev/sysmouse" 524 Option "Buttons" "5" 525 Option "ZAxisMapping" "4 5" 526 EndSection 527 528 529 ### Reboot 530 531 Reboot the system and attempt to run `startx`. 532 533 534 Configure Japanese input 535 ------------------------ 536 537 ### Wayland 538 539 Install the fcitx input method with mozc: 540 541 pkg install ja-fcitx-mozc 542 543 As root, generate a unique ID for this machine that will be written to 544 `/var/lib/dbus/machine-id` for use by dbus, if the file doesn't yet exist and 545 contain a UUID: 546 547 dbus-uuidgen --ensure 548 549 550 ### XWindows 551 552 Setting Japanese keyboard layout with caps-lock as control: 553 554 setxkbmap -layout jp -option ctrl:nocaps 555 556 Installing mozc IME: 557 558 pkg install ja-fcitx-mozc 559 560 In `~/.xinitrc`, before launching i3, add: 561 562 # Use fcitx for Japanese IME. 563 export GTK_IM_MODULE=fcitx 564 export QT_IM_MODULE=fcitx 565 export XMODIFIERS=@im=fcitx 566 567 # Start mozc engine and fcitx IME. 568 /usr/local/bin/mozc start 569 /usr/local/bin/fcitx -d 570 571 Configure fcitx by running `fcitx-configtool`. Using the *Input Method* pane, 572 add *Mozc*. Remove US keyboard if present (unless you're using a US keyboard). 573 Note that when you do this step, dbus will need to be running; this involves 574 either a reboot after the XWindows config steps above or manually starting it 575 via `service dbus start` before running `startx`. 576 577 578 ### Virtual console 579 580 Download Japanese fonts: 581 582 fetch http://people.freebsd.org/~emaste/newcons/b16.fnt 583 fetch http://www.wheel.gr.jp/~dai/fonts/jiskan16u.fnt 584 fetch http://www.wheel.gr.jp/~dai/fonts/jiskan16s.fnt 585 fetch http://www.wheel.gr.jp/~dai/fonts/unifont-8.0.01.fnt 586 587 As root, copy the fonts to a local font directory: 588 589 mkdir /usr/local/share/fonts/vt 590 cp *.fnt /usr/local/share/fonts/vt 591 592 You can convert BDF or HEX fonts to console `.fnt` files using the 593 `vtfontcvt` command. See the `vtfontcvt` man page for details. 594 595 Use the mechanism described (`vidfont` and `vidcontrol`) elsewhere in 596 this document to set the font. 597 598 599 Optionally set up pf firewall 600 ------------------------------ 601 602 Canonical reference in the FreeBSD Handbook: 603 https://www.freebsd.org/doc/handbook/firewalls-pf.html 604 605 An excellent tutorial on the OpenBSD packet filter: 606 https://home.nuug.no/~peter/pf/en/ 607 608 Another decent starter reference: http://srobb.net/pf.html 609 610 611 ### Enable pf 612 613 We'll need to populate `/etc/pf.conf`. A minimal config file that blocks all 614 incoming connections other than SSH (port 22): 615 616 # Our external-facing network interface. 617 ext_if="em0" 618 619 # Block spoofed IP addresses on em0. 620 antispoof for $ext_if 621 622 # Allow all connections over loopback. 623 # "quick" means if rule is matched, stop processing here. 624 pass quick on lo0 all 625 626 # Block all incoming connections. 627 block in all 628 629 # Allow incoming SSH connections. 630 pass in proto tcp to port 22 631 632 # Allow all outgoing connections. 633 pass out all keep state 634 635 To run a check on our config file without yet applying it: 636 637 pfctl -nvf /etc/pf.conf 638 639 Next, we'll start `pf`, but since many a system administrator has found 640 themselves locked out of their own server by applying a bad config, it's useful 641 to queue up a command to disable the firewall after two minutes. In another 642 terminal, log into the remote machine, get a *root* shell using `doas -s`, then 643 run the following: 644 645 # Sleep 2 minutes, then disable pf. 646 sleep 120; pfctl -d 647 648 Then, before the two minutes is up, run these commands in another root terminal 649 to start the firewall: 650 651 # Load the pf kernel module. 652 kldload pf 653 654 # Enable pf. 655 pfctl -e 656 657 It's likely your SSH sessions will hang when you enable the packet filter. 658 Quickly try connecting via SSH to verify you can connect before the two minute 659 timeout above expires. If it worked, re-enable the packet filter on the server 660 using `pfctl -e`. 661 662 Once everything checks out, enable the packet filter on startup by adding the 663 following lines to `/etc/rc.conf`: 664 665 pf_enable="YES" 666 pflog_enable="YES" 667 668 669 ### Reading pf logs 670 671 To read the pf logs, run: 672 673 tcpdump -netttr /var/log/pflog 674 675 676 ### Enabling blacklistd 677 678 Canonical reference in the FreeBSD Handbook: 679 https://www.freebsd.org/doc/handbook/firewalls-blacklistd.html 680 681 If you've got an external-facing SSH port, you'll be continuously spammed with 682 bogus connection attempts from people attempting to get access to 683 badly-configured machines. The less clever of these tend to attack your machine 684 repeatedly from the same IP address. FreeBSD includes the `blacklistd` service 685 which can be used to temporarily ban IP addresses after repeated failed 686 connection attempts. 687 688 First, we'll add a pf anchor for blacklistd blocks in `/etc/pf.conf`: 689 690 anchor "blacklistd/*" in on $ext_if 691 692 Next we'll enable it on boot. We start the daemon with the `-r` flag, which 693 tells it to re-read the firewall rules from the internal database and remove 694 then re-add them; this is useful for packet filters that don't retain state 695 across restarts, though it's unclear to me whether this is the case for `pf`. 696 Add following lines to `/etc/rc.conf`: 697 698 blacklistd_enable="YES" 699 blacklistd_flags="-r" 700 701 Next, as root, start the blacklistd service: 702 703 service blacklistd start 704 705 Finally, we'll enable blacklist support in sshd. Edit `/etc/ssh/sshd_config` and 706 uncomment the line: 707 708 UseBlacklist yes 709 710 Then we'll restart sshd: 711 712 service sshd restart 713 714 at this point, everything should be up and running. 715 716 717 Editing kernel sources 718 ---------------------- 719 720 When editing kernel sources in vim, the indentation settings should be: 721 722 set autoindent " Copy indent from current line when starting a new line 723 set smartindent " Attempt to autoindent when starting a new line 724 set smarttab " Use shiftwidth rather than tabstop at start of line 725 set tabstop=8 " Number of spaces a tab counts for 726 set shiftwidth=4 " Number of spaces for each step of autoindent 727 set softtabstop=4 " Number of spaces a tab counts for when editing 728 set noexpandtab " Use tabs rather than spaces 729 730 731 Using a serial cable 732 -------------------- 733 734 FreeBSD includes built-in support for various UART serial cables including the 735 Prolific PL-2303 and FTDI cables. Connecting the cable will create three 736 character devices named `ttyUN`, `ttyUN.init`, and `ttyUN.lock` in the dev 737 filesystem. 738 739 * `ttyUN` is the serial device. 740 * `ttyUN.init` is an initialisation device used to initialise communication port 741 parameters each time a port is opened, such as `crtscts` for modems which use 742 `RTS/CTS` signalling for flow control. 743 * `ttyUN.lock` is used to lock flags on ports to prevent users or programs from 744 changing certain parameters. See the man pages for `termios`, `sio`, and 745 `stty` for information on terminal settings, locking and initialising devices, 746 and setting terminal options, respectively. 747 748 More info on serial port configuration can be found in the FreeBSD Handbook: 749 750 * [25.2 USB Virtual Serial Ports](https://www.freebsd.org/doc/handbook/usb-device-mode-terminals.html) 751 * [26.2 Serial Terminology and Hardware](https://www.freebsd.org/doc/handbook/serial.html) 752 753 To connect to the serial line, use the `cu` command: 754 755 cu -l /dev/ttyU0 -s 115200 756 757 To disconnect the serial session, type `~.` from within `cu`. 758 759 760 Troubleshooting 761 --------------- 762 763 ### ssh-add fails to run 764 765 If, when running ssh-add, you get an error along the lines of 766 767 Could not open a connection to your authentication agent. 768 769 you likely need to start ssh-agent. You can do this via: 770 771 eval $(ssh agent -s) 772 773 774 ### Segfault on keyboard input in dmenu 775 776 If you have the `XMODIFIERS` variable set but your IME isn't properly configured 777 and running, you'll get a crash on keyboard input to dmenu. 778 779 780 ### Can't doas or log in as root 781 782 Imagine you delete the root password via `vipw` without actually editing the 783 `/usr/local/etc/sudoers` file first, or that you did edit that file but that no 784 user is in the `wheel` group. Time to boot to single-user mode. Reboot the 785 machine and when prompted at the initial FreeBSD boot prompt, quickly select 786 option `2` to boot to single-user mode. 787 788 The root filesystem is mounted read-only by default, so first we'll need to 789 remount the root filesystem as read-write: 790 791 /sbin/mount -o rw / 792 793 Next, edit `/usr/local/etc/doas.conf` or make whatever other changes are 794 required to fix your mistakes. Finally, reboot. 795 796 797 ### Force renew DHCP lease 798 799 DHCP leases are cached in `/var/db/dhclient.leases.em0` (replace `em0` with your 800 interface name). 801 802 To force renewal of DHCP lease, run as root: 803 804 service dhclient restart em0 805 806 To manually unbind/remove an IP address from an interface: 807 808 ifconfig em0 remove 192.168.1.x 809 810 811 ### Force NTP time sync 812 813 To force sync the time on the host, run as root: 814 815 ntpdate -v -b in.pool.ntp.org 816 817 818 ### Intel NUC6i3SYK-specific issues 819 820 #### SD card reader doesn't work 821 822 Intel NUC6i3SYK devices give a repeating error on startup: 823 824 sdhci_pci0_slot0: Controller timeout 825 826 and dump registers. It seems like there's an issue with support for the NUC's SD 827 card reader. After a couple minutes, eventually it gives up and continues. To 828 eliminate the warning on startup, reboot and enter the BIOS by holding down F2, 829 then disable the SD card reader in the *Devices* section of the *Advanced* 830 options. 831 832 Alternatively, edit `/boot/loader.conf` to contain: 833 834 hw.sdhci.enable_msi=0 835 836 If that doesn't work, edit `/boot/device.hints` to contain: 837 838 hint.sdhci_pci.0.disabled="1" 839 840 841 #### Bluetooth doesn't work 842 843 Mostly from notes in FreeBSD 844 [Bugzilla issue 237083](https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237038). 845 846 The NUC's Intel 8260 Bluetooth/wireless requires a custom firmware download. 847 FreeBSD 12.0 doesn't ship with all the support needed for this chipset. Fixes 848 were landed in July 2019, but will take time to get released. When it does, 849 installation will be: 850 851 pkg install iwmbt-firmware 852 853 In the meantime, the firmware downloader can be found here: 854 [](https://github.com/wulf7/iwmbt-firmware). Build the downloader: 855 856 git clone git@github.com:wulf7/iwmbt-firmware 857 cd iwmbt-firmware 858 make 859 860 There's no need to install this, since it's a one-off tool to download and 861 install the firmware. However, before you run it, you need to prevent FreeBSD 862 from trying to auto-attach the device. Edit `/etc/devd.conf` and comment out the 863 following lines, then power off and power back on the machine (a reboot is 864 insufficient to clear the hardware state): 865 866 attach 100 { 867 device-name "ubt[0-9]+"; 868 action "service bluetooth quietstart $device-name"; 869 }; 870 871 Next, to download the firmware, we run as root: 872 873 ./iwmbtfw 874 875 This should get the download to happen, writing the firmware to 876 `/usr/local/share/iwmbt-firmware/ibt-11-5.sfi`. As root, you can then start the 877 service with: 878 879 service start bluetooth ubt0 880 881 To list the attached Bluetooth nodes, try: 882 883 ngctl list 884 885 It should display something like: 886 887 There are 6 total nodes: 888 Name: ubt0 Type: ubt ID: 00000007 Num hooks: 0 889 Name: ubt0hci Type: hci ID: 0000000? Num hooks: 0 890 Name: ubt012cap Type: 12cap ID: 0000000? Num hooks: 0 891 Name: btsock_hci_raw Type: btsock_hci_raw ID: 00000008 Num hooks: 0 892 Name: btsock_l2c_raw Type: btsock_l2c_raw ID: 00000009 Num hooks: 0 893 Name: btsock_l2c Type: btsock_l2c ID: 0000000a Num hooks: 0 894 Name: btsock_sco Type: btsock_sco ID: 0000000b Num hooks: 0 895 Name: ngctl1441 Type: socket ID: 00000019 Num hooks: 0 896 897 I notice when I do it, I'm missing the `ubt0hci` and `ubt012cap` entries though. 898 899 Once you're done, uncomment the section of `/dev/devd.conf` above and reboot.