Mauro Morales

software developer

Running MNT Reform OS on an NVME Disk

Running the MNT Reform 2 from an SD card is not a bad solution. It’s similar to the way a Raspberry Pi is run. However, I wanted to free the SD card slot. In this post I describe the whole process from picking and buying an NVMe SSD, to installing and configuring it.

But before I continue, I cannot take credit for this work, as it’s summarized in the Operating System on NVMe Without SD Card Post. I just wanted to give a little more detail into the steps I took, some of the mistakes I made, and add some information related to using an encrypted device.

PARTS AND TOOLS NEEDED

  • 1 NVMe disk
  • 1 Phillips screw driver
  • 1 M2x4mm pan head screw (included in the DIY kit)

PICKING AND BUYING AN NVME DISK

I bought the one that MNT puts on the assembled version of the Reform 2, a 1Tb Transcend MTE220S because I didn’t want to risk it. I bought it from amazon.de (I tried to look for it in local businesses in Belgium but I couldn’t find it in the ones I was suggested to check). The price was around 125 Euro with shipping included.

There’s a community page on Confirmed Working NVMe Drives that will hopefully hold more options in the future but so far, the Transcend disk seems like a very good one.

INSTALLING THE DISK

  1. Disconnect the laptop from the power
  2. Discharge yourself by touching a metal surface or using a discharge bracelet
  3. Remove the acrylic bottom
  4. Remove the batteries
  5. Place the NVMe device in the M2 socket
  6. Secure it

Do not close the laptop just yet. Turn it around, plug the power, turn it on and log in with your user. If the installation was successful, you should be able to see the device on the Disks application

PARTITIONING, FORMATTING AND ENCRYPTING

The next step is to create one or more partitions on the disk. I used Gnome Disks but it’s limited because you cannot do logical volumes, so you might want to install gparted or follow some tutorial for the CLI on how to achieve your specific partitioning setup.

Note: If you are planning to use the whole disk without partitioning and only format the disk, using the Drive Options menu (3 dots at the top right corner). The script mounting your partition /sbin/reform-init might have issues because of the name of the device. At least that’s what I experienced the first time I did this process.

My current setup is one encrypted partition with ext4 file system for root and one encrypted partition with ext4 file system for home (I will write about this in a next post). This means that I have to enter two passwords when booting. I’m planning to use a key in the future but if you don’t want to have to enter two passwords, read about logical volumes, or if you don’t want encryption at all then you don’t have to worry about this.

  1. Select the NVMe Disk
  2. Click on the + sign to create a new partition
  3. Select the size (needs to be at least the size of the SD card) and continue
  4. Give it a name e.g. “root”
  5. Select ext4 as your file system
  6. Select encryption with LUKS
  7. Press “Next”
  8. Add a pass phrase
  9. Press “Done”

MIGRATE YOUR DATA

To copy all your data in the SD card to the NVMe disk, we first need to unlock the disk. The first argument is the path to the device, so it needs to map whatever partition number you did in the previous step. The second argument is the name you want to give, so choose whatever you prefer.

# cryptsetup luksOpen /dev/nvme0n1p1 crypt

The unencrypted partition will be accessible on /dev/mapper/crypt

We can use that path to run the reform-migrate script

# reform-migrate /dev/mapper/crypt

You can of course use Disks to unlock (open lock button) and mount (play button) the device instead. You will need to use the following command to move all your data.

# rsync -axHAWXS --numeric-ids --info=progress2 / /media/USER/NAME

Make sure to update the last argument to be the path to where you mounted the device.

CONFIGURE BOOTING FROM NVME

Booting from the NVMe disk is a two step process. We first need to configure the laptop to boot from the eMMC drive, and configure it to decrypt and mount the NVMe drive and init from it.

Read more about this topic on Section 10.2 and 10.3 from the Operators Handbook.

To switch the booting mechanism from the SD card to the inner eMMC module where the MNT Rescue disk resides, we need to flip a dip switch that resides underneath the heat sink.

  1. Shutdown and disconnect from power
  2. Remove the heat sink (be careful not to put the heat sink bottom flat on top of a surface since there’s some paste in it)
  3. Flip the dip switch on the bottom right (or top left depending on your perspective)
  4. Place the heat sink back in place

We can now plug the power again and start the machine. When prompted for a logging you need to use “root” without a password since this is a completely different system from the one configured on the SD card.

Now we need to download a newer version of U-boot in the rescue disk.

# wget http://mntre.com/reform_md/flash-rescue-reform-init.bin

U-boot is a mini OS used to boot Linux. For what I understand, this “newer” version is just the same version than is in the SD drive, so trying that instead of downloading a new one would also be an option.

To flash the new U-boot we need to unlock the boot partition

# echo 0 > /sys/class/block/mmcblk0boot0/force_ro

And flash the binary

# dd if=flash-rescue-reform-init.bin of=/dev/mmcblk0boot0 bs=1024 seek=33

Now that we have this U-boot version in place, we can configure it to boot from the NVMe drive

# reform-boot-config nvme

This creates the file /reform-boot-medium with the word nvme in it. This is important because it’s used by reform-init.

Note: One important thing to mention is that reform-init will only try to unlock and mount the encrypted partition under /dev/nvme0n1p1. With a different setup, one needs to go and modify this script to the right path. I stumbled across this problem on my first attempt but it was quite simple to debug and to help me understand better what’s going on under the hood.

If everything went well you should be able to reboot the device and it will boot from the NVMe drive successfully. To finalize this process

  1. Shutdown the system and unplug it
  2. Put the batteries back in place (be careful with the polarity)
  3. Place the acrylic bottom

3 responses to “Running MNT Reform OS on an NVME Disk”

  1. Brother, you just saved me hours. I took what you had and cleaned it up. Removed duplication, removed calls to MNT’s scripts (omg those are horrible), fixed up some stuff, so now:

    1. I have a document that explains each and every command you used and why you used it.
    2. Shows every command exactly as a script would have it. No sdNX no /dev/mmcblkDEVNUMPARNUM gymnastics.
    3. Discusses making rsync quicker. 8.5min to an USB SSD shouldn’t need to copy /dev and /proc. If we can mount directly from it instead of chroot to it, the kernel will build it at boot.

    4. The document includes a script that takes… the same document, and creates a script you can run.
    5. The script asks two things:
    – What is the target device? (like /dev/sda1, /dev/nvme0n1p0, etc.)
    – What is the encryption passphrase?
    It then puts a new GPT, Luks partition, PV, GV, LVs for root and swap,
    mounts root, and rsyncs.

    You saved me hours of research, although I now know the secret is figure out what MNT’s scripts WISH THEY WERE DOING and do that instead of calling those scripts.

    Next up (tomorrow) I’ve got reform-config* and reform-init* to do. That code is horrible, and it’s wrong. For example reform-init tries accessing a media file that nobody created ever. It can’t boot from a USB drive. Biblio kudos Mtnmn addressed this here.

    The point: I’m halfway through automating the whole process WHILE explaining each command in terms of WHAT we’re doing and WHY and WHY here. The building blocks are provided and explained. Couldn’t have done it without your help.

    If you have Patreon, once I’m done, everyone whose contributed will get a mention and a contribution. Also I may desolder the DIP and move it to outside the case (preferred) or bottom of the plexi. RIght now my biggest beef is the USB ports are upside down.

    Thanks for the help. Holler if you’d like a copy. I’m here to share.

    Ehud Gavron
    Tucson, Arizona, US

    1. Hi Ehud, sorry for the very late reply. I’m glad I was able to help 🙂 and yes please, share the results, I haven’t had much time to work on my reform, but I’m planning to get back to it soon

  2. […] making any changes and just assembled the system as instructed. The change I had in my mind was to toggle the switch on the CPU module in order to change the boot sequence so that it would be possible to boot from the storage onboard the CPU module (eMMC) as the primary […]

Leave a Reply to Mauro Cancel reply

Your email address will not be published. Required fields are marked *