package/mender: remove /var/lib/mender symlinking

The logic behind making /var/lib/mender a symlink to itself is to
detect if a filesystem is read-only. However, this creates a few problems:

  1) The logic confusing.

  2) The official mender documentation suggests four partitions minimum:
     - boot
     - rootfs A
     - rootfs B
     - data

     If a user is to follow the official documentation, which they should,
     then there is no need for any additional logic for a system setup with
     a read-only filesystem, as the data partition is always read-write.

  3) The post-build.sh script in the board/mender/x86_64 directory removes
     the symlink.

  - Remove symlinking /var/lib/mender to itself

  - Remove the difficult to understand logic dealing with the symlinks
    in S42mender, mender-client.service.

  - Remove the logic dealing with the symlink in
    board/mender/x86_64/post-build.sh

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
This commit is contained in:
Adam Duskett
2024-10-14 12:21:19 +02:00
committed by Arnout Vandecappelle
parent b2e6cff38f
commit 9320989053
4 changed files with 1 additions and 34 deletions

View File

@@ -31,11 +31,6 @@ parse_args() {
# Create a persistent directory to mount the data partition at.
mender_fixup() {
pushd "${TARGET_DIR}"
if [[ -L var/lib/mender ]]; then
rm var/lib/mender
mkdir -p var/lib/mender
fi
# The common paradigm is to have the persistent data volume at /data for mender.
if [[ ! -L data ]]; then
ln -s var/lib/mender data

View File

@@ -8,22 +8,6 @@ PIDFILE="/var/run/${DAEMON}.pid"
DAEMON_ARGS="daemon"
start() {
# If /var/lib/mender is a symlink to /var/run/mender, and
# - the filesystem is RO (i.e. we can not rm the symlink),
# create the directory pointed to by the symlink.
# - the filesystem is RW (i.e. we can rm the symlink),
# replace the symlink with an actual directory
if [ -L /var/lib/mender ] && [ "$(readlink /var/lib/mender)" = "/var/run/mender" ]
then
if rm -f /var/lib/mender >/dev/null 2>&1; then
mkdir -p /var/lib/mender
else
echo "No persistent location to store mender data. Data will be lost"
echo "at reboot. Are you sure this is what you want to do?"
mkdir -p "$(readlink /var/lib/mender)"
fi
fi
printf "Starting mender service: "
umask 077
start-stop-daemon -bmSqp "$PIDFILE" -x ${DAEMON_PATH} -- ${DAEMON_ARGS}

View File

@@ -6,17 +6,6 @@ After=systemd-resolved.service
Type=idle
User=root
Group=root
ExecStartPre=/bin/sh -c '\
if [ -L /var/lib/mender \
-a "$(readlink /var/lib/mender)" = "/var/run/mender" ]; then \
if rm -f /var/lib/mender >/dev/null 2>&1; then \
mkdir -p /var/lib/mender; \
else \
echo "No persistent location to store mender data. Data will be lost" \
echo "at reboot. Are you sure this is what you want to do?"; \
mkdir -p "$(readlink /var/lib/mender)"; \
fi; \
fi'
ExecStart=/usr/bin/mender daemon
Restart=on-abort

View File

@@ -72,8 +72,7 @@ define MENDER_INSTALL_CONFIG_FILES
$(INSTALL) -D -m 0755 $(MENDER_PKGDIR)/device_type \
$(TARGET_DIR)/etc/mender/device_type
mkdir -p $(TARGET_DIR)/var/lib
ln -snf /var/run/mender $(TARGET_DIR)/var/lib/mender
mkdir -p $(TARGET_DIR)/var/lib/mender
$(foreach f,$(MENDER_UPDATE_MODULES_FILES), \
$(INSTALL) -D -m 0755 $(@D)/support/modules/$(notdir $(f)) \
$(TARGET_DIR)/usr/share/mender/modules/v3/$(notdir $(f))