# Help understanding the disk partitioning post RPi4 Mender image install

**URL:** <https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871>\
**Category:** General Discussions\
**Created:** [November 20, 2020, 5:54pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871 "2020-11-20T17:54:48Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradw](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bradw/32/933_2.png) [@bradw](https://hub.mender.io/u/bradw)\
**Post date:** [November 20, 2020, 5:54pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/1 "2020-11-20T17:54:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 23, 2020, 7:49pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/2 "2020-11-23T19:49:11Z")

</div>

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](https://docs.mender.io/system-updates-debian-family/variables#mender_storage_total_size_mb), [MENDER\_BOOT\_PART\_SIZE\_MB](https://docs.mender.io/system-updates-debian-family/variables#mender_boot_part_size_mb) and [MENDER\_DATA\_PART\_SIZE\_MB](https://docs.mender.io/system-updates-debian-family/variables#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

---

<div class="post-metadata">

**Author:** ![bradw](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bradw/32/933_2.png) [@bradw](https://hub.mender.io/u/bradw)\
**Post date:** [November 25, 2020, 1:12am UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/3 "2020-11-25T01:12:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 25, 2020, 2:30pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/4 "2020-11-25T14:30:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bradw](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bradw/32/933_2.png) [@bradw](https://hub.mender.io/u/bradw)\
**Post date:** [November 30, 2020, 1:38am UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/6 "2020-11-30T01:38:45Z")

</div>

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](https://docs.mender.io/system-updates-debian-family/convert-a-mender-debian-image#configure-the-mender-client-server-configuration) 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.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 30, 2020, 5:44pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/7 "2020-11-30T17:44:20Z")

</div>

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](https://github.com/mendersoftware/mender-convert/pull/264) that changes to a more generic syntax. Can you test it and let us know if it fixes your build issue?

Drew

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [November 30, 2020, 5:45pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/8 "2020-11-30T17:45:48Z")

</div>

As for the npm storage location, I think [this link may](https://github.com/mixonic/docs.npmjs.com/blob/master/content/getting-started/fixing-npm-permissions.md#option-2-change-npms-default-directory-to-another-directory) do what you need.  
Drew

---

<div class="post-metadata">

**Author:** ![bradw](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bradw/32/933_2.png) [@bradw](https://hub.mender.io/u/bradw)\
**Post date:** [November 30, 2020, 9:55pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/9 "2020-11-30T21:55:09Z")

</div>

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;

> [@drewmoseley](#):
>
> everytime you do a full robust image update you will lose any changes that have been made

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?

---

<div class="post-metadata">

**Author:** ![bradw](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bradw/32/933_2.png) [@bradw](https://hub.mender.io/u/bradw)\
**Post date:** [November 30, 2020, 9:59pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/10 "2020-11-30T21:59:01Z")

</div>

> [@drewmoseley](#):
>
> As for the npm storage location, I think [this link may](https://github.com/mixonic/docs.npmjs.com/blob/master/content/getting-started/fixing-npm-permissions.md#option-2-change-npms-default-directory-to-another-directory) do what you need.

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.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [December 1, 2020, 4:30pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/11 "2020-12-01T16:30:09Z")

</div>

It turns out my PR was not quite complete to get that script to run on MacOS. I added another [one here](https://github.com/mendersoftware/mender-convert/pull/266).

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:

```auto
 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

---

<div class="post-metadata">

**Author:** ![bradw](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bradw/32/933_2.png) [@bradw](https://hub.mender.io/u/bradw)\
**Post date:** [December 1, 2020, 4:44pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/12 "2020-12-01T16:44:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bradw](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bradw/32/933_2.png) [@bradw](https://hub.mender.io/u/bradw)\
**Post date:** [December 5, 2020, 7:19pm UTC](https://hub.mender.io/t/help-understanding-the-disk-partitioning-post-rpi4-mender-image-install/2871/13 "2020-12-05T19:19:08Z")

</div>

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;

```bash
    #!/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

```
