Automate safe system upodates with a single script (for APT + systemd systems)

THE PROBLEM Keeping a Linux system fully updated usually means doing several things by hand: Update APT package lists Upgrade installed packages Remove unused dependencies and cached files Update Flatpak apps (if you use Flatpak) Update firmware via fwupd (if available) Decide whether to reboot or shut down None of that is hard, but it is repetitive and easy to skip steps, especially firmware updates. This script turns that whole workflow into a single, safe command. REQUIREMENTS This script assumes: Package manager Uses APT Example: Debian, Ubuntu, Linux Mint and similar Init system Uses systemd (for systemctl reboot/poweroff) Shell bash (script uses “#!/usr/bin/env bash” and “set -euo pipefail”) You can run it with: bash script.sh Privileges Your user has sudo rights Optional components Flatpak (optional) If not installed, Flatpak steps are skipped fwupd (fwupdmgr, optional) If not installed, firmware steps a...

Accessing partitions by label

When I run something like:

sudo e2label /dev/sda2 LCS_RAW

I’m just giving the filesystem a name tag: LCS_RAW.
After that, Linux (via udev) automatically creates a shortcut:

/dev/disk/by-label/LCS_RAW -> ../../sda2

I didn’t create that path myself. Linux did. It’s a symlink that always points to the right partition, even if the kernel decides the device is /dev/sdb2 tomorrow instead of /dev/sda2.

The nice part: I can use this label path anywhere I would use the raw device:

# Mount by label (more stable than /dev/sdX) sudo mount /dev/disk/by-label/LCS_RAW /mnt/LCS

This works the same as mount /dev/sda2, but doesn’t break when device numbers change.

Important detail:
/dev/disk/by-label/LCS_RAW is not a directory, it’s a device file. I don’t cd into it. I mount it, then access the filesystem via the mountpoint:

sudo mount /dev/disk/by-label/LCS_RAW /mnt/LCS cd /mnt/LCS



Short version:
  1. Label the partition → e2label /dev/sdXn NAME.
  2. Linux auto-creates /dev/disk/by-label/NAME.
  3. Use that path for mounting and scripts instead of /dev/sdXn for a more robust setup.

Comments