Removing ZRAM, I already have a Swap file

Hello.

I did an lsblk in terminal and it shows that I have two swap files a ZRAM0 and the normal 32 GB one I created. I was wondering if it is possible that I remove the ZRAM0 swap. I am also wondering if it is even safe to do so. If you could please shed some light on this I would appreciate it.

Thank you,

Jim

inxi
System:    Kernel: 5.15.6-zen2-1-zen x86_64 bits: 64 compiler: gcc v: 11.1.0
                  parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen root=UUID=cb295fb6-ed4a- 
                  4293-b8e9-420dc556f706 rw
                  [email protected] quiet splash rd.udev.log_priority=3 vt.global_cursor_default=0
                 systemd.unified_cgroup_hierarchy=1 resume=UUID=14da6523-9862-4f95-a909- 
                 53a38def6912 loglevel=3
Desktop: GNOME 41.1 tk: GTK 3.24.30 wm: gnome-shell dm: GDM 41.0 Distro: Garuda Linux 
                 base: Arch Linux
Machine:   Type: Laptop System: Apple product: MacBookPro11,5 v: 1.0 serial: <superuser 
                   required> Chassis: type: 9
Mobo:       Apple model: Mac-06F11F11946D27C5 v: MacBookPro11,5 serial: <superuser 
                   required> UEFI: Apple v: 428.40.10.0.0
                   date: 09/25/2021
Battery:   ID-1: BAT0 charge: 87.1 Wh (100.0%) condition: 87.1/97.2 Wh (89.7%) volts: 12.7 min: 
                 11.3 model: SMP bq20z451
                 type: Li-ion serial: N/A status: Discharging cycles: 20
Device-1:  hid-34:88:5d:de:42:8d-battery model: Bluetooth Mouse M336/M337/M535 serial: N/A 
                  charge: N/A
                  status: Discharging
CPU:         Info: Quad Core model: Intel Core i7-4980HQ bits: 64 type: MT MCP arch: Haswell 
                 family: 6 model-id: 46 (70)
                 stepping: 1 microcode: 1C cache: L1: 256 KiB L2: 1024 KiB L3: 6 MiB
                 flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 44697
                 Speed: 3053 MHz min/max: 800/4000 MHz Core speeds (MHz): 1: 3053 2: 3357 3: 2915 
                 4: 3009 5: 2943 6: 3266 7: 2800
                 8: 2884
                 Vulnerabilities: Type: itlb_multihit status: KVM: VMX disabled
                 Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
                 Type: mds mitigation: Clear CPU buffers; SMT vulnerable
                 Type: meltdown mitigation: PTI
                 Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl
                 Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization
                 Type: spectre_v2 mitigation: Full generic retpoline, IBPB: conditional, IBRS_FW, STIBP: 
                 conditional, RSB filling
                 Type: srbds mitigation: Microcode
                 Type: tsx_async_abort status: Not affected
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Venus XT [Radeon HD 8870M / R9 
                   M270X/M370X] vendor: Apple driver: radeon
                   v: kernel alternate: amdgpu bus-ID: 01:00.0 chip-ID: 1002:6821 class-ID: 0300
                   Display: x11 server: X.Org 1.21.1.1 compositor: gnome-shell driver: loaded: 
                   ati,radeon unloaded: modesetting
                   alternate: fbdev,vesa display-ID: :1 screens: 1
Screen-1:  0 s-res: 2880x1800 s-dpi: 96 s-size: 762x476mm (30.0x18.7") s-diag: 898mm (35.4")
Monitor-1: eDP res: 2880x1800 hz: 60 dpi: 221 size: 331x207mm (13.0x8.1") diag: 390mm (15.4")
OpenGL:   renderer: AMD VERDE (DRM 2.50.0 5.15.6-zen2-1-zen LLVM 13.0.0) v: 4.5 Mesa 21.2.5 
                  direct render: Yes
Audio:       Device-1: Intel 8 Series/C220 Series High Definition Audio driver: snd_hda_intel v: kernel bus-ID: 00:1b.0
                  chip-ID: 8086:8c20 class-ID: 0403
Device-2:  AMD Oland/Hainan/Cape Verde/Pitcairn HDMI Audio [Radeon HD 7000 Series] 
                  vendor: Apple
                  driver: snd_hda_intel v: kernel bus-ID: 01:00.1 chip-ID: 1002:aab0 class-ID: 0403
Device-3:  Broadcom 720p FaceTime HD Camera driver: facetimehd v: kernel bus-ID: 05:00.0 
                  chip-ID: 14e4:1570
                  class-ID: 0480
Sound Server-1: ALSA v: k5.15.6-zen2-1-zen running: yes
Sound Server-2: JACK v: 1.9.19 running: no
Sound Server-3: PulseAudio v: 15.0 running: no
Sound Server-4: PipeWire v: 0.3.40 running: yes
Network:   Device-1: Broadcom BCM43602 802.11ac Wireless LAN SoC vendor: Apple driver: 
                   brcmfmac v: kernel bus-ID: 04:00.0
                   chip-ID: 14e4:43ba class-ID: 0280
                   IF: wlp4s0 state: up mac: <filter>
Bluetooth: Device-1: Apple Bluetooth Host Controller type: USB driver: btusb,hid-generic,usbhid 
                   bus-ID: 1-8:2
                  chip-ID: 05ac:8290 class-ID: fe01
Report:     bt-adapter ID: hci0 rfk-id: 0 state: up address: <filter>
Drives:      Local Storage: total: 931.84 GiB used: 240.53 GiB (25.8%)
SMART Message: Required tool smartctl not installed. Check --recommends
                ID-1: /dev/sda maj-min: 8:0 vendor: Apple model: SSD SM1024G size: 931.84 GiB 
                block-size: physical: 4096 B
                logical: 512 B speed: 6.0 Gb/s type: SSD serial: <filter> rev: SA0Q scheme: GPT
Partition: ID-1: / raw-size: 292.97 GiB size: 292.97 GiB (100.00%) used: 12.62 GiB (4.3%) fs: btrfs 
                dev: /dev/sda2
                maj-min: 8:2
                ID-2: /boot/efi raw-size: 401 MiB size: 400.2 MiB (99.80%) used: 576 KiB (0.1%) fs: vfat 
               dev: /dev/sda1
               maj-min: 8:1
               ID-3: /home raw-size: 607.23 GiB size: 607.23 GiB (100.00%) used: 227.91 GiB (37.5%) fs: btrfs dev: /dev/sda4
              maj-min: 8:4
              ID-4: /var/log raw-size: 292.97 GiB size: 292.97 GiB (100.00%) used: 12.62 GiB (4.3%) fs: btrfs dev: /dev/sda2
             maj-min: 8:2
             ID-5: /var/tmp raw-size: 292.97 GiB size: 292.97 GiB (100.00%) used: 12.62 GiB (4.3%) fs: btrfs dev: /dev/sda2
             maj-min: 8:2
Swap:  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
             ID-1: swap-1 type: partition size: 31.25 GiB used: 0 KiB (0.0%) priority: -2 dev: /dev/sda3 maj-min: 8:3
             ID-2: swap-2 type: zram size: 15.5 GiB used: 223.8 MiB (1.4%) priority: 100 dev: /dev/zram0
            Sensors:   System Temperatures: cpu: 78.0 C pch: 58.5 C mobo: N/A gpu: radeon temp: 
            69.0 C
           Fan Speeds (RPM): N/A
Info:   Processes: 337 Uptime: 8h 44m wakeups: 4 Memory: 15.5 GiB used: 4.35 GiB (28.1%) Init:  
           systemd v: 249
           tool: systemctl Compilers: gcc: 11.1.0 clang: 13.0.0 Packages: pacman: 1430 lib: 466 Shell: Bash v: 5.1.12
           running-in: terminator inxi: 3.3.09

What are the reasons to remove ZRAM? Which advantages do you think that using a hard drive instead of RAM as SWAP has?

2 Likes

I have 16 GB of ram and created a 32 GB Swap partition on installation. I do not see the benefit of an additional swap partition.

zram is compressed swap in ram. It will be much more performant than swap on disk.

While I think you are better off leaving it, you can remove it if you wish. Just edit the config file and remove the zram device.

5 Likes

In this situation zswap is the correct approach (rather than zram). They're essentially equivalent, but zswap works natively with a backing device (and works well).

See here for more information: https://wiki.archlinux.org/title/Improving_performance#zram_or_zswap . There are some nice tweaks to the defaults too. I use:

zswap.enabled=1 zswap.compressor=zstd zswap.max_pool_percent=80 zswap.zpool=z3fold

(zswap.enabled=1 is redundant as zswap is enabled by default, but it's left for illustration)

3 Likes

Gotcha, I didn't understand that. I will leave it in place. Thank you

This is completely correct. However, zswap is enabled by default (in the Arch kernel) and will take advantage of a swap device when present. zram is excellent for systems without a swap device (e.g. embedded systems, systems with SSDs, ...).

2 Likes

Dalto i understand how paging works as well as the memory manager, however i have a question. why is z swap faster...see the kernel pages things not often uses to disk when ram starts to get low that way things with a higher reference count. so why are we know paging swap to ram...the highest referenced things are mapped to l1 cache then overflow from the l1 through the cpu caches then to sysyem memory then to the swap..

why are we taking things from the swap and loading them to ram when the kernel will load them back into system memory as needed, because that is what the memory manager does.

feel free to go deep, i understand computer science. i studied it at MIT via open course ware and i can code as well...although i coded in visual studio but whatever..i was a Microsoft user then.

We're not - we're swapping pages from uncompressed RAM into compressed RAM rather than onto disk.

OT

Ooo!

Oh. That's not quite the same.

1 Like

Removing Zram IMHO basically removes one of the founding features of the Garuda Linux distro. People needs to learn that paging through the ssd speeds up its death, while paging through the HDD is hell-on-earth experience. In both instances, the system performs slower, as paging out of memory is costly to performance, it increases system's latency.

2 Likes

compressed ram? so its like g zip for memory ?

If you want to go deep on zswap, read this:

Not really other than the fact that both involve compression.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.