What can I do to get rid of swap and use zram only? | I made a mistake during the install

First, please allow me to thank you for a most excellent distro.

Every couple of years I distro-hop in an attempt to see what is new in the linux world and I recently stumbled across Garuda when I purchased a new desktop to replace my aging gaming computer. After trying several distro's, Garuda was the ONLY one where all of the hardware/drivers worked perfectly upon installation. THANK YOU !!!

While I've run many different distro's, I've spent most of my time running MX Linux with Xfce and then Solus with Plasma. This is where I am coming to Garuda from.

What I learned from distro-hopping this time was centered on BTRFS and ZRAM. I'm no expert, but I am still learning. I love the option of being able to roll back to a previous snapshot via grub-btrfs.

I don't consider myself to be a beginner when it comes to linux, but I am new to Arch. Well, being old and somewhat set in my ways, I chose to customize the install, like I always, and chose separate partition for swap. I can see that I have zram and swap both configured. My question is what can I do to get rid of swap and use zram only?

[πŸ”] Γ— garuda-inxi
System:
Kernel: 5.18.9-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 12.1.0
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
root=UUID=ecab03e1-a558-41c4-9a5d-c968be69fb64 rw [email protected]
quiet
cryptdevice=UUID=aafdf48b-7261-469c-8910-7f87d7aec02d:luks-aafdf48b-7261-469c-8910-7f87d7aec02d
root=/dev/mapper/luks-aafdf48b-7261-469c-8910-7f87d7aec02d splash
rd.udev.log_priority=3 vt.global_cursor_default=0
systemd.unified_cgroup_hierarchy=1
resume=/dev/mapper/luks-79407f78-876d-4460-8848-f2923cf77026 loglevel=3
Desktop: KDE Plasma v: 5.25.2 tk: Qt v: 5.15.5 info: latte-dock
wm: kwin_x11 vt: 1 dm: SDDM Distro: Garuda Linux base: Arch Linux
Machine:
Type: Desktop System: Micro product: G510 v: 1.0
serial: <superuser required>
Mobo: ASUSTeK model: PRIME B550M-A AC v: Rev X.0x
serial: <superuser required> UEFI: American Megatrends v: 2006
date: 03/19/2021
CPU:
Info: model: AMD Ryzen 5 5600X bits: 64 type: MT MCP arch: Zen 3 gen: 4
built: 2021-22 process: TSMC n7 (7nm) family: 0x19 (25) model-id: 0x21 (33)
stepping: 0 microcode: 0xA201009
Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 3 MiB desc: 6x512 KiB
L3: 32 MiB desc: 1x32 MiB
Speed (MHz): avg: 3829 high: 4629 min/max: 2200/4650 boost: enabled
scaling: driver: acpi-cpufreq governor: performance cores: 1: 4525 2: 3589
3: 3604 4: 3737 5: 4629 6: 3876 7: 3604 8: 3604 9: 3809 10: 3638 11: 3600
12: 3734 bogomips: 88626
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: mmio_stale_data status: Not affected
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: Retpolines, IBPB: conditional, IBRS_FW,
STIBP: always-on, RSB filling
Type: srbds status: Not affected
Type: tsx_async_abort status: Not affected
Graphics:
Device-1: AMD Navi 22 [Radeon RX 6700/6700 XT/6750 XT / 6800M]
vendor: Tul / PowerColor driver: amdgpu v: kernel arch: RDNA 2
process: TSMC n7 (7nm) built: 2020-22 pcie: gen: 4 speed: 16 GT/s
lanes: 16 ports: active: DP-3 empty: DP-1,DP-2,HDMI-A-1 bus-ID: 0d:00.0
chip-ID: 1002:73df class-ID: 0300
Display: x11 server: X.Org v: 21.1.3 with: Xwayland v: 22.1.2
compositor: kwin_x11 driver: X: loaded: amdgpu unloaded: modesetting,radeon
alternate: fbdev,vesa gpu: amdgpu display-ID: :0 screens: 1
Screen-1: 0 s-res: 2560x1440 s-dpi: 96 s-size: 677x381mm (26.65x15.00")
s-diag: 777mm (30.58")
Monitor-1: DP-3 mapped: DisplayPort-2 model: ASUS VG32VQ1B
serial: <filter> built: 2020 res: 2560x1440 hz: 165 dpi: 93 gamma: 1.2
size: 697x392mm (27.44x15.43") diag: 800mm (31.5") ratio: 16:9 modes:
max: 2560x1440 min: 720x400
OpenGL: renderer: AMD Radeon RX 6700 XT (navy_flounder LLVM 14.0.6 DRM
3.46 5.18.9-zen1-1-zen)
v: 4.6 Mesa 22.1.3 direct render: Yes
Audio:
Device-1: AMD Navi 21/23 HDMI/DP Audio driver: snd_hda_intel v: kernel
pcie: gen: 4 speed: 16 GT/s lanes: 16 bus-ID: 0d:00.1 chip-ID: 1002:ab28
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: 0f:00.4 chip-ID: 1022:1487 class-ID: 0403
Sound Server-1: ALSA v: k5.18.9-zen1-1-zen running: yes
Sound Server-2: sndio v: N/A running: no
Sound Server-3: JACK v: 1.9.21 running: no
Sound Server-4: PulseAudio v: 16.1 running: yes
Sound Server-5: PipeWire v: 0.3.53 running: yes
Network:
Device-1: Realtek RTL8821CE 802.11ac PCIe Wireless Network Adapter
vendor: ASUSTeK driver: rtw_8821ce v: N/A modules: rtw88_8821ce pcie:
gen: 1 speed: 2.5 GT/s lanes: 1 port: e000 bus-ID: 09:00.0
chip-ID: 10ec:c821 class-ID: 0280
IF: wlp9s0 state: up mac: <filter>
Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
vendor: ASUSTeK PRIME B450M-A driver: r8169 v: kernel pcie: gen: 1
speed: 2.5 GT/s lanes: 1 port: d000 bus-ID: 0a:00.0 chip-ID: 10ec:8168
class-ID: 0200
IF: enp10s0 state: down mac: <filter>
Bluetooth:
Device-1: ASUSTek Bluetooth Radio type: USB driver: btusb v: 0.8
bus-ID: 1-5:3 chip-ID: 0b05:18ea class-ID: e001 serial: <filter>
Report: bt-adapter note: tool can't run ID: hci0 rfk-id: 0 state: down
bt-service: disabled rfk-block: hardware: no software: yes address: N/A
Drives:
Local Storage: total: 4.55 TiB used: 627.23 GiB (13.5%)
SMART Message: Unable to run smartctl. Root privileges required.
ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Western Digital
model: WDS100T2B0C-00PXH0 size: 931.51 GiB block-size: physical: 512 B
logical: 512 B speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter>
rev: 211210WD temp: 36.9 C scheme: GPT
ID-2: /dev/sda maj-min: 8:0 type: USB vendor: Seagate model: Expansion
size: 3.64 TiB block-size: physical: 4096 B logical: 512 B type: N/A
serial: <filter> rev: 0710
Partition:
ID-1: / raw-size: 896.86 GiB size: 896.86 GiB (100.00%)
used: 627.23 GiB (69.9%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
mapped: luks-aafdf48b-7261-469c-8910-7f87d7aec02d
ID-2: /boot/efi raw-size: 260 MiB size: 256 MiB (98.46%)
used: 706 KiB (0.3%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
ID-3: /home raw-size: 896.86 GiB size: 896.86 GiB (100.00%)
used: 627.23 GiB (69.9%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
mapped: luks-aafdf48b-7261-469c-8910-7f87d7aec02d
ID-4: /var/log raw-size: 896.86 GiB size: 896.86 GiB (100.00%)
used: 627.23 GiB (69.9%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
mapped: luks-aafdf48b-7261-469c-8910-7f87d7aec02d
ID-5: /var/tmp raw-size: 896.86 GiB size: 896.86 GiB (100.00%)
used: 627.23 GiB (69.9%) fs: btrfs dev: /dev/dm-0 maj-min: 254:0
mapped: luks-aafdf48b-7261-469c-8910-7f87d7aec02d
Swap:
Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
ID-1: swap-1 type: zram size: 31.26 GiB used: 2.81 GiB (9.0%)
priority: 100 dev: /dev/zram0
ID-2: swap-2 type: partition size: 34.39 GiB used: 0 KiB (0.0%)
priority: -2 dev: /dev/dm-1 maj-min: 254:1
mapped: luks-79407f78-876d-4460-8848-f2923cf77026
Sensors:
System Temperatures: cpu: N/A mobo: N/A gpu: amdgpu temp: 54.0 C
mem: 44.0 C
Fan Speeds (RPM): N/A gpu: amdgpu fan: 1089
Info:
Processes: 407 Uptime: 1d 34m wakeups: 0 Memory: 31.26 GiB
used: 13.31 GiB (42.6%) Init: systemd v: 251 default: graphical
tool: systemctl Compilers: gcc: 12.1.0 clang: 14.0.6 Packages: 2119
pacman: 2109 lib: 574 flatpak: 10 Shell: fish v: 3.4.1 default: Bash
v: 5.1.16 running-in: konsole inxi: 3.3.19
Garuda (2.6.4-2):
System install date:     2021-11-04
Last full system update: 2022-07-04
Is partially upgraded:   No
Relevant software:       NetworkManager
Windows dual boot:       No/Undetected
Snapshots:               Timeshift
Failed units:            systemd-networkd-wait-online.service

To permanently disable swap you must:

  1. swapoff -a

  2. edit /etc/fstab and comment or remove the line with your swap entry

In your case, from your inxi, it looks like this partition you want to comment out of fstab...

  1. run: sudo systemctl mask "dev-sdXX.swap"

(where XX is the swap partition. Note, you should use quotes around the unit name in case the name has escape characters/backslash. Also useful to do it for all possible partitions so that if there is a swap partition on any other drive it will not be mounted.)

:peace_symbol: Have a good one.

EDIT: btw... These actions do not affect your zram which will be kept "as-is" intact. :wink:

4 Likes

Thanks for the assistance.

I've run these cmds and I have two questions.

╰─λ lsblk                                                                                                                                                    β”‚
NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS                                                                          β”‚
sda                                             8:0    0   3.6T  0 disk                                                                                       β”‚
zram0                                         253:0    0     0B  0 disk                                                                                       β”‚
nvme0n1                                       259:0    0 931.5G  0 disk                                                                                       β”‚
β”œβ”€nvme0n1p1                                   259:1    0   260M  0 part  /boot/efi                                                                            β”‚
β”œβ”€nvme0n1p2                                   259:2    0 896.9G  0 part                                                                                       β”‚
β”‚ └─luks-aafdf48b-7261-469c-8910-7f87d7aec02d 254:0    0 896.9G  0 crypt /var/tmp                                                                             β”‚
β”‚                                                                        /var/log                                                                             β”‚
β”‚                                                                        /var/cache                                                                           β”‚
β”‚                                                                        /srv                                                                                 β”‚
β”‚                                                                        /root                                                                                β”‚
β”‚                                                                        /home                                                                                β”‚
β”‚                                                                        /                                                                                    β”‚
└─nvme0n1p3                                   259:3    0  34.4G  0 part                                                                                       β”‚
└─luks-79407f78-876d-4460-8848-f2923cf77026 254:1    0  34.4G  0 crypt

The zram device is showing as 0B size. Is this correct?

Also, can I now remove the 32GB partition (nvme0n1p3, which was the swap partition)?

My pleasure. :slight_smile:

No. 0B is not correct. Here is my lsblk output:

NAME                                        MAJ:MIN RM   SIZE   RO TYPE  MOUNTPOINTS
zram0                                         253:0  0   23.4G  0  disk  [SWAP]

Yes.

1 Like

Thanks for the quick response. Any ideas on what I need to do to confirm that zram is configured and working correctly? Is there a default configuration that I can enable?

Have you rebooted since you disabled swap?

I'd say do that and then check your zram and we go from there. I assume the garuda installer has setup your zram? errr maybe the installer saw your custom partitioning (The installer found your standard swap you provisioned) and didn't setup zram properly? This part is guess work here but I feel that may have happened. Someone more knowledgeable of the garuda-installer innards can jump in if needed.

I guess the sensible question to ask here is also "Have you messed around with any zram configs or such?" :wink:

Anyhoo... awaiting your reboot/check-zram results...

btw, you can also check zram with zramctl.

Here is my zramctl output with active zram present:

╰─λ zramctl
NAME ALGORITHM DISKSIZE  DATA  COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd         23.4G  1.9M 300.4K  664K       8 [SWAP]
1 Like

You must disable hibernation first. Remove the resume=swap_partition from grub command line and resume from mkinitcpio hooks. Then rebuild images (which should normally recreate grub.cfg).

Auto zram is created from a utitlity. IIRC zram-generator, or systemd-swap (query pacman DB for exact package pacman -Qs swap)

4 Likes
  1. zramctl will show you status of zram. If not active you will get no output from the command.

  2. sudo systemctl status [email protected]

:arrow_up:

It is this systemd service unit that automatically initializes zram devices without user intervention.

Worth noting from the archwiki linked here ...

The zram-generator package provides a [email protected] unit to automatically initialize zram devices without users needing to enable/start the template or its instances.

You shouldn't have a need to run the generator, BUT, you should already have the systemd service unit ready to go. Just "enable" if needed, then start/restart the unit and your available zram will be activated by the service unit.

Here you can see an example configuration file needed for zram-generator

Note: "The generator will be invoked by systemd early at boot", so usage is as simple as creating the appropriate configuration file(s) and rebooting. A sample configuration is provided in /usr/share/doc/zram-generator/zram-generator.conf.example

So if you need to setup zram from scratch you will need to...

  1. Make your zram config for zram-generator to use.

  2. reboot so the zram-generator & systemd unit [email protected] can do their magic (it is all automatic).

  3. Once rebooted check the systemd zram service unit status & zramctl to verify the state of your zram.


/usr/lib/systemd/zram-generator.conf

2 Likes
╰─λ zramctl
NAME       ALGORITHM DISKSIZE  DATA  COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd         31.3G  688K 112.4K  536K      12 [SWAP]

The reboot fixed it. All good now.

Thanks again for the assistance.

1 Like

Can you assist me with removing 'resuming=swap_partition' and 'resume'?

I don't know how to do that.

Whatever I can tell you, you will have to read it.
Instead, you may read the best guide I know, from which I have learnt myself.

5 Likes

Thanks that link was very helpful.

I was able to remove the resume option from grub and the mkinitcpio hook.

Thanks everyone for the assistance.

3 Likes

@Mr_McBride :: Good deal. And a huge "Thanks" for responding to help offers and ideas rapidly in this post. It really helps to get the [ proper ] feedback. =)

A++ for advising here that your issue(s) are solved as well.

Soldier on... Life is grand!

:peace_symbol: :dove:

2 Likes

You're very welcome @Cannabis , but you and @petsam deserve all the credit. Both of you provided exactly what I needed to resolve this issue.

2 Likes

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