Myy Posted April 5, 2020 Posted April 5, 2020 Greetings, Here's a quick and very dirty way to use the NVMe disk for the whole system, except the boot files and kernels which will be read from the SDCard. This method is UNSUPPORTED. Meaning that if you follow this procedure and your system broke, catched fire and start attacking you in your sleep, it's on you ! The reason I keep booting on the SDCard are : This makes boot issues easier to deal with since all the files are more easily accessible. It's easy to quickly read a SDCard from a PC using a SDCard reader USB dongle bought from the local store. Meanwhile mounting a NVMe<->USB readers are not that common. It's pretty much guaranteed that the bootloader knows how to boot a SDCard. The procedure is documented here : https://gist.github.com/Miouyouyou/e78f4caa9ce3fea72430dca57a00449b Here's a copy of its content : Moving most of the system (but not the kernel) onto the NVME disk This document describes how to make the system : boot on a SDCARD load the kernel from the SDCARD mount a NVMe partition as / use / for the whole system and applications In this document folder and directory mean the same thing. The whole idea is to be able to edit the boot files easily (kernel, boot configuration, ...) in case something goes wrong, while benefiting from NVMe read/write speeds for you daily application usage. The procedure described is not "THE BEST", just the one I used that worked in my case. Here are the steps I followed to do that : Prepare a SDCARD with an Armbian image, using Etcher. Install a NVMe M.2 disk on the rear side of the NanoPC T4. Put the SDCARD in the NanoPC T4 SDCARD slot. Boot Armbian and configure your first user. Note : The 'root' account password is 1234 on first boot Create a "Linux root (ARM 64)" partition (and maybe a swap partition if you want) on the NVMe disk.Note : Linux root (ARM 64) ID is B921B045-1DF0-41C3-AF44-4C6F280D3FAENote : The disk can be accessed through /dev/nvme0n1Note : I used cfdisk for that matter, but any decent partitioning software will do. Format the NVMe root partition using mkfs.ext4 For example, if you just made one partition, the device node will be : /dev/nvme0n1p1 and so the command will be :mkfs.ext4 /dev/nvme0n1p1 Mount your NVMe root partition on /mnt. For example, if you just made one partition, the device node will be : /dev/nvme0n1p1 and so the command will be : mount /dev/nvme0n1p1 /mnt Do a filesystem copy of / into /mnt, while ignoring special files created on boot-time :rsync -a -H --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt Use blkid on your NVMe root partition to get its UUID. For example, if you just made one partition, the device node will be : /dev/nvme0n1p1. And so the command will be :blkid /dev/nvme0n1p1 In my case, the command output was : /dev/nvme0n1p1: UUID="cbe70e76-9690-4f69-ab6e-23b887531628" TYPE="ext4" PARTUUID="c4a2536b-5092-0b4b-8178-c4215a52ac4b" Edit /mnt/etc/fstab and replace the UUID part of the line about / by the UUID of your NVMe root partition, that you just got from the last command. The line in question is somewhat like this :UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx / ext4 defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1 In my case, I modified it so that it looked like this :UUID=cbe70e76-9690-4f69-ab6e-23b887531628 / ext4 defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1 Do a copy of /boot/armbianEnv.txt like this : cp /boot/armbianEnv.txt /boot/armbianEnv.working Edit /boot/armbianEnv.txt and replace the UUID in the line rootdev=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx by the UUID of your NVMe root partition. In my case, the line was modified like this :rootdev=UUID=cbe70e76-9690-4f69-ab6e-23b887531628 Reboot and see if it worked.If it didn't, you'll have to remove the SDCard from the NanoPC T4, read it from a Linux PC, mount the boot partition, delete boot/armbianEnv.txt and copy boot/armbianEnv.working over boot/armbianEnv.txt. Then you'll be able to retry the procedure from the point were we get the UUID of the NVMe partition (step 7).If it's working, though, it's not finished ! In order to make kernel upgrades possible, we'll have to link the NVMe root partition /boot folder to the SDCard root partition /boot folder. Use blkid on your SDCard root partition, in order to get its UUID.blkid /dev/mmcblk1p1 In my case the output was :/dev/mmcblk1p1: UUID="c5dcbfc7-886b-4c98-ac2a-4d26eec089e8" TYPE="ext4" PARTUUID="d808ef5d-01" Create a directory /sdcard : mkdir /sdcard Do a backup of your /etc/fstab : cp /etc/fstab /etc/working_fstab Add an entry to /etc/fstab to mount the content of the SDCard boot partition to /sdcard automatically. In my case the UUID of that partition was c5dcbfc7-886b-4c98-ac2a-4d26eec089e8 so the line added was :UUID=c5dcbfc7-886b-4c98-ac2a-4d26eec089e8 /sdcard ext4 defaults,noatime,nodiratime,commit=600,nodev,noexec 0 1 Adapt according to your configuration. Test your /etc/fstab configuration by doing : mount /sdcard If that doesn't work, check back your /etc/fstab. If you messed up, cp /etc/working_fstab /etc/fstab Backup the /boot directory : mv /boot /unused_boot Link your SDCard boot partition boot folder to /boot : ln -s /sdcard/boot /boot Reboot one last time And now you should be able to upgrade your kernel while booted on your NVMe disk, while still being able to access the upgrade kernel and boot configuration from the SDCard. This is very useful when a kernel upgrade broke your system. That way, you just have to remove the SDCard, read it from a Linux computer, replace the broken kernel or edit /etc/armbianEnv.txt to boot temporarily on the SDCARD in order to repair the issue. Improvements /sdcard should only be mounted when boot files have to be updated. This avoid softwares trying to access the SDCard for no reasons.
Recommended Posts