Getting a NVME card ready

 

 

Ok, the next challenge. Installing the software

Now there are an easy way to do this, and hard ways. This is the hard way. Why not take the easy way? 

Well, you may have noticed, people like me are masochists looking for a hit. This is what keeps us going. Also, this is the learning curve. It is all very good, to have tools automate everything, but when the poo hits the rotating object, it is good to know why things work

We will break down this into 3 stages

1. Install the Pi OS

2.  Get the M.2 NVME board recognized

3. Install the Pi OS onto it

To do this, I largely followed To do this, I followed this tutorial.

However, there were some issues, so we will work through them

Step 1.Install Pi OS

 
Note: you must do this step before you build your Argon box, because you cannot access SD card slot from outside the case 
 
Note:  use a reasonable size card (e.g 32 GB) since we need to load an OS image onto it

The 1st step is to install our initial Pi OS. To start with, we must boot via the micro SD card, because the pi by default does not know anything about M.2 slots (Hopefully this will be fixed at some point as M.2 become more ubiquitous)

Over the years, the Raspberry Pi organization have made things far easier in this respect. The go-to tool is the Raspberry Pi Imager.

For this, we are installing the 64bit lite version. We don't need an HMI and the OS will only be used long enough to bring the M.2 card up.

This tool, simplifies installation to virtually a single step. It downloads, and installs the OS on your micro SD card, then initially configures it. The main important step is to set your SSH username/password. You will need that, so remember to note it down.

Once loaded, and the card installed, you can reboot your Pi. If you have a monitor, you should see the Pi start up. If not, you will have to find the IP address of your Pi (Normally you will attach it to a router and find it that way).

You should be able to ping it and then login via SSH.

On Windows you can use

ssh -l <username> <IP address>

via a console window. Login using your username and password previously defined

We now need to tell the Pi, about it's NVME card

Stage 2 Get NVME recognised

To do this, we need to add the following line to /boot/firmware/config.txt

so type 

sudo nano /boot/config.txt

and add the following line

dtparam=nvme

This configures the system to recognise that it has a nvme device attached.

Secondly, we need to tell the system  to try booting from it. By default, the system will not recognize the NVME as a boot device

Type

sudo rpi-eeprom-config --edit

This is a Pi 5 special. Previous versions use a file called boot.bin to boot the Pi. Pi 5 do it from a dedicated hardware device called an EEPROM. So we have  to use a tool to configure it

Change the line BOOT_ORDER to 

BOOT_ORDER=0xf416

(The boot order defines which device to try booting from 1st and is defined here. Note it does it in the reverse order, so 6 says boot from NVME, 1 - SD card etc, why it is so obscure is a mystery)

Also add  the line, so the

PCIE_PROBE=1

Type Ctrl-O and Ctrl-X to get out of it, and the changed settings will be copied to the EEPROM. This only has to be done once.

You can now reboot (e.g sudo reboot)

Stage 3. Install the Pi OS on the M.2 card

The controller should reboot and you will be able to login again via SSH

If you type lsblk you should see something like this

The mmcblk0 is your present boot disk with two partitions. However, we know have a nvme0n1 disk, which is our M2 disk. We cannot use it yet, because no software is on it

To install it, we must load a Pi OS image onto it.  To do that, download your image onto your PC. We know need to transfer it. To do that we can use SFTP using your SSH username and password

On a new console windows type. Goto the directory in which your download is stored

sftp <usename> @<IP Address>

Login using the user password and type

put <image name>

(Note it will end in .xz)

Via your SSH console, you should then see the image file

 Before we install it however, we must unpack it. Pi OS images are now compressed using the xz algorithm. The imaging tool, does not understand it, so 1st unpack it with the following command (if you are not sure whether it is compressed run file <image name>. It should say XZ compressed data)

Run

xz -d 2024-07-04-raspios-bookworm-arm64-lite.img.xz

This will create a file with the .xz extension removed

If you run file  against it, it will say it contains two partitions

We can then image our new disk with the following command

time sudo dd if=./<Image name> of=/dev/nvme0n1

This will do an identikit copy of our image onto our M.2 disk. It will take roughly 30 seconds

We now need to mount the partitions so we can access them. This is so we can tell the new boot partition to recognize the NVME disk like we dis above. We also need to add our SSH parameters so we can still access the console when we reboot

if you do a lsblk

You will now see this

As you can see, we have 2 new partitions.

Type 

sudo mount /dev/nvme0n1p1 /mnt

If this succeeds, type ls /mnt

and you will see the files of the boot partition

First, let's add our SSH credentials

Type 

HASH=$(openssl passwd -6 -stdin)

and add your SSH password

Then type

echo <usernamed>:$HASH  | sudo tee /mnt/userconf.txt

This adds a user to log into

then type the following

sudo touch /mnt/ssh
echo "dtparam=nvme" | sudo tee /mnt/config.txt

This configures the ssh and sets the nvme option

One last thing to do. Although we have now installed our OS, we need to expand the partitions to fill the entire card. By default the image comes with minimal partitions (2.1 G). Our M.2 is far larger, so we need to take advantage of that,

Therefore type

raspi-config --expand-rootfs

If you run lsblk again, you will see the main partition is now the size of the entire disk

So now we are good to go. Type sudo reboot

Login again using SSH (Note: windows may complain because the SSK key has changed. If so, typessh-keygen -R 192.168.1.193  )

if you type lsblk you should see something like this

As you can see, the boot partition is now on the nvme disk

Job Done!


Comments

Popular posts from this blog

A Bridgen too far

Coloring Old images

Argon 1 Review