Closed iamarya2k24 closed 3 years ago
Ty for reporting this!
After pulling new changes it works as expected. Thanks for the quick fix @vilgotf.
❯ sudo systemctl status systemd-swap.service
● systemd-swap.service - Manage swap spaces on zram, files and partitions.
Loaded: loaded (/lib/systemd/system/systemd-swap.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2020-10-26 15:32:11 IST; 17s ago
Process: 2976 ExecStart=/usr/bin/systemd-swap start (code=exited, status=0/SUCCESS)
Main PID: 2976 (code=exited, status=0/SUCCESS)
Status: "Swap unit activation finished"
Oct 26 15:32:10 ubuntu systemd-swap[2976]: INFO: Removing files in /var/lib/systemd-swap/swapfc/...
Oct 26 15:32:11 ubuntu systemd-swap[2976]: INFO: Zswap: backup current configuration: start
Oct 26 15:32:11 ubuntu systemd-swap[2976]: INFO: Zswap: backup current configuration: complete
Oct 26 15:32:11 ubuntu systemd-swap[2976]: INFO: Zswap: set new parameters: start
Oct 26 15:32:11 ubuntu systemd-swap[2976]: INFO: Zswap: Enable: 1, Comp: zstd, Max pool %: 25, Zpool: z3fold
Oct 26 15:32:11 ubuntu systemd-swap[2976]: INFO: Zswap: set new parameters: complete
Oct 26 15:32:11 ubuntu systemd-swap[2976]: INFO: Writing destroy info...
Oct 26 15:32:11 ubuntu systemd-swap[2976]: INFO: swapD: pick up devices from systemd-gpt-auto-generator
Oct 26 15:32:11 ubuntu systemd-swap[2976]: INFO: swapD: searching swap devices
Oct 26 15:32:11 ubuntu systemd[1]: Started Manage swap spaces on zram, files and partitions..
@vilgotf I am facing an issue, service seems to run without error but I get no swap status nor zram status.
❯ free -m
total used free shared buff/cache available
Mem: 908 355 21 9 530 534
Swap: 0 0 0
❯ sudo systemctl status systemd-swap.service
● systemd-swap.service - Manage swap spaces on zram, files and partitions.
Loaded: loaded (/lib/systemd/system/systemd-swap.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2020-10-26 15:40:45 IST; 11min ago
Process: 1841 ExecStart=/usr/bin/systemd-swap start (code=exited, status=0/SUCCESS)
Main PID: 1841 (code=exited, status=0/SUCCESS)
Status: "Swap unit activation finished"
Oct 26 15:40:44 ubuntu systemd-swap[1841]: INFO: Removing files in /var/lib/systemd-swap/swapfc/...
Oct 26 15:40:44 ubuntu systemd-swap[1841]: INFO: Zswap: backup current configuration: start
Oct 26 15:40:44 ubuntu systemd-swap[1841]: INFO: Zswap: backup current configuration: complete
Oct 26 15:40:44 ubuntu systemd-swap[1841]: INFO: Zswap: set new parameters: start
Oct 26 15:40:44 ubuntu systemd-swap[1841]: INFO: Zswap: Enable: 1, Comp: zstd, Max pool %: 25, Zpool: z3fold
Oct 26 15:40:44 ubuntu systemd-swap[1841]: INFO: Zswap: set new parameters: complete
Oct 26 15:40:44 ubuntu systemd-swap[1841]: INFO: Writing destroy info...
Oct 26 15:40:44 ubuntu systemd-swap[1841]: INFO: swapD: pick up devices from systemd-gpt-auto-generator
Oct 26 15:40:45 ubuntu systemd-swap[1841]: INFO: swapD: searching swap devices
Oct 26 15:40:45 ubuntu systemd[1]: Started Manage swap spaces on zram, files and partitions..
❯ zramctl
~ ❯
If I use zram-tools package, I am able to get zram up and running without issues.
Whats the output of systemd-swap status
and your configuration file?
I am using default configuration file.
❯ sudo cat /etc/systemd/swap.conf
# This file is part of systemd-swap.
#
# Entries in this file show the systemd-swap defaults as
# specified in /usr/share/systemd-swap/swap-default.conf
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See swap.conf(5) and /usr/share/systemd-swap/swap-default.conf for details.
#zswap_enabled=1
#zswap_compressor=zstd
#zswap_max_pool_percent=25
#zswap_zpool=z3fold
#zram_enabled=0
#zram_size=$(( RAM_SIZE / 4 ))
#zram_count=${NCPU}
#zram_streams=${NCPU}
#zram_alg=zstd
#zram_prio=32767
#swapfc_enabled=0
#swapfc_force_use_loop=0
#swapfc_frequency=1
#swapfc_chunk_size=256M
#swapfc_max_count=32
#swapfc_min_count=0
#swapfc_free_ram_perc=35
#swapfc_free_swap_perc=15
#swapfc_remove_free_swap_perc=55
#swapfc_priority=50
#swapfc_path=/var/lib/systemd-swap/swapfc/
#swapfc_nocow=1
#swapfc_directio=1
#swapfc_force_preallocated=0
#swapd_auto_swapon=1
#swapd_prio=1024
################################################################################
# Defaults are optimized for general usage
################################################################################
################################################################################
# You can override any settings with files in:
# /etc/systemd/swap.conf.d/*.conf
################################################################################
################################################################################
# Zswap
#
# Kernel >= 3.11
# Zswap create compress cache between swap and memory to reduce IO
# https://www.kernel.org/doc/Documentation/vm/zswap.txt
zswap_enabled=1
zswap_compressor=zstd # lzo lz4 zstd lzo-rle lz4hc
zswap_max_pool_percent=25 # 1-99
zswap_zpool=z3fold # zbud z3fold (note z3fold requires kernel 4.8+)
################################################################################
# ZRam
#
# Kernel >= 3.15
# Zram compression streams count for additional information see:
# https://www.kernel.org/doc/Documentation/blockdev/zram.txt
zram_enabled=0
zram_size=$(( RAM_SIZE / 4 )) # This is 1/4 of ram size by default.
zram_count=${NCPU} # Device count (only for kernels < 4.8)
zram_streams=${NCPU} # Compress streams
zram_alg=zstd # See $zswap_compressor
zram_prio=32767 # 1 - 32767
################################################################################
# Swap File Chunked
# Allocate swap files dynamically
# For btrfs fallback to swapfile + loop will be used
# ex. Min swap size 256M, Max 32*256M
swapfc_enabled=0
swapfc_force_use_loop=0 # Force usage of swapfile + loop
swapfc_frequency=1 # How often to check free swap space in seconds
swapfc_chunk_size=256M # Size of swap chunk
swapfc_max_count=32 # Note: 32 is a kernel maximum
swapfc_min_count=0 # Minimum amount of chunks to preallocate
swapfc_free_ram_perc=35 # Add first chunk if free ram < 35%
swapfc_free_swap_perc=15 # Add new chunk if free swap < 15%
swapfc_remove_free_swap_perc=55 # Remove chunk if free swap > 55% && chunk count > 2
swapfc_priority=50 # Priority of swapfiles (decreasing by one for each swapfile).
swapfc_path=/var/lib/systemd-swap/swapfc/
# Only for swapfile + loop
swapfc_nocow=1 # Disable CoW on swapfile
swapfc_directio=1 # Use directio for loop dev
swapfc_force_preallocated=0 # Will preallocate created files
################################################################################
# Swap devices
# Find and auto swapon all available swap devices
swapd_auto_swapon=1
swapd_prio=1024
❯ sudo systemd-swap status
. compressor zstd
. enabled Y
. max_pool_percent 25
. same_filled_pages_enabled Y
. zpool z3fold
Zswap:
. . duplicate_entry 0
. . pool_limit_hit 0
. . pool_total_size 0
. . reject_alloc_fail 0
. . reject_compress_poor 0
. . reject_kmemcache_fail 0
. . reject_reclaim_fail 0
. . same_filled_pages 0
. . stored_pages 0
. . written_back_pages 0
. . compress_ratio 0%
swapD:
~ ❯
my fstab looks like this.
❯ cat /etc/fstab
LABEL=writable / ext4 defaults 0 0
LABEL=system-boot /boot/firmware vfat defaults 0 1
tmpfs /var/log tmpfs size=200M,defaults,noatime,mode=0755 0 0
tmpfs /var/cache/apt/archives tmpfs size=500M,defaults,noexec,nosuid,nodev,mode=0755 0 0
#tmpfs /var/spool/cups tmpfs size=100M,defaults,noatime,mode=0755 0 0
#tmpfs /var/spool/cups/tmp tmpfs defaults,noatime,mode=0755 0 0
Seems like your conf file is a mix of the new (top part) and the old (bottom part), I'd recommend removing the file and reinstalling the package (reinstalling the conf file).
Both zram and swapfc are disabled by default, so you need to enable them for things to work ;)
Because the output of systemd-swap status
doesn't mention zram nor swapfc means that they are disabled
Oh okay, got it.
Ok working now!
❯ sudo systemctl status systemd-swap.service
● systemd-swap.service - Manage swap spaces on zram, files and partitions.
Loaded: loaded (/lib/systemd/system/systemd-swap.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-10-26 16:09:13 IST; 40s ago
Main PID: 2771 (systemd-swap)
Status: "Monitoring memory status..."
Tasks: 1 (limit: 974)
CGroup: /system.slice/systemd-swap.service
└─2771 /usr/bin/python3 -u /usr/bin/systemd-swap start
Oct 26 16:09:07 ubuntu systemd-swap[2771]: INFO: Zram: not part of kernel, trying to find zram module
Oct 26 16:09:07 ubuntu systemd-swap[2771]: INFO: Zram: module successfully loaded
Oct 26 16:09:10 ubuntu systemd-swap[2771]: INFO: Zram: trying to initialize free device
Oct 26 16:09:10 ubuntu systemd-swap[2771]: INFO: Zram: initialized: /dev/zram0
Oct 26 16:09:13 ubuntu systemd-swap[2771]: INFO: Writing destroy info...
Oct 26 16:09:13 ubuntu systemd-swap[2771]: INFO: swapD: pick up devices from systemd-gpt-auto-generator
Oct 26 16:09:13 ubuntu systemd-swap[2771]: INFO: swapD: searching swap devices
Oct 26 16:09:13 ubuntu systemd-swap[2771]: INFO: swapFC: on-demand swap activation at >590 MiB memory usage
Oct 26 16:09:13 ubuntu systemd[1]: Started Manage swap spaces on zram, files and partitions..
Oct 26 16:09:14 ubuntu systemd-swap[2771]: INFO: swapFC: free ram: 3 < 35 - allocate chunk: 1
❯ zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd 227.1M 4K 57B 4K 4 [SWAP]
❯ free -m
total used free shared buff/cache available
Mem: 908 369 22 7 515 509
Swap: 483 15 467
My config
❯ sudo cat /etc/systemd/swap.conf
# This file is part of systemd-swap.
#
# Entries in this file show the systemd-swap defaults as
# specified in /usr/share/systemd-swap/swap-default.conf
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See swap.conf(5) and /usr/share/systemd-swap/swap-default.conf for details.
zswap_enabled=1
zswap_compressor=zstd
zswap_max_pool_percent=25
zswap_zpool=z3fold
zram_enabled=1
zram_size=$(( RAM_SIZE / 4 ))
zram_count=${NCPU}
zram_streams=${NCPU}
zram_alg=zstd
zram_prio=32767
swapfc_enabled=1
swapfc_force_use_loop=0
swapfc_frequency=1
swapfc_chunk_size=256M
swapfc_max_count=32
swapfc_min_count=0
swapfc_free_ram_perc=35
swapfc_free_swap_perc=15
swapfc_remove_free_swap_perc=55
swapfc_priority=50
swapfc_path=/var/lib/systemd-swap/swapfc/
swapfc_nocow=1
#swapfc_directio=1
#swapfc_force_preallocated=0
swapd_auto_swapon=1
swapd_prio=1024
System Info: