Hello,
I’ve found how to mount SSD as rootfs with extlinux.conf APPEND, but in still requires initrd modification (modification of this method).
Main problem: initrd created by JetPack 4.4 has init script, that search for root device first as device name format, then as PARTUUID format. Then only “PARTUUID*”, “mmcblk*”, “sd*”, “nfs” are acepted as legal rootdev string. init[62…173]:
rootdev=“$(sed -ne 's/.\broot=/dev/([abcdefklmnps0-9])\b./\1/p’ < /proc/cmdline)"
if [ “${rootdev}” == “” ]; then
uuid_regex=‘[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}’
rootdev="$(sed -ne "s/.\broot=(PARTUUID=${uuid_regex})\b.*/\1/p” < /proc/cmdline)"
fi
if [ “${rootdev}” != “” ]; then
echo “Root device found: ${rootdev}” > /dev/kmsg;
fi
if [[ “${rootdev}” == PARTUUID* ]]; then
-------
elif [[ “${rootdev}” == mmcblk* ]]; then
-------
elif [[ “${rootdev}” == sd* ]]; then
-------
elif [[ “${rootdev}” == “nfs” ]]; then
-------
else
echo “No root-device: Mount failed” > /dev/kmsg;
exec /bin/bash;
fi
Patch init
Initrd source will be in dir_initrdssd folder. Patch init script with following patch init.patch:initpatch.log (1.4 KB)
(only .log text files are accepted by forum :( )
Patch changes priority to PARTUUID over device name and adds "nvme" as accepted rootfs name.
Pack back
sudo …/pack.sh
initrdtossd in folder with scripts will be created. Copy this file to /boot
sudo cp …/initrdtossd /boot/
Edit extlinux.conf
Find PARTUID of nvme partition with future rootfs.
systemd service
In this case systemd service setssdroot.service runing before local-fs-pre.target is used ( after systemd-remount-fs.service from initrd, if initrd with systemd is used) . So it’s one of the first runing units when system starts up. But, there are parallel targets swap.target, cryptsetup-pre.target , various low-level services. (systemd bootup ) . This service executes script, which switches rootfs with systemctl call /bin/systemctl --no-block switch-root ${CHROOT_PATH}.
Pros:
No initrd or extlinux.conf required. So, work with JetPack 4.2, where kernel is located in special partition.
After building new kernel, default initrd update workflow is required, no manual modification of initrd (i.e. flash.sh ...).If system doesn’t use initrd, we need only install modules on SSD and eMMC.
If /dev/nvme0n1p1 is absent, default rootfs is used, because setssdroot.service will not be executed.
Cons:
It’s still hack:) .
There are units, executing in parallel with setssdroot.service, including udevd, thus, for some devices modules will be loaded from rootfs on eMMC while others from NVMe. That’s why we need to install same modules on both.
I don’t understand why, but we need copy of setssdroot.service and setssdroot.sh on NVMe, otherwise service completes with error (but still switches rootfs).
extlinux.conf APPEND
In this case APPEND line with new “root=…” parameter is added to extlinux.conf. At kernel loading stage cboot appends this line to kernel cmdline. So cmdline have 2 “root=…” parameters: first - “root=/dev/mmcblk0p1” from device tree for cboot, second - custom, appended with extlinux.conf directive.
Pros:
Normal system bootup sequence. Main and backup kernel could be different.
All modules are loaded from initrd or rootfs on NVMe only. One needs only to copy new kernel image and it’s initrd to /boot/ directory on eMMC and configure /boot/extlinux/extlinux.conf there. No modules installation for new kernel on eMMC required. (Except when the same kernel image is used as backup).
Backup kernel is set by extlinux.conf :
LABEL backup
MENU LABEL backup kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} quiet
It can have it’s own initrd and only it’s modules are installed on eMMC.
Cons:
Only JetPack 4.4 now is supported, because cboot with extlinux.conf parsing is required.
Hi everyone,
I was able to use initrd produced by ubuntu for second method ( extlinux.conf APPEND), thus removing manual manipulations with initrd.
Steps:
Flash device (Xavier AGX or NX (tested on AGX only)) with JetPack 4.4.
Add update-initramfs hook to add xusb firmware to initrd.
a. Create file tegra-xusbfw with following content (Remove log extention tegra-xusbfw.log (306 Bytes) ):
b. Make file executable and copy to /usr/share/initramfs-tools/hooks directory.
c. Generate initrd:
sudo update-initramfs -c -v -k all
d. Check in log that “tegra19x_xusb_firmware” was added.
e. At this step you should have file initrd.img-4.9.140-tegra in /boot directory.
Edit /boot/extlinux/extlinux.conf
sudo gedit /boot/extlinux/extlinux.conf
Edit INITRD parameter and add APPEND parameter to primary record. Should be something like this (extlinux.conf.log (383 Bytes) ):
TIMEOUT 30
DEFAULT primary
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
INITRD /boot/initrd.img-4.9.140-tegra
APPEND ${cbootargs} root=PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX->XXXXXXXXXXXX quiet
LABEL backup
MENU LABEL backup kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} quiet
DON’T FORGET to copy rootfs to SSD!!!.
Reboot
Kernel don’t rises any errors while booting from this initrd.
It would be good if someone from NVIDIA check if ubuntu generated initrd didn’t miss any other modules.
USB firmware is needed because otherwise the usb port will not work.
If you use initrd generated without firmware hook, system do will boot, you will see login screen, but without keyboard it’s useless :).
P.S. I will try APPEND parameter combinations later on weekends.
Yeah but what’s that got to do with nvme unless you’re using a usb<>nvme bridge. I may have gotten lost between this thread and the one on the NX forum. Are you using usb<>nvme or pcie<>nvme?
2.1 With initrd, installed while flashing with JetPack 4.4.
This case requares patching init script in initrd, as default init script prioritirizes root=/dev/[somedevice] over root=PARTUUID=.... .
With default init APPEND below doesn’t work for some still unknown reason. (Boot stops at initrd’s console, as if there is no device, but I see /dev/nvme0n1p1 there ???)
first root=/dev/mmcblk0p1 is prioritirized and system boots to rootfs on eMMC.
2.2 With initrd generated by update-initramfs in ubuntu.
In this case Xavier is flashed with JetPack 4.4, then new initrd is generated on Xavier itself and extlinux.conf edited to point on new initrd and APPEND root=PARTUUID= added.
This initrd lacks xusb firmware, but has no problems with parsing root=xxx parameter. So linux boots to rootfs on NVMe well, but USB ports are not functional, so no mouse or keyboard could be used.
To add xusb firmware, hook is registered (this post) before update-initramfs.
Thus 2.2 method is most traditional from Linux view, IMHO.
example my device partuuid
/dev/nvme0n1p1: UUID=“b11f5460-ec67-4f4a-9c41-8cffd4b11df4” TYPE=“ext4” PARTLABEL=“primary” PARTUUID=“532ead91-c15f-4412-83b5-e5675ff21773”
clone emmc to ssd sudo dd if=/dev/mmcblk0p1 of=/dev/nvme0n1p1
Thanks, @jocover . I have repeated your method. It works great and doesn’t requires any system modifications, unlike APPEND methods. IMHO, it’s the best method in cases where restoration system on eMMC is not required.
I think it should be noted that after sudo ./flash.sh jetson-xavier external all data on eMMC will be rewrited and APP partition consists only boot folder:
First root= is from cboot. Now it’s allready in root=PARTUUID= format and for original initrd APPEND ${cbootargs} root=/dev/mmcblk0p1 in extlinux.conf should enable to load rootfs from eMMC (that must be copied there manualy).
About original initrd. It’s main feature - it doesn’t contain any modules, only libs and firmware, so it works with modified kernels ( original dmesg.orig.log (75.6 KB) , build on Xavier (added KVM hw support like there) dmesg.orig-exp2.log (75.9 KB) ): ls-initrd.orig.log (7.6 KB)
I also have tested with initrd generated by update-initramfs (with xusbfw hook).
Original kernel work fine with initrd generated for it.
Builded on Xavier kernel with it’s initrd failed to boot. Cboot failed to load initrd. I will create new topic for this problem later. initrd-ubuntu-exp2-cutecom.log (23.5 KB)
But modified kernel booted with update-initramfs generated initrd without any taunted modules (dmesg.ubuntu-exp2tgr.log (75.8 KB) ).
Main difference of generated initrd - it’s size. ls-initrd.ubuntu.log (39.2 KB) ls-initrd.ubuntu-exp2.log (39.3 KB)
As I did not have a system running Ubuntu, I was unable to use the SDK method to install JetPack on my Jetson AGX Xavier. I flashed the image to a uSD card, and boot from it.
I would prefer to boot from NVMe SSD. Are any changes required to move the rootfs from uSD to SSD?
Hi everyone,
I have used system installed on SSD with @jocover 's method without any problem for some weeks. But today Ubuntu Update downloaded some updates from nvidia repository ( this and this ), requested to reboot and then Xavier failed to boot system, hanging on initrd step.
Log from debug port: afterupdate-ubuntu-exp2(tgr)-cutecom.log (27.6 KB)
I tried backup kernel (original), but it panic. afterupdate-ubuntu-orig-cutecom.log (56.2 KB)
There was strange thing in log. After update root=/dev/mmcblk0p1 parameter is back!!! Kernel tried to switch rootfs on /dev/mmcblk0p1, that didn’t contain system in @jocover 's method.
So, device block with cboot device tree on eMMC was rewrited. I think it’s nvidia-l4t-bootloader package doing.
I had to reflash Xavier from JetPack to repair boot. ( sudo ./flash.sh jetson-xavier external)
System on SSD didn’t take any damage and after reboot system loaded with rootfs from SSD. I copied /boot folder from SSD ( updated from repository kernel and new device trees installed there ) to eMMC and rebooted.
Now Xavier works like before.
So, it should be noted, that now Nvidia firmware updates doesn’t take into account if system was flashed with sudo ./flash.sh jetson-xavier external and reflashing from external PC with JetPack will be needed after update. Systemd method should be resistant against updates as it doesn’t use bootloader features.
In all cases coping from /boot of SSD to /boot on eMMC will be required.
But today Ubuntu Update downloaded some updates from nvidia repository ( this and this ), requested to reboot and then Xavier failed to boot system, hanging on initrd step.
IMO it’s safer to just put commonly used stuff on a ssd and not the entire of /. I’m not sure how much benefit you get from having stuff like /etc on an ssd, since it’s mostly a bunch of text files.
My partition layout looks like:
nvme0n1 259:11 0 931.5G 0 disk
├─nvme0n1p1 259:12 0 119.2G 0 part /tmp
├─nvme0n1p2 259:13 0 323.9G 0 part /home
├─nvme0n1p3 259:14 0 250G 0 part /usr
└─nvme0n1p6 259:15 0 238.4G 0 part /var/lib/docker
Those are just ext4 partitions on a GPT disk, but you may wish to use something fancier like LVM or btrfs with subvolumes for easier resizing.