In chapter 3 you built the robot's new system as a folder on your PC. Now you copy that folder onto the robot's drive, make the robot boot from it, and give it the handful of settings every later chapter assumes. The factory install stays on the drive next to the new system. You need it once more in this chapter, the camera driver comes from it later, and it's meant as your way back, although I never tested going back to it.
Plan on an afternoon. The copy itself took me under 14 minutes. Most of the time goes into reading output carefully before the steps that change the drive: the partition table, the format and the rename of the boot partition.
I did this install twice. The first time, as this chapter describes it, I made a new partition next to the factory system. The second time I reformatted the factory partition and installed into it, with the first new system kept as a fallback. Most outputs below are from the first install. Where one comes from the second, I say so.
The first-stage bootloader and the UEFI firmware don't live on the SSD. They sit in a small flash chip on the module itself, and this chapter doesn't touch it. UEFI starts NVIDIA's L4TLauncher from the SSD, and L4TLauncher looks for the GPT partition whose name is exactly APP. From that partition it reads boot/extlinux/extlinux.conf and loads the kernel named there. The APPEND line in that file becomes the kernel's command line, and its root=PARTUUID=... part tells the kernel which partition to mount as /.
So two things decide what boots: which partition is named APP, and which partition the root= line points at. This chapter uses exactly those two levers. You make a new partition, copy the system into it, write a boot entry that points at it, and then swap the names so the new partition is APP and the factory one is APP_old.
A partition has several IDs, and they're easy to mix up. Its number is the 16 in /dev/nvme0n1p16. Its name is what lsblk calls PARTLABEL. Its PARTUUID is a random ID the partition table gives it. The ext4 filesystem inside it has a label and a UUID of its own. L4TLauncher picks by name; the kernel picks by PARTUUID.
Why not flash the robot the normal way? NVIDIA's usual install puts the module into recovery mode and writes the drive from a PC over USB. On this robot the software way into recovery mode failed both times I tried it, and the hardware way needs two pins that you can only reach with the robot taken apart. Installing from the running factory system avoids both.
This changes the partition table of the robot's only drive. I had a full clone of mine before I started, but I never had to restore it. As chapter 5 explains, no backup has ever been written back onto this robot, so restoring one is untested. This guide also has no tested way to back up the factory system: chapter 5's backup script refuses to run on it, because it looks for your user, which the factory system doesn't have. If you want a copy of the whole drive first, you have to make it your own way.
Save the depth camera's driver to your PC before you change anything on the drive. I found no public download of it. On the factory system it sits in /home/ubuntu/third_party/aurora_ws/src/deptrum-ros-driver-aurora930-0.2.11, and chapter 7 can't install the camera without it. This chapter keeps the factory system as APP_old, so nothing here erases it, but it's the only copy, and my second install reformatted that partition. Chapter 7 describes the archive it expects. My own copy came from a backup of an earlier system, so I have no tested command for packing it straight from the factory system.
Plug the Ethernet cable into the robot and your router now. The new system has no Wi-Fi driver yet, so the cable is how you'll reach it after the reboot. The factory system has working Wi-Fi, and I reached it over Wi-Fi for this whole chapter.
The robot side of this chapter runs on the factory system as the user ubuntu, which the factory set up with passwordless sudo. That's why the commands use sudo -n: it fails instead of stopping to ask for a password. Point the alias rosorin on your laptop at the factory system for now, in ~/.ssh/config. Mine reached it over Wi-Fi at ROBOT_WIFI_IP; use your factory system's address:
Host rosorin
HostName ROBOT_WIFI_IP
User ubuntu
IdentityFile ~/.ssh/id_ed25519
The commands below use BatchMode=yes, which only works with key login. My laptop's key was already on the factory ubuntu account, so I never did that step and this guide has no tested way to do it. If your key isn't there, put it there first.
I sent each robot block from the laptop as ssh -o BatchMode=yes rosorin 'bash -s' <<'EOF', then the block, then EOF. Do the same. Several blocks start with set -e, which stops the block at the first error. Typed into an interactive shell on the robot, the same set -e would close your session instead.
command -v sgdisk; sudo -n sgdisk -p /dev/nvme0n1 2>&1 | head -8
On my robot it printed:
/usr/sbin/sgdisk
Disk /dev/nvme0n1: 1000215216 sectors, 476.9 GiB
Model: Micron_2400_MTFDKBK512QFM
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 6A99051F-7A83-4C99-ABE0-615F90392068
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 40, last usable sector is 250069646
The last usable sector is the line to read. 250,069,646 sectors of 512 bytes is 128 GB, but the drive has 1,000,215,216 sectors. The factory flash only made a partition table for the first 128 GB, so three quarters of the drive sits outside it, unused. That's where the new system goes.
The factory layout is fifteen partitions inside those 128 GB. p1 is APP, the factory system, 117.8 GiB. p2 to p15 are NVIDIA's small partitions: kernel copies, recovery kernels, the EFI partition (p10, mounted at /boot/efi) and two reserved ones. They stay exactly as they are.
The commands in the next section create the new partition from 128 GB to 256 GB. They fit a factory table that ends at 128 GB on a drive of 256 GB or more, as on mine. If your drive is the 128 GB that Hiwonder's documentation lists, or your sgdisk -p looks different, stop here. There's no room, and this guide has no tested way to install on a full drive.
Creating the partition straight away fails, because the space you want lies past the last usable sector. When I tried, parted printed:
Warning: Not all of the space available to /dev/nvme0n1 appears to be used, you can fix the GPT to use all of the space (an extra 750145536 blocks) or continue with the current setting?
Error: Unable to satisfy all constraints on the partition.
The fix is sgdisk -e. It moves the backup copy of the partition table to the real end of the drive, which moves the last usable sector there too. It doesn't change any existing partition, and the block proves that: it saves the list of partitions before and after, and compares them. Then parted creates partition 16 from 128 GB to 256 GB and names it APP_new. The word ext4 is only a type hint for parted; it formats nothing. -a optimal aligns the start for the drive, and partprobe tells the kernel to read the table again.
I ran this block once, on my first install, and the output below is from that run. On my second install I didn't run it at all: the table already reached the end of the drive, and I installed into the existing p1 instead of a new partition.
This block writes the partition table, so first look at the partitions it starts from. This is the block's own first line without the file at the end:
sudo -n sgdisk -p /dev/nvme0n1 | sed -n "/^Number/,\$p"
You want entries 1 to 15 and nothing else, with number 1 named APP and about 117.8 GiB, ending at sector 250069646. I didn't keep this listing from my first install, so I can't show it. If there is already a 16, or anything else is named APP, stop.
set -e
sudo -n sgdisk -p /dev/nvme0n1 | sed -n "/^Number/,\$p" > /tmp/parts_before.txt
sudo -n sgdisk -e /dev/nvme0n1
sudo -n partprobe /dev/nvme0n1; sleep 1
sudo -n sgdisk -p /dev/nvme0n1 | grep "last usable"
sudo -n sgdisk -p /dev/nvme0n1 | sed -n "/^Number/,\$p" > /tmp/parts_after.txt
diff /tmp/parts_before.txt /tmp/parts_after.txt && echo "existing partition entries unchanged"
sudo -n parted -s -a optimal /dev/nvme0n1 mkpart APP_new ext4 128GB 256GB
sudo -n partprobe /dev/nvme0n1; sleep 2
lsblk -o NAME,SIZE,PARTLABEL,PARTUUID /dev/nvme0n1 | grep -E "NAME|APP"
The lines that matter in my output were these:
The operation has completed successfully.
Warning: Not all of the space available to /dev/nvme0n1 appears to be used, you can fix the GPT to use all of the space (an extra 6 blocks) or continue with the current setting?
First usable sector is 40, last usable sector is 1000215176
existing partition entries unchanged
The last usable sector now sits at the end of the drive, and existing partition entries unchanged proves p1 to p15 weren't touched. If that line is missing, stop. The leftover warning about 6 blocks is harmless; parted carried on. The lsblk lines at the end should list p1 as APP and the new p16 as APP_new. My log cut those lines off; the format block's own name test is what proved p16 was APP_new.
Don't plan around the 128 GB size. On the first boot, NVIDIA's setup grows the root partition to the end of the drive when it's the last partition, and p16 is.
Formatting erases a partition. Before you run it, look at both partitions side by side and be sure which is which:
lsblk -o NAME,SIZE,FSTYPE,LABEL,PARTLABEL,PARTUUID,MOUNTPOINT /dev/nvme0n1p1 /dev/nvme0n1p16
echo "root: $(findmnt -no SOURCE /)"; mkfs.ext4 -V 2>&1 | head -1
You want to see p1 named APP, with an ext4 filesystem, mounted at /, and the root: line should say /dev/nvme0n1p1. That's the system you're running, and it must not be formatted. p16 should be named APP_new, about 119G (the 128 GB you asked for), with no filesystem and no mount point. The last line should say mke2fs 1.46.5. If any of that is different, stop.
I ran this exact check on my second install, where the roles were different: p1 was the partition to erase and the running system was on p16. On the first install I only looked at lsblk -o NAME,SIZE,PARTLABEL,PARTUUID /dev/nvme0n1, so I can't show you this output for the layout in this chapter. On the second install the version line read mke2fs 1.46.5 (30-Dec-2021).
The version matters. Ubuntu 22.04's mke2fs is 1.46.5. Newer versions, including the one on a current Fedora PC, turn on an ext4 feature called orphan_file. The robot's 5.15 kernel doesn't support it (it's missing from /sys/fs/ext4/features), so the root filesystem wouldn't mount. I never tried to boot from such a filesystem. Format on the robot, never directly on your PC.
The format block checks for itself that p16 is APP_new and not mounted, and refuses to run otherwise:
set -e
test "$(lsblk -no PARTLABEL /dev/nvme0n1p16)" = "APP_new"
findmnt /dev/nvme0n1p16 && { echo "mounted, abort"; exit 1; } || true
sudo -n mkfs.ext4 -q -L APP_new /dev/nvme0n1p16
lsblk -f /dev/nvme0n1p16
On a new, empty partition mkfs.ext4 has nothing to ask. If it finds an old filesystem in the way, it asks "Proceed anyway?", but only when its input and output are a terminal. Under bash -s its input is the rest of your script. When I reformatted a partition that already held a system on my second install, I put </dev/null at the end of the mkfs.ext4 line, so a typed run and a bash -s run behave the same and mkfs never touches the script.
Right after mkfs, lsblk -f printed my partition with empty columns, because it hadn't caught up yet. blkid reads the drive itself:
sudo -n blkid /dev/nvme0n1p16; sudo -n dumpe2fs -h /dev/nvme0n1p16 2>/dev/null | grep -E "volume name|Block count|Filesystem state"
/dev/nvme0n1p16: LABEL="APP_new" UUID="8ef4f905-4ef0-4749-b39e-438ac7b4993d" BLOCK_SIZE="4096" TYPE="ext4" PARTLABEL="APP_new" PARTUUID="ef01d088-5975-4263-b620-2d0f5137dfe1"
Filesystem volume name: APP_new
Filesystem state: clean
Block count: 31241216
Write down your PARTUUID. It's random, so yours is different. Everywhere this chapter shows ef01d088-5975-4263-b620-2d0f5137dfe1, put yours.
The copy is one pipe through your laptop. Your PC packs the staged rootfs into a tar stream inside the container, because the files there belong to root. The stream crosses your laptop, and the robot unpacks it as root into the new partition. Nothing is written to disk in between. Run this on the laptop:
ssh -o BatchMode=yes rosorin 'sudo -n mkdir -p /mnt/app_new && sudo -n mount /dev/nvme0n1p16 /mnt/app_new && findmnt /mnt/app_new && sudo -n find /mnt/app_new -mindepth 1 -maxdepth 1 | grep -v lost+found | wc -l' && ssh -o BatchMode=yes yourpc 'docker run --rm -v ~/jetson-flash/work:/work:z jetson-flash:r36.4.3 tar -C /work/Linux_for_Tegra/rootfs --numeric-owner --xattrs --acls -cpf - .' | ssh -o BatchMode=yes rosorin 'sudo -n tar -C /mnt/app_new --numeric-owner --xattrs --xattrs-include="*" --acls -xpf - && echo COPY_DONE'
Read it from left to right. First, on the robot, it creates /mnt/app_new, mounts p16 there, shows the mount and counts what's already in it. Then your PC writes the whole tree to its output with tar -c, starting inside the rootfs so the paths begin with ./. Last, the robot reads the stream with tar -x and unpacks it into /mnt/app_new.
The flags carry everything a system needs besides the file contents. --numeric-owner keeps the owner and group numbers exactly as they are in the staged rootfs. Your PC's user and the robot's factory system both have their own lists of users, and without this flag tar would translate names through them and the IDs could change. -p keeps permissions exactly, including the setuid bit that sudo needs. --xattrs and --acls keep extended attributes and access lists, and --xattrs-include="*" on the unpacking side restores every kind of attribute, not just the default ones.
Before the stream starts, the robot prints the mount and the count:
TARGET SOURCE FSTYPE OPTIONS
/mnt/app_new /dev/nvme0n1p16 ext4 rw,relatime
0
The count must be 0, since a fresh filesystem holds only lost+found. If it isn't, something is already on p16, so stop and find out what before you unpack over it. At the end the robot prints COPY_DONE.
Now compare the copy with the counts you wrote down in chapter 3. Files and folders first:
ssh -o BatchMode=yes rosorin 'sudo -n bash -c "cd /mnt/app_new && echo files \$(find . -xdev \( -type f -o -type l \) -not -path ./lost+found | wc -l) dirs \$(find . -xdev -type d -not -path ./lost+found | wc -l)"'
Then the bytes in regular files:
ssh -o BatchMode=yes rosorin 'sudo -n find /mnt/app_new -xdev -type f -not -path "/mnt/app_new/lost+found/*" -printf "%s\n" | awk "{s+=\$1} END {printf \"%.0f\n\", s}"'
On my second install I got files 188110 dirs 18751 and 7689137431, exactly my chapter 3 numbers. On the first install, from an earlier staging, the bytes were 7689137900, again the same on both sides. Yours must match yours exactly.
Two things can look like a short copy and aren't. If you see 2147483647, that's awk running out of range with %d; use %.0f as above. And don't compare with du: on my robot it differed by about 73 MB from the PC, because folders take a different amount of space on the PC's filesystem than on the robot's ext4. The file bytes are what count.
The staged rootfs has NVIDIA's template boot/extlinux/extlinux.conf, whose APPEND line is only ${cbootargs}, the arguments the bootloader passes in. NVIDIA's flash tool would normally add the root partition and NVIDIA's standard arguments. Here you add them yourself.
The standard arguments are called CMDLINE_ADD in the board configuration. Read them on your PC:
docker run --rm -v ~/jetson-flash/work:/work:z jetson-flash:r36.4.3 bash -c "du -sb --apparent-size /work/Linux_for_Tegra/rootfs | cut -f1; cd /work/Linux_for_Tegra; grep -h CMDLINE_ADD p3767.conf.common p3768-0000-p3767-0000-a0.conf jetson-orin-nano-devkit-super.conf 2>/dev/null"
After a size line, it should print just one CMDLINE_ADD:
CMDLINE_ADD="mminit_loglevel=4 console=ttyTCU0,115200 firmware_class.path=/etc/firmware fbcon=map:0 nospectre_bhb video=efifb:off console=tty0"
Compare it with the factory boot line you saved in chapter 3. It's the same plus net.ifnames=0, which isn't in NVIDIA's files. I left that one out on purpose. Without it, the wired card gets a name from its position on the PCI bus, enP8p1s0, instead of eth0. Either way NetworkManager runs DHCP on it.
The new line adds root=PARTUUID= with your partition, then rw rootwait rootfstype=ext4, which means mount it writable, wait until the SSD has appeared, and expect ext4. The two console= entries send kernel messages to the serial debug port and to a screen. firmware_class.path=/etc/firmware says where drivers find their firmware. The rest are NVIDIA's defaults for this board, unchanged.
The block keeps NVIDIA's template as extlinux.conf.nvidia, only the first time, then replaces the first APPEND line of the LABEL primary entry with a short Python script, and shows the result. Put your own PARTUUID into the NEW= line:
set -e
M=/mnt/app_new
grep -vE "^\s*(#|$)" $M/etc/network/interfaces 2>/dev/null | grep -v "^source" || echo "interfaces: nothing defined"
test -e $M/boot/extlinux/extlinux.conf.nvidia || sudo -n cp -p $M/boot/extlinux/extlinux.conf $M/boot/extlinux/extlinux.conf.nvidia
NEW=" APPEND \${cbootargs} root=PARTUUID=ef01d088-5975-4263-b620-2d0f5137dfe1 rw rootwait rootfstype=ext4 mminit_loglevel=4 console=ttyTCU0,115200 firmware_class.path=/etc/firmware fbcon=map:0 nospectre_bhb video=efifb:off console=tty0"
sudo -n python3 - "$NEW" <<'PY'
import sys
p="/mnt/app_new/boot/extlinux/extlinux.conf"
lines=open(p).read().split("\n")
out=[];in_primary=False;done=False
for l in lines:
s=l.strip()
if s.startswith("LABEL "): in_primary=(s=="LABEL primary")
if in_primary and s.startswith("APPEND") and not done:
out.append(sys.argv[1]); done=True; continue
out.append(l)
assert done
open(p,"w").write("\n".join(out))
PY
echo "== result"; grep -vE "^\s*#|^\s*$" $M/boot/extlinux/extlinux.conf
echo "== diff vs template"; diff $M/boot/extlinux/extlinux.conf.nvidia $M/boot/extlinux/extlinux.conf || true
ls -la $M/boot/Image $M/boot/initrd
sudo -n blkid -s PARTUUID -o value /dev/nvme0n1p16
The first grep checks that the new system has no old-style /etc/network/interfaces setup that could fight with NetworkManager; it should print interfaces: nothing defined. The \${cbootargs} is escaped so the shell writes the literal text ${cbootargs} into the file. The file without its comments came out like this on mine:
TIMEOUT 30
DEFAULT primary
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} root=PARTUUID=ef01d088-5975-4263-b620-2d0f5137dfe1 rw rootwait rootfstype=ext4 mminit_loglevel=4 console=ttyTCU0,115200 firmware_class.path=/etc/firmware fbcon=map:0 nospectre_bhb video=efifb:off console=tty0
The diff should show one changed line, line 10, and the last line prints p16's PARTUUID again. It must be the same value as in the root= part. Check it character by character; a typo here means the kernel can't find its root.
Now the new partition gets the name APP and the factory one becomes APP_old. L4TLauncher boots the partition named exactly APP, so there must never be two of them, and never none. The block checks both current names first, flushes and unmounts p16, and renames both in a single sgdisk call. The PARTUUIDs don't change.
Be clear about what happens next. After the reboot, p16 boots with your PARTUUID, and the factory system sits untouched on p1 as APP_old. If the new system doesn't come up at all, only NVIDIA's recovery mode or another boot medium is left, and recovery mode never worked for me on this robot. That's why every check above matters.
First, while the factory system still answers, write down the wired card's hardware address. You'll need it to find the new system after the reboot:
ip -br link
I didn't run this on the factory system. On my second install I read the address on the system I was replacing, with ip -br link show enP8p1s0. On the factory system the wired card is probably called eth0, because of the net.ifnames=0 in its boot line, but I haven't checked that. It's the one that is neither lo nor the Wi-Fi card. Its line shows the MAC address, six pairs of hex digits. Write it down.
Before the swap, look at the two names once more. This is the swap block's last line on its own:
lsblk -o NAME,PARTLABEL,PARTUUID /dev/nvme0n1 | grep -E "APP"
p1 must be APP and p16 APP_new with the PARTUUID you wrote down. The block tests both names again and stops if either is wrong. Then the swap:
set -e
test "$(sudo -n sgdisk -i 1 /dev/nvme0n1 | grep "Partition name" | cut -d"'" -f2)" = "APP"
test "$(sudo -n sgdisk -i 16 /dev/nvme0n1 | grep "Partition name" | cut -d"'" -f2)" = "APP_new"
sync; sudo -n umount /mnt/app_new
sudo -n sgdisk -c 1:APP_old -c 16:APP /dev/nvme0n1
sudo -n partprobe /dev/nvme0n1 2>/dev/null || true
for i in 1 16; do echo "p$i: $(sudo -n sgdisk -i $i /dev/nvme0n1 | grep -E "Partition name|unique GUID" | tr -s " " | tr "\n" " ")"; done
lsblk -o NAME,PARTLABEL,PARTUUID /dev/nvme0n1 | grep -E "APP"
p1: Partition unique GUID: 59FCA1C4-9E3E-406D-8532-CAD56C869912 Partition name: 'APP_old'
p16: Partition unique GUID: EF01D088-5975-4263-B620-2D0F5137DFE1 Partition name: 'APP'
├─nvme0n1p1 APP_old 59fca1c4-9e3e-406d-8532-cad56c869912
└─nvme0n1p16 APP ef01d088-5975-4263-b620-2d0f5137dfe1
Exactly one APP, and it's p16 with your PARTUUID. Reboot from the laptop:
ssh -o BatchMode=yes -o ServerAliveInterval=3 -o ServerAliveCountMax=2 rosorin 'sync; sudo -n systemctl reboot'
The SSH session dies when the robot goes down. The two ServerAlive options make your laptop give up after about 6 seconds instead of hanging. macOS has no timeout command, so this is the simple way to do it.
The way back to the factory system is the same swap the other way round, run on the new system: ssh -t rosorin 'sudo sgdisk -c 16:APP_new -c 1:APP /dev/nvme0n1 && sudo systemctl reboot'. Before it, run the lsblk line above and check that p16 is APP with your PARTUUID and p1 is APP_old. Afterwards your rosorin alias would have to point at the factory system again. I never ran this way back, so it's untested.
The new system has a new user, new SSH host keys and no Wi-Fi, and your router picks its wired address. On my first install it came up at a different address. On the second it came up at ROBOT_WIRED_IP, the address the router already kept for that cable, and I found it by its MAC as shown here. From the laptop, wake every address on your network once and look for that MAC. On macOS, arp drops leading zeros (...:06 prints as ...:6), so search for the first five parts only:
for i in $(seq 1 254); do ping -c1 -W 300 192.168.1.$i >/dev/null 2>&1 & done; wait; arp -an | grep -i "<first five parts>"
Right after the reboot your laptop may still list an old entry for the address although nothing answers there yet. Ping the address to be sure. On the second install it answered about three and a half minutes after the reboot.
Your laptop has never seen this system, so before you trust it, check that its host keys are the ones chapter 3 generated. Back up your SSH files, then scan the robot's keys into a file of their own. Use your robot's address:
cp -p ~/.ssh/config ~/.ssh/config.bak && cp -p ~/.ssh/known_hosts ~/.ssh/known_hosts.bak
ssh-keyscan ROBOT_WIRED_IP 2>/dev/null | sort > /tmp/rosorin_new_keys; ssh-keygen -lf /tmp/rosorin_new_keys
On your PC, print the fingerprints of the keys in the staged rootfs:
docker run --rm -v ~/jetson-flash/work:/work:z jetson-flash:r36.4.3 bash -c 'for k in ecdsa ed25519 rsa; do ssh-keygen -lf /work/Linux_for_Tegra/rootfs/etc/ssh/ssh_host_${k}_key.pub; done'
There are three keys, ECDSA, ED25519 and RSA. Every fingerprint must be the same on both sides. The comment after the ED25519 one is the name of the container that made it, something like root@8d5c93826614. If they differ, you're not talking to your new system, so stop. I did this key check on my second install, and all three matched. On the first I let SSH store the key on first contact without comparing it.
Only if all three match, store them:
cat /tmp/rosorin_new_keys >> ~/.ssh/known_hosts
Then replace the Host rosorin block in ~/.ssh/config with one for the new system:
Host rosorin
HostName ROBOT_WIRED_IP
HostKeyAlias ROBOT_WIRED_IP
User burgerbarn
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
ServerAliveInterval 30
ServerAliveCountMax 4
IdentitiesOnly yes offers only this key, not every key your SSH agent holds. The two ServerAlive lines notice a dead connection after about two minutes. HostKeyAlias stores and checks the robot's host key under one fixed name, whatever address you connect to. That pays off once the robot has Wi-Fi. Its Wi-Fi address will likely be the one the factory system used, and your known_hosts still holds the factory's keys for it. With the same HostKeyAlias in the Wi-Fi alias, both aliases check against the new system's key. Keep the factory keys in known_hosts; you'd need them if you ever go back.
I didn't type this block out whole. On my second install I already had a block like it and changed only its HostKeyAlias line to the new address; the result is the block above. Check what the alias resolves to, and log in:
ssh -G rosorin | grep -E "^(hostname|hostkeyalias) "; ssh rosorin 'hostname; findmnt -no SOURCE /'
On my second install:
hostname ROBOT_WIRED_IP
hostkeyalias ROBOT_WIRED_IP
rosorin
/dev/nvme0n1p1
That system lived on p1. Following this chapter, the last line is /dev/nvme0n1p16.
The rest of this chapter reaches the robot through the rosorin alias. When I ran these steps, I typed burgerbarn@ and the robot's address in some commands instead; apart from that, they're as I ran them.
One NVIDIA service fails on this first boot. Look at it:
ssh -o BatchMode=yes rosorin 'journalctl -b -u nv-l4t-bootloader-config.service --no-pager | tail -25'
nv-l4t-bootloader-config.sh[1456]: Error: Cannot open /etc/nv_boot_control.conf for reading.
nv-l4t-bootloader-config.sh[1456]: Cannot install package. Exiting...
systemd[1]: nv-l4t-bootloader-config.service: Failed with result 'exit-code'.
/etc/nv_boot_control.conf describes the board. It's the file with the TNSPEC lines you read in chapter 3. NVIDIA's flash tool writes it during a normal flash, so a system copied in by hand doesn't have one. The factory system has the right file for this exact board, so copy it from APP_old.
sudo on the new system still asks for your password, so it needs a real terminal. Run this single line from your laptop:
ssh -t rosorin 'sudo mount -o ro,noload /dev/nvme0n1p1 /mnt && sudo cp /mnt/etc/nv_boot_control.conf /etc/ && sudo umount /mnt && sudo systemctl restart nv-l4t-bootloader-config.service && echo BOOTCTL_FIXED'
Type your password when it asks. It should end with BOOTCTL_FIXED. This exact line, with p1, wasn't run. On my first install I typed the same four commands one by one in a session on the robot, with a plain -o ro mount. On my second install I ran this line with /dev/nvme0n1p16 in place of /dev/nvme0n1p1, because there the board's file came from the first new system, and it printed BOOTCTL_FIXED. The noload matters: a plain read-only mount still replays the filesystem's journal if it wasn't cleanly closed, and that writes to the factory partition. noload skips it, so nothing on p1 changes. Then check the service:
ssh -o BatchMode=yes rosorin 'systemctl show nv-l4t-bootloader-config.service -p Type -p Result -p ExecMainStatus -p RemainAfterExit; journalctl -b -u nv-l4t-bootloader-config.service --no-pager | tail -14; systemctl --failed --no-legend | wc -l'
Type=oneshot
RemainAfterExit=no
Result=success
ExecMainStatus=0
... nv-l4t-bootloader-config.sh[2829]: COMPATIBLE_SPEC 3767-000-0000--1--jetson-orin-nano-devkit-super-
... nv-l4t-bootloader-config.sh[2829]: TEGRA_BOOT_STORAGE nvme0n1
... nv-l4t-bootloader-config.sh[2829]: TEGRA_CHIPID 0x23
and 0 at the end, for no failed units.
This service can update the bootloader in the module's flash chip, so I read its script before I let it run. Its automatic update only acts on an Orin Nano developer kit configuration with module SKU 0005. This module is SKU 0000, the 3767-303-0000 in the TNSPEC line, so it leaves the flash chip alone.
From here on, the robot is the new system, logged in as burgerbarn. Send this whole block with ssh -o BatchMode=yes rosorin 'bash -s' <<'EOF' as before:
echo "== identity"; hostname; whoami; id
echo "== root fs"; findmnt -no SOURCE,FSTYPE /; lsblk -no PARTLABEL,PARTUUID $(findmnt -no SOURCE /)
echo "== kernel"; uname -r; cat /proc/cmdline
head -1 /etc/nv_tegra_release; lsb_release -ds
echo "== net"; ip -br addr | grep -v "^lo"
echo "== model"; tr -d "\0" < /proc/device-tree/model; echo
echo "== hiwonder remnants"; systemctl list-unit-files --no-legend 2>/dev/null | grep -Ei "start_app|button_scan|find_device|wifi\.service|nxserver|remote\.service|set_default_device|sync_typerc" || echo none
ls /home
echo "== failed units"; systemctl --failed --no-legend
echo "== sudo"; sudo -n true 2>&1 | head -1
The start of mine:
== identity
rosorin
burgerbarn
uid=1000(burgerbarn) gid=1000(burgerbarn) groups=1000(burgerbarn),4(adm),20(dialout),27(sudo),29(audio),44(video),104(render),996(weston-launch)
== root fs
/dev/nvme0n1p16 ext4
APP ef01d088-5975-4263-b620-2d0f5137dfe1
== kernel
5.15.148-tegra
root=PARTUUID=ef01d088-5975-4263-b620-2d0f5137dfe1 rw rootwait rootfstype=ext4 mminit_loglevel=4 console=ttyTCU0,115200 firmware_class.path=/etc/firmware fbcon=map:0 nospectre_bhb video=efifb:off console=tty0 bl_prof_dataptr=2031616@0x471E...
The bootloader adds its own arguments after yours, such as bl_prof_dataptr=.... That's normal.
Further down you should see # R36 (release), REVISION: 4.3, Ubuntu 22.04.5 LTS, the wired card enP8p1s0 with its address, the model NVIDIA Jetson Orin NX Engineering Reference Developer Kit Super, and only burgerbarn in /home. The hiwonder remnants line searches for the factory's own services by name and must print none, because this system was built without any of them. There should be no failed units. The last line is sudo: a password is required; that changes below.
The nvautoconfig file from chapter 3 made NVIDIA's late-boot script run two jobs once: grow the root partition and set up swap.
df -h / | tail -1
swapon --show
ls -la /etc/nv/
/dev/nvme0n1p16 352G 6.7G 330G 2% /
NAME TYPE SIZE USED PRIO
/dev/zram0 partition 978.5M 0B 5
/dev/zram1 partition 978.5M 0B 5
...
/dev/zram7 partition 978.5M 0B 5
The partition you made as 128 to 256 GB now runs to the end of the drive. NVIDIA's resize script only does that when the root partition is the last one on the drive, which p16 is. Swap is eight compressed-memory devices of 978.5M each, not a swap file. /etc/nv/ lists only . and .., because the script deletes nvautoconfig when it's done, so these defaults run only once.
Every install script from here on runs with sudo, many of them over non-interactive SSH, and typing the password each time is too much. The risk is limited: SSH takes only your key, and password and root logins are off. Do this on the robot only, not on your PC.
The rule is one line in a file in /etc/sudoers.d. Always check such a file with visudo -c before installing it. A file there with a syntax error can stop sudo from working at all, and then you have no root access to fix it. This one line from your laptop writes the file, checks it, and installs it with the owner and mode sudo requires. The && stops at the first failure, and -t gives sudo a terminal for your password, one last time:
ssh -t rosorin 'printf "burgerbarn ALL=(ALL) NOPASSWD:ALL\n" > /tmp/90-burgerbarn && sudo visudo -cf /tmp/90-burgerbarn && sudo install -m 0440 -o root -g root /tmp/90-burgerbarn /etc/sudoers.d/90-burgerbarn && echo SUDO_DONE'
It ends with SUDO_DONE. Check it:
for i in $(seq 1 30); do ssh -o BatchMode=yes rosorin 'sudo -n true' 2>/dev/null && { echo "passwordless sudo works"; break; }; sleep 5; done; ssh -o BatchMode=yes rosorin 'sudo -n ls -l /etc/sudoers.d/90-burgerbarn; sudo -n cat /etc/sudoers.d/90-burgerbarn'
You should see passwordless sudo works, the file listed as -r--r----- 1 root root 34, and the line burgerbarn ALL=(ALL) NOPASSWD:ALL. To undo it, sudo rm /etc/sudoers.d/90-burgerbarn.
The plain Ubuntu ships brltty, a daemon for Braille displays. On my robot it filled the journal with Ignored Byte lines, and it's the only package I removed. First look, and simulate the removal. These run on the robot:
journalctl -b --no-pager -u brltty -u brltty-udev 2>/dev/null | grep -iE "tty|serial|device" | head -5
apt-get -s purge brltty 2>&1 | grep -E "^(Purg|Remv|Inst)|newly installed|to remove"
You may see a few brltty: Ignored Byte: 09 lines, or none. The simulation must remove exactly one package:
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Purg brltty [6.4-4ubuntu3]
Then remove it for real and check:
sudo apt-get purge -y brltty
dpkg-query -W -f='${Package} ${db:Status-Abbrev}\n' brltty 2>&1
pgrep -x brltty || echo "no brltty process"
You want brltty un, where un means not installed, and no brltty process. The purge may also print dpkg: warning: while removing brltty, directory '/var/lib/BrlAPI' not empty so not removed, which is harmless.
After the purge, apt suggests apt autoremove. Never run it on the robot. The packages it wants to remove include initramfs-tools, which builds the initrd the robot boots with. Ignore that suggestion here and after every later removal.
The robot's software will be many separate ROS 2 programs exchanging messages. When two of them run on the same machine, they pass data through shared-memory files in /dev/shm, and those files belong to the user the programs run as, burgerbarn. By default, systemd's login manager deletes a user's shared memory when that user's last login session ends. The robot's services run as burgerbarn without a login session, so on my robot, closing my last SSH session silenced every running program. They saw no messages at all for 30 seconds and more.
There's no ROS 2 on the robot yet, but set this now, before anything depends on it:
ssh rosorin 'sudo mkdir -p /etc/systemd/logind.conf.d && printf "[Login]\n# rosorin-base runs as burgerbarn; default RemoveIPC=yes deletes its FastDDS /dev/shm segments\n# when the last burgerbarn login session ends -> base nodes go silent.\nRemoveIPC=no\n" | sudo tee /etc/systemd/logind.conf.d/10-rosorin-keep-ipc.conf >/dev/null && sudo systemctl restart systemd-logind && systemd-analyze cat-config systemd/logind.conf | grep "^RemoveIPC"'
It prints RemoveIPC=no. systemd-analyze cat-config merges the main file and all the extra files, so that's the setting that's actually in force. After this change on my robot, the shared-memory files survived separate SSH sessions, and a new program got its first message after 0.6 to 1.7 seconds. If programs ever go silent after you log out, check this file first.
On a stock install, the system journal lives only in memory, so a reboot wipes it. I lost the log of a failed stop that way, because the reboot that ended the problem also erased the record of it. The default setting, Storage=auto, keeps the journal on disk if the folder /var/log/journal exists, so the fix is to create that folder correctly.
Install scripts in this guide live in ~/setup on the robot. Create the folder and write the script there. On the robot:
mkdir -p ~/setup
cat > ~/setup/persistent_journal.sh <<'EOS'
#!/bin/bash
# Rollback: sudo rm -rf /var/log/journal && sudo systemctl restart systemd-journald
set -euo pipefail
[ "$(id -u)" = 0 ] || { echo "run with sudo"; exit 1; }
mkdir -p /var/log/journal && systemd-tmpfiles --create --prefix /var/log/journal
journalctl --flush; systemctl restart systemd-journald
journalctl --disk-usage
EOS
The id -u line refuses to run without root. The script creates the folder with the ownership and permissions systemd's own rules define, moves the in-memory journal to disk, restarts the journal service and prints the space it uses. The comment line says how to undo it. Run it from the laptop:
ssh rosorin 'sudo bash ~/setup/persistent_journal.sh | tail -1'
It prints a line like Archived and active journals take up 312.0M in the file system. The size will differ.
The stock install boots into a graphical login screen, and the robot has no screen. The login screen used about 340 MB of memory on mine, and its sound server held on to audio devices the robot needs for itself. A systemd target is a named set of services that systemd brings up at boot. graphical.target includes the login screen; multi-user.target is everything except that. Switch the default and stop the login screen that's running now. On the robot:
sudo systemctl set-default multi-user.target
sudo systemctl stop gdm3
systemctl get-default; echo "desktop processes left: $(pgrep -c "gnome-shell|Xorg|gdm")"
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/multi-user.target.
multi-user.target
desktop processes left: 0
To undo it, sudo systemctl set-default graphical.target.
Each user has their own systemd manager that runs that user's background services, for example the sound server. Normally it starts at the first login and stops at the last logout. Linger makes it start at boot and stay running with nobody logged in. The first time I booted my robot without a desktop, it was off. Turn it on:
sudo loginctl enable-linger burgerbarn
loginctl show-user burgerbarn -p Linger
It prints Linger=yes.
NetworkManager runs the wired card on its own as Wired connection 1, with an address from your router. To make that address fixed, reserve it in your router by the card's MAC. Read the MAC on the robot:
ip -br link show enP8p1s0
The line shows enP8p1s0, UP and the MAC. It's the same MAC you found the robot by, since it's the same card. This chapter records only the wired card's MAC. The Wi-Fi card has no driver yet, so its MAC comes in chapter 5. Set the reservation in your router to the address in your rosorin alias. My router already had a reservation for that cable, so I didn't have to change anything. Before it had one, the wired address once moved by itself when the router handed out a new lease. You'll reserve the Wi-Fi address the same way once Wi-Fi works in chapter 5.
If you see NO-CARRIER right after plugging in a cable, wait. On my factory system it took about two minutes from NO-CARRIER to an address.
Reboot once and check that every setting survived. Use the same reboot line as before:
ssh -o BatchMode=yes -o ServerAliveInterval=3 -o ServerAliveCountMax=2 rosorin 'sync; sudo -n systemctl reboot'
My robot answered SSH again after 42 seconds. Then:
ssh rosorin 'systemctl get-default; loginctl show-user burgerbarn -p Linger; systemd-analyze cat-config systemd/logind.conf | grep "^RemoveIPC"; ls -ld /var/log/journal; dpkg-query -W -f="\${Package} \${db:Status-Abbrev}\n" brltty; sudo -n true && echo "passwordless sudo works"; systemctl --failed --no-legend | wc -l'
You should see multi-user.target, Linger=yes, RemoveIPC=no, the journal folder listed as drwxr-sr-x+ 3 root systemd-journal, brltty un, passwordless sudo works, and 0 failed units.
Now check that the journal kept the boot before this one. This lists every boot the journal holds, skips the running one, and prints the last two lines of each of the others. On the robot:
cur=$(tr -d - < /proc/sys/kernel/random/boot_id); for b in $(journalctl -F _BOOT_ID); do [ "$b" = "$cur" ] || { echo "boot $b:"; journalctl -b "$b" -n 2 --no-pager; }; done
Mine printed one boot ID and its last two lines:
systemd-shutdown[1]: Sending SIGTERM to remaining processes...
systemd-journald[3352]: Journal stopped
Those are the last words of the boot you just ended, read back from disk. Once more boots are stored, it prints two lines for each.
The usual way to look at the previous boot, journalctl -b -1, doesn't work on a fresh install of this robot. After my first reboot it printed Data from the specified boot (-1) is not available: No such boot ID in journal, although the previous boot was on disk. The robot's clock is wrong for the first seconds of every boot, years in the past until the network time arrives, and the journal orders boots by time, so it can't work out which boot came before. For the same reason, journalctl --list-boots showed a single boot. Use the boot ID loop above instead.
This chapter also has no tested way onto a drive without free space next to the factory install, or onto a blank or replaced drive. NVIDIA has a method for writing a blank drive from a PC, with the drive in a USB enclosure. I built its images on my PC, but I never wrote a real drive with it or booted from one, so it isn't in this guide.
Four things above are untested. I never put a laptop key onto the factory ubuntu account, because mine was already there, and I never ran the way back to the factory system. There is also no tested way to back up the factory system before you install, and no tested command to pack the camera driver from it.
You're ready for the next chapter when lsblk -o NAME,PARTLABEL,PARTUUID /dev/nvme0n1 shows exactly one APP, on p16, with the factory system kept on p1 as APP_old. ssh rosorin hostname prints rosorin with your key, findmnt -no SOURCE,FSTYPE / prints /dev/nvme0n1p16 ext4, and /proc/cmdline contains your PARTUUID, which you have written down. systemctl show nv-l4t-bootloader-config.service -p Result prints Result=success. ssh rosorin 'sudo -n true && echo ok' prints ok without asking for a password. After the reboot the default target is multi-user.target, linger is on, RemoveIPC=no holds, and the journal shows the previous boot by its ID. brltty is un, you didn't run apt autoremove, the wired link has its fixed address, and systemctl --failed lists nothing.