Skip to content

About overlays in the MPC filesystem

TheKikGen edited this page Jan 26, 2023 · 11 revisions
    __ __| |           |  /_) |     ___|             |           |
       |   __ \   _ \  ' /  | |  / |      _ \ __ \   |      _` | __ \   __|
       |   | | |  __/  . \  |   <  |   |  __/ |   |  |     (   | |   |\__ \
      _|  _| |_|\___| _|\_\_|_|\_\\____|\___|_|  _| _____|\__,_|_.__/ ____/

About overlays in the MPC filesystem

in Linux filesystem, an overlay filesystem combines two directories :

  • an ‘upper’ filesystem
  • a ‘lower’ filesystem.

When a name exists in both, the object in the ‘upper’ filesystem is visible while the object in the ‘lower’ is either hidden or, in the case of directories, merged with the ‘upper’ object.

Then whenever a lookup is requested in such a merged directory, the lookup is performed in each actual directory and the combined result is cached in the dentry belonging to the overlay filesystem. If both actual lookups find directories, both are stored and a merged directory is created, otherwise only one is stored: the upper if it exists, else the lower.

still with me ?

The Akai update process replaces entirely the rootfs partition on the internal ssd : i.e., each time you update your MPC, the entire root filesystem is rewritten with the new one. Overlaying with the "az01-internal" rw partition on the internal disk avoids the user to lost all their system settings, like WIFI configuration, bluetooth peripheral, and for sure, ssh, while allowing updates in /etc /var global.

Logged in the MPC within a SSH session, if we look at mounted volumes with a mount command, we get :

(...)
overlay on /etc type overlay (rw,relatime,lowerdir=/etc,upperdir=/media/az01-internal/system/etc/overlay,workdir=/media/az01-internal/system/etc/.work)
overlay on /var type overlay (rw,relatime,lowerdir=/var,upperdir=/media/az01-internal/system/var/overlay,workdir=/media/az01-internal/system/var/.work)
(...)

(az01-internal is the data partition on the internal emmc disk. sd-card is mounted to /media/az01-internal-sd)

So we have

  • /var = /media/az01-internal/system/var/overlay (upper - from sdcard ) + /var (lower - from ssd)
  • /etc = /media/az01-internal/system/etc/overlay (upper - from sdcard ) + /etc (lower - from ssd)

The “workdir” .work is an empty hidden directory on the same filesystem as upperdir caching the dentry belonging to the overlay filesystem.

Have a closer look on the az01-internal disk partition :

cd /media/az01-internal/system
# /media/tkgl/mpcroot/bin/tree
.
|-- etc
|   `-- overlay
|       |-- dbus-1
|       |-- group
|       |-- group-
|       |-- hostname
|       |-- localtime -> ../usr/share/zoneinfo/Europe/Paris
|       |-- machine-id
|       |-- machine-info
|       |-- mtab -> ../proc/self/mounts
|       |-- passwd
|       |-- passwd-
|       |-- resolv.conf -> /run/connman/resolv.conf
|       |-- shadow
|       |-- shadow-
|       |-- ssh
|       |   |-- ssh_host_dsa_key
|       |   |-- ssh_host_dsa_key.pub
|       |   |-- ssh_host_ecdsa_key
|       |   |-- ssh_host_ecdsa_key.pub
|       |   |-- ssh_host_ed25519_key
|       |   |-- ssh_host_ed25519_key.pub
|       |   |-- ssh_host_rsa_key
|       |   |-- ssh_host_rsa_key.pub
|       |   `-- sshd_config
|       `-- systemd
|           `-- system
|               `-- multi-user.target.wants
|                   `-- sshd.service -> /usr/lib/systemd/system/sshd.service
`-- var
    `-- overlay
        |-- cache
        |   `-- private
        |-- lib
        |   |-- bluetooth
        |   |   `-- 43:39:00:00:1F:AC
        |   |       |-- 11:22:33:43:76:57
        |   |       |   `-- info
        |   |       |-- cache
        |   |       |   |-- 11:22:33:43:76:57
        |   |       |   |-- 58:51:00:53:3C:77
        |   |       |   |-- 74:DF:BF:A8:D4:76
        |   |       |   |-- 74:E1:B6:19:BB:02
        |   |       |   |-- A4:45:19:14:49:AB
        |   |       |   |-- C0:18:85:B6:DC:0F
        |   |       |   |-- D0:05:2A:AF:0F:6E
        |   |       |   |-- E4:22:A5:F0:CA:3E
        |   |       |   `-- E4:A9:B6:19:1A:C3
        |   |       `-- settings
        |   |-- connman
        |   |   |-- settings
        |   |   `-- wifi_b0f1ecabe817_546f72676e65742d776972656c657373_managed_psk
        |   |       |-- data
        |   |       `-- settings
        |   |-- inMusic
        |   |   `-- 9E0C3419-93E1-4E92-B8E3-79141B049228
        |   |       `-- DCS_UserDefinedDeviceName.var
        |   |-- machines
        |   |-- portables
        |   |-- private
        |   |-- systemd
        |   |   |-- backlight
        |   |   |   `-- platform-mipi-backlight:backlight:mipi-backlight
        |   |   |-- catalog
        |   |   |   `-- database
        |   |   |-- coredump
        |   |   |-- random-seed
        |   |   `-- rfkill
        |   |       |-- platform-ff0d0000.dwmmc:wlan
        |   |       `-- platform-ff180000.serial:bluetooth
        |   `-- udisks
        |       |-- mtab
        |       |-- mtab.H34IR0
        |       `-- mtab.ZVW2R0
        |-- lock -> ../run/lock
        |-- log
        |   |-- btmp
        |   |-- journal
        |   |-- lastlog
        |   |-- private
        |   `-- wtmp
        |-- spool
        `-- tmp
            |-- com.akaipro.mpc.vcs-version
            |-- com.akaipro.mpc.version
            |-- juceAppLock_
            |-- juceAppLock_MPC
            |-- splicesync
            `-- splicesync-log

If we consider ssh for example, when sshd_config is missing on the az01-internal partition (i suppose being the "factory" default), the sshd_config from the rootfs is selected, so no ssh access enabled. If a sshd_confid exists on the az01-internal partition, it will be the one used by the sshd server, whatever the rootfs /etc/ssh conf is.

So to active ssh, you need to either modify the sshd_config on the az01-internal partition if it exists (impossible without ssh ha ha ha ha...), Either delete the file on the az01-internal partition, and modify the file of the updated image. This is what is done on modified images. This approach is working for any other service managed from the /etc directory.

To activate ssh permanently :

  • The overlay on /etc must be stopped : unmount /etc, because sshd daemon is pre-started by the system before the overlay it-self.
  • The ro filesystem has to be rw : `mount -o rw,remount /
  • To enable the sshd service at boot time a link is created in the multi-user.target.wants : ln -s mpcmnt/usr/lib/systemd/system/sshd.service mpcmnt/etc/systemd/system/multi-user.target.wants/sshd.service

The sshd_config is in the /etc/ssh directory.