Skip to content

Latest commit

 

History

History
170 lines (127 loc) · 6.14 KB

install-omnia.adoc

File metadata and controls

170 lines (127 loc) · 6.14 KB

NixOS on Turris Omnia

The Turris Omnia is little bit more complex regarding the initial setup compared to Turris Mox. One issue is that armv7 builds are not provided by official Hydra. The second issue is that there is not a single reasonable installation (such as SD card on Turris Mox).

Turris Omnia can be booted either from USB or internal disk or from internal MMC. The USB drive is the easies to setup from PCs and thus it is suggested for testing NixOS on your Turris Omnia. You can always return to the Turris OS just by unplugging the USB drive.

Tip
Read the whole documentation before you start to understand what you are getting yourself into.

1.) Updating U-Boot

The updated U-Boot is required to make Turris Omnia work with NixOS in most cases. The reason is that the original U-Boot 2015.10 does not support booting from USB or internal drive. The newer Turris Omnia routers have newer U-Boot versions but always verify the U-Boot version before you continue by running the following command as root on the router:

strings /dev/mtd0 | grep 'U-Boot [0-9.]\+'

The minimal suggested version is U-Boot 2022.07.

Updating U-Boot on Turris OS

The minimal version of Turris OS to get new stable version of U-Boot is Turris OS 6.0. Please update the Turris OS installation to this version or newer before you continue.

The next step is to install turris-nor-update and run it:

opkg update
opkg install turris-nor-update
nor-update

This should give you at least U-Boot 2022.07.

Updating U-Boot on NixOS

The factory version of U-Boot of Turris Omnia most likely won’t support booting from USB devices. This makes this just something for completeness as you won’t be able to boot NixOS unless you update U-Boot from Turris OS. None the less the latest stable version of Turris Omnia firmware is available in NixTurris installation under command turris-firmware-update. You have to run this command as root. It is going to ask you before any change is performed.

2.) Get tarball with NixOS

The initial system can either be downloaded from Gitlab or build locally. Note that version available for download can be pretty old. It is just some version that was build with latest commit to the NixTurris repository.

3.) Boot from USB drive

This is the easies option to get NixOS on Turris Omnia. You can prepare the drive in any Linux system and then just plug it into the Omnia.

You should use some reliable and preferably USB 3.0 flash drive or just regular SSD drive. The suggested minimal size is 8GB but that is pretty much every USB drive on the market right now. You might want to use swap and thus make sure that you use some higher quality one as swap can kill cheap flash drives pretty fast.

You need to format the USB drive first. The required partition table is GPT. You can use only one partition that would be preferably formatted with BTRFS. The important thing is to set label NixTurris so boot can locate the correct partition by it.

It is up to you which tool are you going to use. The instructions here are going to be for GNU Parted. The following shell log should give you an idea of what you should do to get the correct layout:

~# parted /dev/sdx
(parted) mktable gpt
(parted) mkpart NixTurris 0% 100%
(parted) set 1 boot on
(parted) quit
~# mkfs.btrfs /dev/sdx1

The next step is to unpack the tarball to the USB drive.

mkdir -p mnt
mount /dev/sdx1 mnt
tar -xf nixos-system-armv7-linux.tar.xz -C mnt
umount mnt
eject /dev/sdx

Now you can take this drive and plug it in the Turris Omnia. The last step is to instruct firmware to boot from USB.

Tip
If you have USB to serial converter (see official documentation) then you can trigger USB boot only once using it. You have to reboot Omnia and halt boot process by pressing kbd:[Enter] few times once you see U-Boot booting. You should get U-Boot prompt shortly after (the line starting with > `). USB boot is initialized by entering `run usb_boot to it and confirming by kbd:[Enter].

You need to have uboot-envtools package installed on Turris OS or ubootTools on NixOS.

First you have to verify your environment access configuration by printing the current environment using fw_printenv (as root). You should get output with no message informing you about invalid CRC. Do not proceed if you get it.

To set USB boot as a preferred method run:

fw_setenv boot_targets usb0 mmc0 nvme0 scsi0 pxe dhcp

Feel free to validate settings by running fw_printenv again.

Now you can reboot your Omnia to NixOS. The next step is to do first configuration and for that you have to be able to access the router.

Reverting to Turris OS

The simplest step is to remove the USB drive with NixOS (remove it when system is not running). That way Omnia fallbacks back on MMC and boots TurrisOS, but you should still revert also the boot order because this way any flash drive with valid system that gets plugged to the system gets precedence.

fw_setenv boot_targets mmc0 nvme0 scsi0 usb0 pxe dhcp

You can also reset environment to the default if you want to be sure. For that you need USB to serial converter connected (see official documentation). Reboot the board and halt boot process by pressing kbd:[Enter] few times once you see U-Boot booting. You should get U-Boot prompt shortly after (the line starting with `> `). To reset environment enter:

env default -a
saveenv

To continue boot you can enter command boot.

Installing more permanently

The USB flash drive is a good option for testing it out but you might want to have NixOS installed in a more permanent way. There is a separate article describing various alternatives.