|
| 1 | +# Description |
| 2 | + |
| 3 | +This document on how I configure [NixOS](https://nixos.org/) on [NanoPC-T4](https://wiki.friendlyarm.com/wiki/index.php/NanoPC-T4). |
| 4 | + |
| 5 | +# Installation |
| 6 | + |
| 7 | +To install NixOS on you can follow the [official instructions](https://nixos.wiki/wiki/NixOS_on_ARM/NanoPC-T4) and use the [pre-built images](https://github.com/tmountain/arch-nanopct4/tree/main/images/) from @tmountain. You can also build the U-Boot image yourself from `nixpkgs` based on changes added in [#111034](https://github.com/NixOS/nixpkgs/pull/111034). |
| 8 | + |
| 9 | +## NixOS on NVMe with ZFS |
| 10 | + |
| 11 | +It is possible to migrate the OS from the eMMC storage to the NVMe. |
| 12 | + |
| 13 | +In my case I migrated `/`, `/nix`, and `/home`, leaving `/boot` on the eMMC. |
| 14 | + |
| 15 | +Create the ZFS pool and three filesystems on the SSD: |
| 16 | +```sh |
| 17 | +zpool create -O xattr=sa -O acltype=posixacl -O mountpoint=none rpool /dev/nvme0n1 |
| 18 | +for VOL in nix root home; do |
| 19 | + zfs create -o mountpoint=legacy rpool/$VOL |
| 20 | + mkdir /mnt/$VOL |
| 21 | + mount.zfs rpool/$VOL /mnt/$VOL |
| 22 | +done |
| 23 | +``` |
| 24 | +Then sync the original filesystem on eMMC to the new volumes: |
| 25 | +```sh |
| 26 | +rsync -rax /. /mnt/root |
| 27 | +rsync -rax /nix/. /mnt/nix |
| 28 | +rsync -rax /home/. /mnt/home |
| 29 | +rsync -rax /boot/. / |
| 30 | +``` |
| 31 | +Afterwards create a configuration that looks like this: |
| 32 | +```nix |
| 33 | +{ |
| 34 | + # TODO: Make sure to update the eMMC device UUID! |
| 35 | + fileSystems."/boot" = { device = "/dev/disk/by-uuid/1234-5678"; fsType = "ext4"; }; |
| 36 | + fileSystems."/" = { device = "rpool/root"; fsType = "zfs"; }; |
| 37 | + fileSystems."/nix" = { device = "rpool/nix"; fsType = "zfs"; }; |
| 38 | + fileSystems."/home" = { device = "rpool/home"; fsType = "zfs"; }; |
| 39 | +} |
| 40 | +``` |
| 41 | +And rebuild he system: |
| 42 | +```sh |
| 43 | +sudo nixos-rebuild boot |
| 44 | +``` |
| 45 | +:warning: __IMPORTANT:__ After that it's necessary to run all the four `rsync` commands again to sync filesystems. |
| 46 | + |
| 47 | +Once everything is synced you can finally reboot. |
| 48 | + |
| 49 | +You should also clean up `/boot` afterwards. |
| 50 | + |
| 51 | +# UART Debug Console |
| 52 | + |
| 53 | +Device provides a Debug UART 4 Pin 2.54mm header connection, 3V level, 1500000bps. |
| 54 | + |
| 55 | +To connect to you will need a USB to UART converter/receiver that supports the speed of 1500000bps. |
| 56 | + |
| 57 | +The serial port parameters are [8-N-1](https://en.wikipedia.org/wiki/8-N-1). |
| 58 | + |
| 59 | +A reader using `CP2102` chip did not work but `FT232RL` works fine: |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +You can use `minicom` or `picocom` to connect: |
| 64 | +``` |
| 65 | +sudo minicom -b 1500000 -D /dev/ttyUSB0 |
| 66 | +sudo picocom -b 1500000 /dev/ttyUSB0 |
| 67 | +``` |
| 68 | +But you'll need to disable flow control with `Ctrl-A x`. |
| 69 | + |
| 70 | +Here is a good overview of UART USB-to-Serial adapters: |
| 71 | + |
| 72 | +* https://www.sjoerdlangkemper.nl/2019/03/20/usb-to-serial-uart/ |
| 73 | +* https://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT232R.pdf |
| 74 | + |
| 75 | +Pin layout where #4 is next to USB-C port: |
| 76 | + |
| 77 | +| Pin num.| #1 | #2 | #3 | #4 | |
| 78 | +|---------|-----|----|----|----| |
| 79 | +| Purpose | GND | V5 | TX | RX | |
| 80 | + |
| 81 | +Remember that the `TX` and `RX` ports should be swapped between UART adapter and the board. |
| 82 | + |
| 83 | +The V5 pin does not need to be connected if you're powering the board from another source. |
| 84 | + |
| 85 | +See the full board diagram for more details: |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +You can access the recovery console by holding the __Recovery__ button and then pressing the __Power__ button. |
| 90 | +For this to work the device will have to be off, which requires holding the __Power__ button long enough. |
| 91 | + |
0 commit comments