Will an update overwrite this systemd script modification?

In my continued efforts to configure my RPi4, I noticed:
/usr/lib/systemd/scripts/zswap-arm-ctrl

I was looking to add a zram for /var/log. The script loads the zram module, creates and mounts a swap on zram and will “undo” this, allowing for interactive control of the swapfile. All well and good. But it hard codes the zram device to be used and will unload the zram module, when it really does not need to. So, I modified the script.

Will this script be over-written on update? If so, I’ll set it immutable but I don’t like doing that unless it is required.

Below is my modified script if anyone else is interested. Also note I modified the ZRAM_SIZE_PERCENT to be a smaller amount and changed the compression algorithm to be zstd. Modify those as desired.

#!/bin/bash
ZRAM_LABEL="ZSWAP"

start() {
  ZRAM_SIZE_PERCENT=20

  (( MEM_TOTAL=`cat /proc/meminfo|grep MemTotal|awk '{print $2}'` * 1024 ))
  (( ZRAM_SIZE=MEM_TOTAL * $ZRAM_SIZE_PERCENT / 100 ))

  ZRAM=`zramctl -f -a "zstd" -s $ZRAM_SIZE`

  if [ -n "$ZRAM" ]; then
    mkswap $ZRAM -L $ZRAM_LABEL
    swapon -p 100 -L $ZRAM_LABEL
  fi
}

stop() {
  ZRAM=`blkid --label $ZRAM_LABEL`

  if [ -n "$ZRAM" ]; then
    swapoff -L $ZRAM_LABEL
    zramctl -r $ZRAM
  fi
}

case $1 in
  start|stop) "$1" ;;
esac

You will also want to create /etc/modprobe.d/zram.conf to direct the number of zram devices to create. I use the following:

options zram num_devices=4

Then modify /etc/mkinitcpio.conf to load the zram module on boot.

MODULES=(zram)
BINARIES=("/usr/bin/zramctl")

I then use udev rules to make my zram drive for /var/log by creating /etc/udev/rules.d/05-zram.rules:

KERNEL=="zram0", ATTR{comp_algorithm}="zstd" ATTR{disksize}="512M" RUN="/usr/bin/mkfs.ext2 -L VAR_LOG_MNJRO /dev/zram0", TAG+="systemd"

And I add it to /etc/fstab:

/dev/zram0					/var/log	ext2	x-systemd.automount,nodev,nosuid		0	0

And if you want journald to log to /var/log/journal rather than /run/log/journal/, you need to modify /etc/systemd/journald.conf:

#Storage=auto
Storage=persisent

And then finally, rebuild the initramfs:

cd /boot
mkinitcpio -P

It will get overwritten next time zswap-arm package gets updated (which it does not do that often though).

The zram script we use is just a good default we use on all our devices. You are free to uninstall it and setup zram/zswap on our own if you wish.

Ah, I figured it was part of a base set of required packages for low memory arm devices and would be reinstalled if uninstalled. But this comes from experiences with other distros. Is there such a thing in Manjaro (profiles, templates, base packages, etc.)? Where some packages are required, and can not be uninstalled, or if so, they will be reinstalled at update?

In Manjaro we set a package list in our profile. But they are not hardcoded into the system.

Regular dependency chain still apply though, so if another package requires it, you won’t be able to uninstall it without uninstalling or breaking the other package. But I don’t think we have put anything to actually depend on the zswap-arm package.

I decided to remove the zswap-arm package and add a udev rule. This keeps the zram config in a single location and puts swap control back into fstab. A simple enough setup for my needs.