How to Boot from NVMe SSD?

After reflashing to JetPack 4.4 DP I had time to play with booting from SSD again and here are some remarks. Because forum fobids sharing archives with scripts, formated text will be included.

  1. I added conditional start for service on /etc/setssdroot.conf (on mmcblk0p1) availability. To mount rootfs from eMMC, file /etc/setssdroot.conf on mmcblk0p1 should be deleted.
    setssdroot.service:

[Unit]
Description=Change rootfs to SSD in M.2 key M slot (nvme0n1p1)
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-remount-fs.service
Before=local-fs-pre.target local-fs.target shutdown.target
Wants=local-fs-pre.target
ConditionPathExists=/dev/nvme0n1p1
ConditionPathExists=/etc/setssdroot.conf
ConditionVirtualization=!container
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/setssdroot.sh
[Install]
WantedBy=default.target

  1. setssdroot.service and setssdroot.sh should be on both mmcblk0p1 and nvme0n1p1 else service report error to journal, still switching rootfs.

  2. At JetPack 4.4 propoused to install new kernels and modules with deb packet. One should remember, that after installation, kernel, initrd and modules to rootfs switched to SSD would be placed on /boot/* and /lib/modules/[kernel name]/ on SSD and should manualy be copied to same folders on mmcblk0p1. Because Image and initrd, located in mmcblk0p1 /boot folder, pointed by /boot/extlinux/extlinux.conf data in mmcblk0p1, is booting with CBoot. If modules version in initrd on mmcblk0p1 and /lib/modules/[kernel name]/ on SSD will be different, modules load will be tainted.

So, step by step guid will be the following:

  • Flash Xavier with rootfs on eMMC (default with SDKManager)

  • Install default software, that will be needed on main (SSD) and restoration (eMMC) systems.

  • Copy rootfs to SSD.

#!/bin/bash
sudo mount /dev/nvme0n1p1 /mnt
sudo rsync -aAXv / --exclude={“/dev/“,”/proc/”,“/sys/“,”/tmp/”,“/run/“,”/mnt/”,“/media/*”,“/lost+found”} /mnt

  • Install service (steps 3-5 from my previous post, setssdroot.service from top of this post).

  • Copy service files to SSD

sudo cp /etc/systemd/system/setssdroot.service /mnt/etc/systemd/system/setssdroot.service
sudo cp /sbin/setssdroot.sh /mnt/sbin/setssdroot.sh

  • Install software for restoration rootfs (on eMMC). It is possible to reboot back in this rootfs if /etc/setssdroot.conf file is absent.

  • Create file /etc/setssdroot.conf

sudo touch /etc/setssdroot.conf

  • Reboot system. You will boot in new rootfs located in SSD.
    Don’t forget to synchronize /boot/ /lib/modules/ folders with eMMC when moding kernels.

When rootfs on SSD is used, /dev/mmcblk0 is unmounted, so we can backup it with dd.
Rootfs on SDD can be safely backed after loading back into rootfs on eMMC:

sudo mount /dev/mmcblk0p1 /mnt
sudo rm /mnt/etc/setssdroot.conf
reboot

For backups I use SSD drive connected to M.2 key E throught M.2 key E to m.2 key M adapter from aliexpress.

3 Likes