From bea3bdbb62a3ce8386f4b175003352304e66c600 Mon Sep 17 00:00:00 2001 From: alejandrogs73 Date: Mon, 28 Sep 2026 16:25:39 +0200 Subject: [PATCH] zram: swap comprimida en RAM por delante de la del disco MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit zramen con zstd, hasta la mitad de la RAM (máximo 8 GB) y la prioridad más alta; la swap del NVMe queda de reserva. swappiness 180 y page-cluster 0, lo normal con zram. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01C5v1qWDwgkaVM5kjVHGGh8 --- README-en.md | 19 +++++++++++-------- README.md | 17 ++++++++++------- install.sh | 4 ++-- sistema/etc/sv/zramen/conf | 7 +++++++ sistema/etc/sysctl.d/99-zram.conf | 5 +++++ 5 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 sistema/etc/sv/zramen/conf create mode 100644 sistema/etc/sysctl.d/99-zram.conf diff --git a/README-en.md b/README-en.md index d5ee71d..8d228a4 100644 --- a/README-en.md +++ b/README-en.md @@ -55,14 +55,14 @@ for example) and repeated safely: 6. `sistema` (system): copies `sistema/` into `/`, sets up `wpa_supplicant.conf` so wheel users can use `wpa_cli` without root and save networks, enables the runit services (dbus, turnstiled, - wpa_supplicant, dhcpcd, bluetoothd, acpid, openntpd, tlp, automontaje, - cupsd), removes NetworkManager, elogind, chronyd, avahi-daemon (the printer - has a fixed IP), sshd (nobody SSHes into the laptop), nix-daemon and - polkitd (if something asks for polkit, like libvirt, D-Bus starts it on its - own) and adds the user to the audio, video, input, network, bluetooth, - lpadmin (printer management) and `_pipewire` (realtime priority for audio - without rtkit) groups. `doas.conf` is checked with `doas -C` before it is - installed with mode 400. + wpa_supplicant, dhcpcd, bluetoothd, acpid, openntpd, tlp, zramen, + automontaje, cupsd), removes NetworkManager, elogind, chronyd, avahi-daemon + (the printer has a fixed IP), sshd (nobody SSHes into the laptop), + nix-daemon and polkitd (if something asks for polkit, like libvirt, D-Bus + starts it on its own) and adds the user to the audio, video, input, + network, bluetooth, lpadmin (printer management) and `_pipewire` (realtime + priority for audio without rtkit) groups. `doas.conf` is checked with `doas + -C` before it is installed with mode 400. 7. `quitar` (remove): uninstalls what the repo no longer uses because something else replaces it: sudo (doas), feh (xwallpaper and nsxiv), gammastep (sct), autorandr (`pantallas`), blueman and pavucontrol (the @@ -190,6 +190,9 @@ preserveonrestart patches). (the laptop one on the left and as primary) at startup and whenever one is plugged or unplugged (udev rule in `sistema/`), then repaints the wallpaper with `xwallpaper`. +- Memory: compressed swap in RAM with zram (`zramen` service, up to half the + RAM, with zstd) ahead of the disk swap, which stays as a fallback + (`sistema/etc/sv/zramen/conf` and `sistema/etc/sysctl.d/99-zram.conf`). - Audio: `.xinitrc` runs pipewire, wireplumber and pipewire-pulse in a loop, so if one of them dies it comes back a second later (without wireplumber everything goes to "Dummy Output"). diff --git a/README.md b/README.md index fbe107a..09cca61 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ Hace siete pasos, que también se pueden lanzar por separado 6. `sistema`: copia `sistema/` en `/`, prepara `wpa_supplicant.conf` para que los de wheel usen `wpa_cli` sin root y guarden redes, activa los servicios de runit (dbus, turnstiled, wpa_supplicant, dhcpcd, bluetoothd, acpid, - openntpd, tlp, automontaje, cupsd), quita NetworkManager, elogind, chronyd, - avahi-daemon (la impresora va por IP fija), sshd (al portátil no se entra - por SSH), nix-daemon y polkitd (si algo pide polkit, como libvirt, D-Bus lo - arranca solo) y añade el usuario a los grupos audio, video, input, network, - bluetooth, lpadmin (para gestionar impresoras) y `_pipewire` (prioridad de - tiempo real para el audio sin rtkit). `doas.conf` se valida con `doas -C` - antes de instalarlo con modo 400. + openntpd, tlp, zramen, automontaje, cupsd), quita NetworkManager, elogind, + chronyd, avahi-daemon (la impresora va por IP fija), sshd (al portátil no + se entra por SSH), nix-daemon y polkitd (si algo pide polkit, como libvirt, + D-Bus lo arranca solo) y añade el usuario a los grupos audio, video, input, + network, bluetooth, lpadmin (para gestionar impresoras) y `_pipewire` + (prioridad de tiempo real para el audio sin rtkit). `doas.conf` se valida + con `doas -C` antes de instalarlo con modo 400. 7. `quitar`: desinstala lo que el repo ya no usa porque lo sustituye otra cosa: sudo (doas), feh (xwallpaper y nsxiv), gammastep (sct), autorandr (`pantallas`), blueman y pavucontrol (scripts `bluetooth` y `volumen`), @@ -188,6 +188,9 @@ ventanas (parches restartsig y preserveonrestart). `xrandr` (la del portátil a la izquierda y como principal) al arrancar y cada vez que se conecta o desconecta una (regla de udev en `sistema/`), y vuelve a pintar el fondo con `xwallpaper`. +- Memoria: swap comprimida en RAM con zram (servicio `zramen`, hasta la mitad + de la RAM, con zstd) por delante de la del disco, que queda de reserva + (`sistema/etc/sv/zramen/conf` y `sistema/etc/sysctl.d/99-zram.conf`). - Audio: `.xinitrc` lanza pipewire, wireplumber y pipewire-pulse en un bucle, así que si alguno se cae vuelve solo al segundo (sin wireplumber todo sale por "Dummy Output"). diff --git a/install.sh b/install.sh index ef84338..4c1704c 100755 --- a/install.sh +++ b/install.sh @@ -20,7 +20,7 @@ PAQUETES=" xorg xinit setxkbmap xrandr dbus turnstile picom dunst libnotify xwallpaper nsxiv maim xclip sct xssstate pipewire wireplumber libspa-bluetooth alsa-pipewire - wpa_supplicant dhcpcd bluez acpid openntpd tlp + wpa_supplicant dhcpcd bluez acpid openntpd tlp zramen cups cups-filters hplip font-firacode nerd-fonts-symbols-ttf papirus-icon-theme papirus-folders sassc gnome-themes-extra qt5ct @@ -34,7 +34,7 @@ SUCKLESS="dwm st dmenu slstatus slock scroll clipmenu" # Tema GTK Everforest, en una versión fija para que siempre salga igual GTK_TEMA_REPO=https://github.com/Fausto-Korpsvart/Everforest-GTK-Theme GTK_TEMA_COMMIT=9b8be4d6648ae9eaae3dd550105081f8c9054825 -SERVICIOS="dbus turnstiled wpa_supplicant dhcpcd bluetoothd acpid openntpd tlp automontaje cupsd" +SERVICIOS="dbus turnstiled wpa_supplicant dhcpcd bluetoothd acpid openntpd tlp zramen automontaje cupsd" # La red la llevan wpa_supplicant y dhcpcd. polkitd no hace falta como # servicio: si algo lo pide (libvirt), D-Bus lo arranca. turnstiled sustituye # a elogind y openntpd a chronyd. avahi-daemon (mDNS) no hace falta: la diff --git a/sistema/etc/sv/zramen/conf b/sistema/etc/sv/zramen/conf new file mode 100644 index 0000000..2e2e170 --- /dev/null +++ b/sistema/etc/sv/zramen/conf @@ -0,0 +1,7 @@ +# Swap comprimida en RAM (zram), antes que la del disco. Con 11 GB de RAM se +# llega a usar la swap del NVMe; en zram cabe más y va mucho más rápido. +# Hasta la mitad de la RAM (máximo 8 GB) y zstd, que comprime más que lz4. La +# prioridad por defecto (32767) la pone por delante de la swap del disco. +export ZRAM_COMP_ALGORITHM=zstd +export ZRAM_SIZE=50 +export ZRAM_MAX_SIZE=8192 diff --git a/sistema/etc/sysctl.d/99-zram.conf b/sistema/etc/sysctl.d/99-zram.conf new file mode 100644 index 0000000..9f3824f --- /dev/null +++ b/sistema/etc/sysctl.d/99-zram.conf @@ -0,0 +1,5 @@ +# Con zram (sistema/etc/sv/zramen) sale más a cuenta mandar páginas a la swap +# comprimida que soltar la caché de disco, y no hace falta leerlas de 8 en 8 +# como en un disco. +vm.swappiness = 180 +vm.page-cluster = 0