Swapfile makes system unstable

This one has me stumped. I dont know if it is a quirk of my hw, but everytime i have tried to use a swapfile (ext4) vs a swap partition, my system gets unstable. X locks up solid but i can switch over to tty to gracefully reboot. The odd thing is, if i use a swap partition, the problem goes away. It doesnt seem to be dependent on a certain kernel level. I read everywhere that swapfile is preferred, but my system just gets unstable. I started with a 8G swapfile but upped it to 16G thinking that was the problem. Didnt make a bit of difference. I just went back and created a 70G swap parttition (i have 64G mem).

Any ideas?

Can you try to use a swap partition ?

Can you provide inxi -Fza ?

Do you have a HD or a SSD?

It is an nvme.

Yea… and it is completely stable when i use a swap partition.

~ $ inxi -Fza
System:
  Kernel: 6.9.12-3-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 14.2.1
    clocksource: tsc avail: hpet,acpi_pm
    parameters: root=UUID=71203883-958d-4bfd-8c4e-fe5e36536f51 rw
    resume=UUID=c26fadcc-9b2c-4ea9-877b-ba0fbc2ba478 ipv6.disable=1
    mitigations=off processor.max_cstate=5 acpi_osi=Linux amd_iommu=on
    iommu=pt amdgpu.gpu_recovery=1 nowatchdog amdgpu.lockup_timeout=0
    amdgpu.ppfeaturemask=0xffffffff quiet udev.log_priority=3
    initrd=boot\initramfs-6.9-x86_64.img
  Desktop: KDE Plasma v: 6.0.5 tk: Qt v: N/A info: frameworks v: 6.5.0
    wm: kwin_x11 tools: xscreensaver,xscreensaver-systemd vt: 2 dm: SDDM
    Distro: Manjaro base: Arch Linux
Machine:
  Type: Desktop System: ASUS product: N/A v: N/A serial: <superuser required>
  Mobo: ASUSTeK model: ROG CROSSHAIR VIII HERO (WI-FI) v: Rev X.0x
    serial: <superuser required> part-nu: SKU uuid: <superuser required>
    UEFI: American Megatrends v: 4702 date: 10/20/2023
CPU:
  Info: model: AMD Ryzen 9 5950X bits: 64 type: MT MCP arch: Zen 3+ gen: 4
    level: v3 note: check built: 2022 process: TSMC n6 (7nm) family: 0x19 (25)
    model-id: 0x21 (33) stepping: 0 microcode: 0xA20102B
  Topology: cpus: 1x cores: 16 tpc: 2 threads: 32 smt: enabled cache:
    L1: 1024 KiB desc: d-16x32 KiB; i-16x32 KiB L2: 8 MiB desc: 16x512 KiB
    L3: 64 MiB desc: 2x32 MiB
  Speed (MHz): avg: 2772 high: 4369 min/max: 2200/5083 boost: enabled
    scaling: driver: acpi-cpufreq governor: schedutil cores: 1: 2200 2: 4356
    3: 2953 4: 3816 5: 3406 6: 3122 7: 4369 8: 2200 9: 2200 10: 2198 11: 2199
    12: 2199 13: 2200 14: 2198 15: 2200 16: 2200 17: 3653 18: 3618 19: 2890
    20: 3710 21: 3208 22: 2902 23: 3632 24: 3507 25: 2200 26: 2200 27: 2196
    28: 2199 29: 2200 30: 2200 31: 2200 32: 2200 bogomips: 217667
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
  Vulnerabilities:
  Type: gather_data_sampling status: Not affected
  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: reg_file_data_sampling status: Not affected
  Type: retbleed status: Not affected
  Type: spec_rstack_overflow status: Vulnerable
  Type: spec_store_bypass status: Vulnerable
  Type: spectre_v1 status: Vulnerable: __user pointer sanitization and
    usercopy barriers only; no swapgs barriers
  Type: spectre_v2 status: Vulnerable; IBPB: disabled; STIBP: disabled;
    PBRSB-eIBRS: Not affected; BHI: Not affected
  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: Tul / PowerColor driver: amdgpu v: kernel arch: RDNA-1 code: Navi-1x
    process: TSMC n7 (7nm) built: 2019-20 pcie: gen: 4 speed: 16 GT/s
    lanes: 16 ports: active: DP-1 empty: DP-2,DP-3,HDMI-A-1 bus-ID: 0a:00.0
    chip-ID: 1002:731f class-ID: 0300
  Device-2: Logitech HD Webcam C525 driver: snd-usb-audio,uvcvideo type: USB
    rev: 2.0 speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 5-4:3 chip-ID: 046d:0826
    class-ID: 0e02 serial: <filter>
  Display: x11 server: X.Org v: 21.1.13 with: Xwayland v: 24.1.2
    compositor: kwin_x11 driver: X: loaded: amdgpu unloaded: modesetting,radeon
    alternate: fbdev,vesa dri: radeonsi gpu: amdgpu display-ID: :0 screens: 1
  Screen-1: 0 s-res: 2560x1440 s-dpi: 72 s-size: 903x508mm (35.55x20.00")
    s-diag: 1036mm (40.79")
  Monitor-1: DP-1 mapped: DisplayPort-0 model: LG (GoldStar) ULTRAGEAR
    serial: <filter> built: 2021 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: 640x480
  API: EGL v: 1.5 hw: drv: amd radeonsi platforms: device: 0 drv: radeonsi
    device: 1 drv: swrast gbm: drv: kms_swrast surfaceless: drv: radeonsi x11:
    drv: radeonsi inactive: wayland
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 24.1.6-arch1.1
    glx-v: 1.4 direct-render: yes renderer: AMD Radeon RX 5700 XT 50th
    Anniversary (radeonsi navi10 LLVM 18.1.8 DRM 3.57 6.9.12-3-MANJARO)
    device-ID: 1002:731f memory: 7.81 GiB unified: no
  API: Vulkan v: 1.3.279 layers: 5 device: 0 type: discrete-gpu name: AMD
    Radeon RX 5700 XT 50th Anniversary (RADV NAVI10) driver: mesa radv
    v: 24.1.6-arch1.1 device-ID: 1002:731f surfaces: xcb,xlib
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: 0a: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
  Device-3: Logitech HD Webcam C525 driver: snd-usb-audio,uvcvideo type: USB
    rev: 2.0 speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 5-4:3 chip-ID: 046d:0826
    class-ID: 0e02 serial: <filter>
  API: ALSA v: k6.9.12-3-MANJARO status: kernel-api with: aoss
    type: oss-emulator tools: alsactl,alsamixer,amixer
  Server-1: sndiod v: N/A status: off tools: aucat,midicat,sndioctl
  Server-2: JACK v: 1.9.22 status: off tools: N/A
  Server-3: PipeWire v: 1.2.2 status: off with: pipewire-media-session
    status: active tools: pw-cli
  Server-4: PulseAudio v: 17.0 status: active with: 1: pulseaudio-alsa
    type: plugin 2: pulseaudio-jack type: module tools: pacat,pactl
Network:
  Device-1: Mellanox MT27500 Family [ConnectX-3] driver: mlx4_core v: 4.0-0
    pcie: gen: 3 speed: 8 GT/s lanes: 4 port: N/A bus-ID: 0b:00.0
    chip-ID: 15b3:1003 class-ID: 0200
  IF: enp11s0 state: up speed: 10000 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>
  Info: services: NetworkManager, sshd, systemd-timesyncd
Bluetooth:
  Device-1: Intel AX200 Bluetooth driver: btusb v: 0.8 type: USB rev: 2.0
    speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-6:3 chip-ID: 8087:0029
    class-ID: e001
  Report: btmgmt ID: hci0 rfk-id: 0 state: down bt-service: disabled
    rfk-block: hardware: no software: no address: N/A
RAID:
  Supported mdraid levels: raid0
  Device-1: md0 maj-min: 9:0 type: mdraid level: raid-0 status: active
    size: 7.14 TiB
  Info: report: N/A blocks: 7670165504 chunk-size: 512k super-blocks: 1.2
  Components: Online:
  0: sda1 maj-min: 8:1 size: 1.79 TiB
  1: sdb1 maj-min: 8:17 size: 1.79 TiB
  2: sdc1 maj-min: 8:33 size: 1.79 TiB
  3: sdd1 maj-min: 8:49 size: 1.79 TiB
  Device-2: md1 maj-min: 9:1 type: mdraid level: raid-0 status: active
    size: 5.46 TiB
  Info: report: N/A blocks: 5860116480 chunk-size: 512k super-blocks: 1.2
  Components: Online:
  0: sdb2 maj-min: 8:18 size: 1.82 TiB
  1: sdc2 maj-min: 8:34 size: 1.82 TiB
  2: sdd2 maj-min: 8:50 size: 1.82 TiB
Drives:
  Local Storage: total: 16.46 TiB used: 15.36 TiB (93.3%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: A-Data model: SX8200PNP
    size: 1.86 TiB block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s
    lanes: 4 tech: SSD serial: <filter> fw-rev: 42AZS6AC temp: 39.9 C
    scheme: GPT
  ID-2: /dev/nvme1n1 maj-min: 259:1 vendor: A-Data model: SX8200PNP
    size: 1.86 TiB block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s
    lanes: 4 tech: SSD serial: <filter> fw-rev: 42AZS6AC temp: 40.9 C
    scheme: GPT
  ID-3: /dev/sda maj-min: 8:0 vendor: Crucial model: CT2000MX500SSD1
    size: 1.82 TiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s
    tech: SSD serial: <filter> fw-rev: 023 scheme: GPT
  ID-4: /dev/sdb maj-min: 8:16 vendor: Crucial model: CT4000MX500SSD1
    size: 3.64 TiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s
    tech: SSD serial: <filter> fw-rev: 046 scheme: GPT
  ID-5: /dev/sdc maj-min: 8:32 vendor: Crucial model: CT4000MX500SSD1
    size: 3.64 TiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s
    tech: SSD serial: <filter> fw-rev: 046 scheme: GPT
  ID-6: /dev/sdd maj-min: 8:48 vendor: Crucial model: CT4000MX500SSD1
    size: 3.64 TiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s
    tech: SSD serial: <filter> fw-rev: 046 scheme: GPT
Partition:
  ID-1: / raw-size: 314.81 GiB size: 308.8 GiB (98.09%)
    used: 178.54 GiB (57.8%) fs: ext4 dev: /dev/nvme0n1p4 maj-min: 259:5
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
    used: 24.6 MiB (8.2%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:2
  ID-3: /home raw-size: 1.46 TiB size: 1.43 TiB (98.36%)
    used: 866.13 GiB (59.0%) fs: ext4 dev: /dev/nvme0n1p2 maj-min: 259:3
Swap:
  Kernel: swappiness: 10 (default 60) cache-pressure: 100 (default) zswap: yes
    compressor: zstd max-pool: 20%
  ID-1: swap-1 type: partition size: 68.36 GiB used: 256 KiB (0.0%)
    priority: -2 dev: /dev/nvme0n1p3 maj-min: 259:4
Sensors:
  System Temperatures: cpu: 62.2 C mobo: 40.0 C gpu: amdgpu temp: 40.0 C
    mem: 42.0 C
  Fan Speeds (rpm): cpu: 0 fan-1: 0 fan-2: 0 fan-3: 1176 fan-4: 0 fan-5: 0
    fan-6: 799 fan-7: 807 gpu: amdgpu fan: 65535
Info:
  Memory: total: 64 GiB note: est. available: 62.7 GiB used: 12.12 GiB (19.3%)
  Processes: 630 Power: uptime: 31m states: freeze,mem,disk suspend: deep
    avail: s2idle wakeups: 0 hibernate: platform avail: shutdown, reboot,
    suspend, test_resume image: 25.07 GiB services: org_kde_powerdevil,upowerd
    Init: systemd v: 256 default: graphical tool: systemctl
  Packages: 3396 pm: dpkg pkgs: 0 pm: pacman pkgs: 3300 libs: 651
    tools: pamac,yay pm: appimage pkgs: 0 pm: flatpak pkgs: 96 Compilers:
    clang: 18.1.8 gcc: 14.2.1 Shell: Bash v: 5.2.32 running-in: konsole

Some prefer swapfiles, some prefer partitions, the former are more vocal. The “benefits” of using a file is that you can change the size without re-partitioning (assuming you have space), therefore some think they’re more versatile. However the space needs to accounted for one way or another.

There was a bug once that only affected swapfiles, which corrupted the filesystem containing the swapfile, and when addressing it Linus Torvalds said there’s a slight performance hit from using them.

I would recommend a swap partition anyway.

4 Likes

Thank you… I went back to swap partition. I am old school and remember that swapfiles are relatively new. I will just carry on. I boot to gparted iso to do partition stuff anyways. So it is easy but just takes time.

1 Like

Where do you read that? After i did investigation few year’s ago… i saw that Swap Partition is recommend. Specially from Linus Torvald himself.

Ahh someone already mentioned this :sweat_smile:

3 Likes

Really the more modern perspective is neither.
zram requires no SWAP device and grows/shrinks as needed.
Its also faster than regular SWAP.
The main draw-back being you cant hibernate.

1 Like

I’m not very modern. :grin:

There’s also zswap which is enabled by default and can be backed by swap.

zswap - ArchWiki
zram - ArchWiki

1 Like

Yeah, but I dont actually suggest zswap.

They are different things.
zswap requires a SWAP device and is a compression cache for it.
zram requires no such backing and is compressed cache in ram.
( Do not use them together! )

zram still wins then on both counts - no extra partition or similar needed, and its faster. It also does not matter if you are using a slow spinning HD. In fact you probably get more gains the slower the host system.

1 Like

omfg… i just configured zram on my system and it is WAY faster. plasma has no lag at all… wtf is this thing? I have 64G mem and configured 16G zram for swap. I dont hibernate so i think i shouldnt have any issues. After reading the arch wiki on it, there doesnt seem to be a downside if you dont hibernate. Am i missing something?

1 Like

It can also incur an amount of extra cpu overhead. I consider this largely negligible on anything that isnt pretty crippled, and even then it may still be worth it. But ‘only siths deal in absolutes’ or something like that.

i have a 5950x with 16 cores/32 threads… cant even notice it.

You might want to update your User Profile, which says you have an AMD Ryzen 3950x CPU & are running a 5.7 kernel.

1 Like

You shouldn’t have a lag in plasma besides using swap.

Zram looks really interesting. But why isn’t that a option when installing Manjaro with Calamares?

It is technically impossible to cater for each and every possible combination.

Manjaro does adhere to the K.I.S.S. principle - there has been a huge cleanout in the repos and with avaialable profiles - I kind of like it that way - if you are not that technically minded you can still install Manjaro - if you technically minded you can tweak the underlying kernel to fit your needs.

I specifically did not mention desktop tweakin - we all have experiences showing it is only going downhill…

1 Like

End of 2022 I bought a thinkpad with 32 GB ram, wich brought me to the question, “do i even need swap?”.
The (short) answer was yes, some apps looking for swap, also your machine does.
After some search i found

$ pacman -Ss zram
extra/zram-generator 1.1.2-1 [Installiert]
    Systemd unit generator for zram devices
$ 

The majnaro-wiki doesn’t even mention it, but the arch-wiki does

You can, but don’t need to configure it, the defaults are sane. Only downside, no hibernation.
My conclusion: The more ram you have, the more sense zram makes.

2 Likes

corrected… thanks.

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