Help understanding the disk partitioning post RPi4 Mender image install

Running sudo fdisk /dev/mmcblk0 then p I’m able to see that I have four partitions created as follows;

Device         Boot    Start      End  Sectors  Size Id Type
/dev/mmcblk0p1 *       24576   548863   524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2        548864  7847935  7299072  3.5G 83 Linux
/dev/mmcblk0p3       7847936 15147007  7299072  3.5G 83 Linux
/dev/mmcblk0p4      15147008 62333951 47186944 22.5G 83 Linux

Running mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p'
tells me that the root partition is /dev/mmcblk0p2

I want to be able to access the 22.5G of memory from where mender and my application run by deleting the right partitions and expanding them into one.

I’ve seen ample solutions posted covering the process of how to do this using fdisk. Most of them only have two or 3 partitions. I’ve tried deleting partitions /dev/mmcblk0p2, /dev/mmcblk0p3 and /dev/mmcblk0p4 as well as just /dev/mmcblk0p3 and /dev/mmcblk0p4 then adding them back as a new partition. However each time when I reboot the RPi times out when I try to SSH back into it. I then reformat my disk and reflash the backup image I made before attempting this.

Hi @bradw,

Partition 2 is your active root filesystem. Partition 3 is your passive root filesystem. Partition 4 is the persistent data partition.

If your goal is to change the sizes of the partitions then you should do that in your mender-convert configuration. Using variables such as MENDER_STORAGE_TOTAL_SIZE_MB, MENDER_BOOT_PART_SIZE_MB and MENDER_DATA_PART_SIZE_MB should allow you to customize the partition sizes to whatever you like.

I’m not quite sure what you are trying to accomplish by deleting the partitions so if it something other than setting the sizes properly, if you can describe your needs, I’ll do what I can to get you a solution.

Drew

When I ran npm install from my ArtifactCommit_Leave script npm returned errors INSUFFICIENT MEMORY. But I have a 32 GB SD card so I know the card is not full. It’s just that I have 22.5GB of memory that is in a different partition from where npm, and my Node program, is running. Everything is in my hpm/pi directory. I just didn’t understand which partition above that is or how to properly merge it with the 22.5GB partition.

Presumably the default for npm is to install in the root filesystem. But with Mender you have a reduced size there and the bulk of the storage is in /data. You have two choices:

  1. Increase the size of the root filesystem. You can do this by setting the variables mentioned above. MENDER_STORAGE_TOTAL_SIZE_MB represents the total combined sizes of the boot partition, two root filesystem partitions and the data partition. You can explicitly specify the sizes of the boot and data partitions and Mender will calculate the size of the root filesystem partitions from that. The downside of doing it this way is that everytime you do a full robust image update you will lose any changes that have been made as the entire root filesystem is replaced.

  2. Configure npm to use the /data partition to store its files. I don’t know how to do this but I would be surprised if it were not possible.

Drew

I searched for a way to update the npm configuration but there doesn’t appear to be one relating to the specific partition npm uses.

As I worked through converting a Mender Debian image when I reached this step and ran the bootstrap-rootfs-overlay-hosted-server.sh script on my Mac Terminal I received the following error after entering my password; chown: 503.20: illegal user name

I’m not sure what it means because it never asked for a user name.

Hi @bradw it looks like the version of chown that comes with MacOS doesn’t understand the 503.20 syntax for user and group specification. I created a proposed PR that changes to a more generic syntax. Can you test it and let us know if it fixes your build issue?

Drew

As for the npm storage location, I think this link may do what you need.
Drew

I cloned and changed directory into the cloned PR and reran the hosted Mender bootstrap-rootfs-overlay-hosted-server command. The error changed from chown: 503.20: illegal user name to chgrp: root: illegal group name

Before I have you spend too much time on this let me make sure I understand what you meant here;

Does that mean if I copy the image to a new SD card and update my Node application via Mender deployment it won’t keep the MENDER_TOTAL_STORAGE_SIZE_MB setting?

This seems to only deal with the directory npm places your Node modules in. I don’t think that helps in this situation, right? I’m likely running out of memory in terms of the 3.5GB disk partition if i’m not mistaken.

It turns out my PR was not quite complete to get that script to run on MacOS. I added another one here.

Change the directory where the NPM files are installed will move them to a different partition if the directory you specify is on a separate partition. The standard Mender layout is to mount the persistent partition at /data. This is usually the bulk of the storage and is used to store files that you want to persist across image updates. If you do something like:

 mkdir /data/npm-global
 npm config set prefix /data/npm-global

Then all your npm installed files will be in the /data partition. This also means that they will persist across robust image updates which may or may not be what you want.

The MENDER_STORAGE_TOTAL_SIZE_MB setting will be respected when doing robust image updates. It’s just that the entire root filesystem partition will be replaced so any files you have added in there since it was originally installed will not be part of the new partition contents.

Drew

That commit got the bootstrap-rootfs-overlay-hosted-server.sh script to run successfully.

Presuming Node has no issues with loading modules for my program, which is running in the root partition, from the /data partition the npm configuration you linked to may be the solution I’m looking for. Then I could run my ArtifactCommit_Leave script which updates my package.json file and calls npm install and npm would install updated packages in the /data partition node_modules directory.

I was able to get my node modules installed in the /data directory using a ArtifactCommit_Leave script using the following bash script that creates a symlink inside my-project to the node_modules directory in /data, without making them global;

    #!/bin/bash
    set -euo pipefail
    cd '../../../../home/pi/my-project'
    if ! cmp -s 'package.json' '~/../../data/package.json'; then
        cp -f 'package.json' '../../../data'
        cd '../../../data'
        pnpm install -r
    fi
    ln -s 'node_modules/' '../home/pi/my-project'
    exit 0