maximumadmin / zramd Goto Github PK
View Code? Open in Web Editor NEWAutomatically setup swap on zram ✨ with optional systemd support, a simpler alternative to zram-generator and systemd-swap
License: MIT License
Automatically setup swap on zram ✨ with optional systemd support, a simpler alternative to zram-generator and systemd-swap
License: MIT License
By default, zramd
will allocate a maximum of eight gigabytes for swap. On systems such as the RPI, this is significantly higher than the actual amount of memory installed by the manufacturer. Do you recommend adjusting this parameter to cater to low memory systems, or does the default configuration simply work as well?
I am attempting to use zramd on Artix Linux with dinit as the unit system and I cannot start zramd. I get error: failed to execute "modprobe zram num_devices=1"
Does zramd need a program to start before it to work?
Please give an easy way to control the zstd compression level.
It is tunable with compression levels ranging from negative 7 (fastest) to 22 (slowest in compression speed, but best compression ratio).
Compression speed can vary by a factor of 20 or more between the fastest and slowest levels, while decompression is uniformly fast, varying by less than 20% between the fastest and slowest levels.
Ref: https://en.wikipedia.org/wiki/Zstd
System Info:
~ inxi -Fazy ✔
System:
Kernel: 5.15.28-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 11.2.0
parameters: BOOT_IMAGE=/@/boot/vmlinuz-5.15-x86_64
root=UUID=2858d787-58d2-4b32-bfe2-dcd848223859 rw rootflags=subvol=@
cryptdevice=UUID=ec00de08-393b-4d8c-a1ed-853a4de311ee:cryptroot apparmor=1
security=apparmor bootsplash.bootfile=bootsplash-themes/manjaro/bootsplash
Desktop: Xfce v: 4.16.0 tk: Gtk v: 3.24.29 info: xfce4-panel wm: xfwm
v: 4.16.1 vt: 7 dm: LightDM v: 1.30.0 Distro: Manjaro Linux base: Arch Linux
Machine:
Type: Desktop Mobo: ASUSTeK model: PRIME X570-PRO v: Rev X.0x
serial: <superuser required> UEFI: American Megatrends v: 4204
date: 02/24/2022
CPU:
Info: model: AMD Ryzen 9 3900X bits: 64 type: MT MCP arch: Zen 2
family: 0x17 (23) model-id: 0x71 (113) stepping: 0 microcode: 0x8701021
Topology: cpus: 1x cores: 12 tpc: 2 threads: 24 smt: enabled cache:
L1: 768 KiB desc: d-12x32 KiB; i-12x32 KiB L2: 6 MiB desc: 12x512 KiB
L3: 64 MiB desc: 4x16 MiB
Speed (MHz): avg: 3991 high: 4015 min/max: 2200/4918 boost: disabled
scaling: driver: acpi-cpufreq governor: schedutil cores: 1: 3999 2: 3993
3: 3989 4: 3980 5: 3998 6: 3995 7: 3972 8: 3995 9: 4015 10: 3964 11: 4002
12: 4008 13: 3975 14: 3980 15: 4012 16: 4010 17: 3971 18: 3983 19: 4014
20: 3994 21: 3983 22: 3989 23: 3987 24: 3994 bogomips: 191698
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Vulnerabilities:
Type: itlb_multihit status: Not affected
Type: l1tf status: Not affected
Type: mds status: Not affected
Type: meltdown status: Not affected
Type: spec_store_bypass
mitigation: Speculative Store Bypass disabled via prctl and seccomp
Type: spectre_v1
mitigation: usercopy/swapgs barriers and __user pointer sanitization
Type: spectre_v2
mitigation: Retpolines, IBPB: conditional, STIBP: conditional, RSB filling
Type: srbds status: Not affected
Type: tsx_async_abort status: Not affected
Graphics:
Device-1: AMD Navi 10 [Radeon RX 5600 OEM/5600 XT / 5700/5700 XT]
vendor: ASUSTeK driver: amdgpu v: kernel pcie: gen: 4 speed: 16 GT/s
lanes: 16 ports: active: HDMI-A-1 empty: DP-1,DP-2,DP-3 bus-ID: 0b:00.0
chip-ID: 1002:731f class-ID: 0300
Display: x11 server: X.Org v: 1.21.1.3 compositor: xfwm v: 4.16.1 driver:
X: loaded: amdgpu unloaded: modesetting,radeon alternate: fbdev,vesa
gpu: amdgpu display-ID: :0.0 screens: 1
Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.00x11.22")
s-diag: 582mm (22.93")
Monitor-1: HDMI-A-1 mapped: HDMI-A-0 model: Samsung SyncMaster
serial: <filter> built: 2009 res: 1920x1080 hz: 60 dpi: 102 gamma: 1.2
size: 477x268mm (18.78x10.55") diag: 587mm (23.1") ratio: 16:9, 15:9
modes: max: 1920x1080 min: 640x480
Message: Unable to show GL data. Required tool glxinfo missing.
Audio:
Device-1: AMD Navi 10 HDMI Audio driver: snd_hda_intel v: kernel pcie:
gen: 4 speed: 16 GT/s lanes: 16 bus-ID: 0b:00.1 chip-ID: 1002:ab38
class-ID: 0403
Device-2: AMD Starship/Matisse HD Audio vendor: ASUSTeK
driver: snd_hda_intel v: kernel pcie: gen: 4 speed: 16 GT/s lanes: 16
bus-ID: 0d:00.4 chip-ID: 1022:1487 class-ID: 0403
Sound Server-1: ALSA v: k5.15.28-1-MANJARO running: yes
Sound Server-2: JACK v: 1.9.20 running: no
Sound Server-3: PulseAudio v: 15.0 running: yes
Sound Server-4: PipeWire v: 0.3.48 running: yes
Network:
Device-1: Intel I211 Gigabit Network vendor: ASUSTeK driver: igb v: kernel
pcie: gen: 1 speed: 2.5 GT/s lanes: 1 port: f000 bus-ID: 05:00.0
chip-ID: 8086:1539 class-ID: 0200
IF: enp5s0 state: up speed: 1000 Mbps duplex: full mac: <filter>
IF-ID-1: vmnet1 state: unknown speed: N/A duplex: N/A mac: <filter>
IF-ID-2: vmnet8 state: unknown speed: N/A duplex: N/A mac: <filter>
Bluetooth:
Device-1: Cambridge Silicon Radio Bluetooth Dongle (HCI mode) type: USB
driver: btusb v: 0.8 bus-ID: 1-2:2 chip-ID: 0a12:0001 class-ID: e001
Report: rfkill ID: hci0 rfk-id: 0 state: up address: see --recommends
Drives:
Local Storage: total: 1.82 TiB used: 154.94 GiB (8.3%)
SMART Message: Unable to run smartctl. Root privileges required.
ID-1: /dev/nvme0n1 maj-min: 259:1 vendor: Samsung model: SSD 970 EVO 500GB
size: 465.76 GiB block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s
lanes: 4 type: SSD serial: <filter> rev: 2B2QEXE7 temp: 37.9 C scheme: GPT
ID-2: /dev/nvme1n1 maj-min: 259:0 vendor: Samsung model: SSD 970 EVO 500GB
size: 465.76 GiB block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s
lanes: 4 type: SSD serial: <filter> rev: 2B2QEXE7 temp: 24.9 C scheme: GPT
ID-3: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 870 QVO 1TB
size: 931.51 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
type: SSD serial: <filter> rev: 2B6Q scheme: GPT
Partition:
ID-1: / raw-size: 419.26 GiB size: 419.26 GiB (100.00%)
used: 30.22 GiB (7.2%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
mapped: cryptroot
ID-2: /boot/efi raw-size: 512 MiB size: 511 MiB (99.80%)
used: 26.1 MiB (5.1%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:5
ID-3: /home raw-size: 419.26 GiB size: 419.26 GiB (100.00%)
used: 30.22 GiB (7.2%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
mapped: cryptroot
Swap:
Kernel: swappiness: 60 (default) cache-pressure: 100 (default)
ID-1: swap-1 type: zram size: 8 GiB used: 0 KiB (0.0%) priority: 100
dev: /dev/zram0
Sensors:
System Temperatures: cpu: N/A mobo: N/A gpu: amdgpu temp: 37.0 C mem: 34.0 C
Fan Speeds (RPM): N/A gpu: amdgpu fan: 0
Info:
Processes: 472 Uptime: 5m wakeups: 0 Memory: 31.32 GiB used: 3.4 GiB (10.9%)
Init: systemd v: 250 tool: systemctl Compilers: gcc: 11.2.0 clang: 13.0.1
Packages: 1219 pacman: 1210 lib: 340 flatpak: 9 Shell: Zsh v: 5.8.1
running-in: xfce4-terminal inxi: 3.3.15
systemctl status systemd-oomd
Apr 15 17:47:48 BlackBox systemd-oomd[884]: Swap is currently not detected; memory pressure usage will be degraded
Hi, let me start by expressing my gratitude for creating/offering this excellent application. Have been using it without hiccups for a long time. But after my Arch Linux box got the systemd v254 recently, I did notice some peculiarity. Where before this upgrade swapon
consistently reported /dev/zram0, it now shows /zram0 instead.
$ sudo swapon --noheadings --raw --show=name,size,used
/dev/sda2 4,2G 0B
/zram0 1024M 0B
UPDATE:
After doing some more experimenting it turned out we can keep PrivateNetwork
and explicitly disable PrivateMounts
.
Nothing crucial apparently, the zram device is created and still resides under /dev/zram0. But it's confusing and I opted to disable PrivateNetwork
PrivateMounts
to get back to the output one would expect from swapon.
zramd/build/package/zramd.service
Line 11 in a21eb47
$ cat /etc/systemd/system/zramd.service.d/fix-swapon-output.conf
[Service]
# systemd v254 introduced some changes that apparently affected
# swapon output - bring back known good behaviour
# https://github.com/systemd/systemd/commit/6b2d576f2b38c0385bb056af328754ec8966f9fd
PrivateMounts=no
Not sure whether there might be better ways to deal with this systemd change. I'll leave that up to you.
After enabling the service and rebooting (using the default configuration), I get bunch of Error statting /zram0: No such file or directory
coming from udiskd at random intervals for about a minute after booting:
mai 30 19:04:56 terence-desktop systemd[1]: Starting Automatically setup swap on zram...
mai 30 19:04:56 terence-desktop kernel: zram: Added device: zram0
mai 30 19:04:56 terence-desktop systemd[1]: Created slice system-udisks2\x2dzram\x2dsetup.slice.
mai 30 19:04:56 terence-desktop systemd[1]: Starting UDisks2 managed ZRAM device zram0 setup...
mai 30 19:04:56 terence-desktop kernel: zram0: detected capacity change from 0 to 16777216
mai 30 19:04:56 terence-desktop systemd[1]: [email protected]: Deactivated successfully.
mai 30 19:04:56 terence-desktop systemd[1]: Finished UDisks2 managed ZRAM device zram0 setup.
mai 30 19:04:56 terence-desktop kernel: Adding 8388604k swap on /dev/zram0. Priority:100 extents:1 across:8388604k SSFS
mai 30 19:04:56 terence-desktop systemd[1]: Finished Automatically setup swap on zram.
mai 30 19:04:56 terence-desktop udisksd[623]: Error statting /zram0: No such file or directory
mai 30 19:04:56 terence-desktop udisksd[623]: Error statting /zram0: No such file or directory
mai 30 19:05:04 terence-desktop udisksd[623]: Error statting /zram0: No such file or directory
mai 30 19:05:07 terence-desktop udisksd[623]: Error statting /zram0: No such file or directory
mai 30 19:05:07 terence-desktop udisksd[623]: Error statting /zram0: No such file or directory
mai 30 19:05:08 terence-desktop udisksd[623]: Error statting /zram0: No such file or directory
mai 30 19:05:20 terence-desktop udisksd[623]: Error statting /zram0: No such file or directory
I still seem to get a functioning zram swap:
total used free shared buff/cache available
Mem: 15Gi 2,7Gi 8,3Gi 194Mi 4,6Gi 11Gi
Swap: 8,0Gi 0B 8,0Gi
Since the message is coming from udisks2, should an issue be opened there or is there something zramd might do incorrectly?
I have set the fraction to 0.5 and the maximum_size to 16384MB, but running zramctl or the system monitor shows the size of the zram swap to be 7.5GB. It’s supposed to be 16GB, as that is the uncompressed maximum. This is a problem, because I want to run a script which automatically frees the swap if there is enough free memory. If the number reported is incorrect, so e.g. there are 5GB of pages in swap but the uncompressed size is more like 10GB, this could crash my system by leading to an out-of-memory condition.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.