Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

zram doesn't work anymore

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
Anard
Apprentice
Apprentice
User avatar
Posts: 270
Joined: Thu Oct 01, 2020 8:11 am

zram doesn't work anymore

  • Quote

Post by Anard » Sun May 26, 2024 11:18 am

Hi.

I configured a zram device which worked fine. But since a while, it doesn't anymore. Don't know why neither when it stopped to work...

Here is my config :

Code: Select all

$ cat /etc/conf.d/zram-init
# zram settings...

# load zram kernel module on start?
load_on_start=yes

# unload zram kernel module on stop?
unload_on_stop=yes

# Number of devices.
# This value is also passed to the kernel module on modprobe.
num_devices=1

# For each device, specify the following variables
# Omitting them is the same as specifying them as empty: It uses defaults
# type0, type1, ... are the variables for the types
# size0, size1, ... are the variables for the sizes (in MB)
# mlim0, mlim1, ... are the variables for the maximal uncompressed memory (MB)
# back0, back1, ... are the variables for the backup device
# maxs0, maxs1, ... are the variables for the maximal (parallel) streams
# algo0, algo1, ... are the variables for the compression algorithms
# flag0, flag1, ... are the variables for the flags
# labl0, labl1, ... are the variables for the label name (if you want some)
# uuid0, uuid1, ... are the variables for the UUID (if you want to force it)
# args0, args1, ... are the variables for additional arguments to zram-init
#                   (args0, args1, ... are eval'd, so quote correspondingly!)
# notr0, notr1, ... are the flags for "do not trim (discard)" (if nonempty)
# (set notr* to a nonempty value only for linux-3.14 or earlier or when you
# are prepared to waste a lot of memory for a possibly slight speed increase)
# The following are ignored for type swap but not for the other types:
# opts0, opts1, ... are the variables for the mount options
# mode0, mode1, ... are the variables for the directory mode
# owgr0, owgr1, ... are the variables for the directory owner:group
#
# If the size is 0 (or empty) the device is ignored by the script.
#
# Available types:
# "swap"  The device is initialized as a swap device.
#         The flags variable specifies the priority (16383 if empty).
#         Use "-" in the flags variable for the default priority (-1)
# "/..."  The device is mounted on /...
#         The flags variable specifies the type (ext2, ext4, or btrfs;
#         default is ext4)
# "-"     The filesystem (specified by flags as above) is created in
#         /dev/zram$NUM but not mounted
# Devices with other types are ignored by the script
#
# Only variables with numbers  0 ... num_devices-1  are used by the script.

# swap - 4G
type0=swap
#flag0=10000 # The default "16383" is fine for us
size0=4096
mlim0= # no hard memory limit
back0= # no backup device
notr0= # keep the default on linux-3.15 or newer
maxs0= # maximum number of parallel processes for this device
algo0=zstd # lz4 (since linux-4.18), lz4 (since linux-3.15), or lzo.
           # Size: zstd (best) > lzo > lz4. Speed: lz4 (best) > zstd > lzo
labl0=zram # the label name
uuid0= # Do not force UUID
args0= # we could e.g. have set args0="-L 'zram_swap'" instead of using labl0
I have no errors about it in dmesg.
But my zram doesn't really exists :

Code: Select all

$ swapon --show
NAME      TYPE      SIZE USED PRIO
/dev/sdc4 partition  15G   0B   -2

$ zramctl zram0
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd            0B   0B    0B    0B       4 
And it fails to restart :

Code: Select all

# LANG=en rc-service zram-init restart
 * WARNING: you are stopping a boot service
 * Remove zram0 swap                                                      [ !! ]
 * Unloading zram module...                                               [ ok ]
 * Loading zram module...                                                 [ ok ]
 * Swap->zram0
zramctl: /dev/zram0: failed to reset: Device or resource busy
zram-init: 
zramctl zram0 failed                                                      [ !! ]
Thanks for your help.
"iMack" : GA-H97M-D3H, Intel i7 4790, 24Go DDR3, Sapphire RX570 4Go, 2x SSD 256Go, HDD 500Go + Zpool 3x2To / Clover - macOS Mojave / Gentoo-Xfce
Top
stefantalpalaru
Tux's lil' helper
Tux's lil' helper
Posts: 76
Joined: Sun Jan 11, 2009 10:35 pm
Location: Italy
Contact:
Contact stefantalpalaru
Website

  • Quote

Post by stefantalpalaru » Sun May 26, 2024 5:12 pm

Try zswap instead of zram: https://wiki.gentoo.org/wiki/Zswap
Top
Anard
Apprentice
Apprentice
User avatar
Posts: 270
Joined: Thu Oct 01, 2020 8:11 am

  • Quote

Post by Anard » Mon May 27, 2024 5:22 am

I also use Zswap, this one works fine. But I also configured a Zram to help portage on large compilations and/or when a VM is started.
It worked for a long time, but I just discover it is now out.
Last edited by Anard on Mon May 27, 2024 8:26 am, edited 1 time in total.
"iMack" : GA-H97M-D3H, Intel i7 4790, 24Go DDR3, Sapphire RX570 4Go, 2x SSD 256Go, HDD 500Go + Zpool 3x2To / Clover - macOS Mojave / Gentoo-Xfce
Top
Zucca
Administrator
Administrator
User avatar
Posts: 4693
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Mon May 27, 2024 7:06 am

Code: Select all

zramctl: /dev/zram0: failed to reset: Device or resource busy
This bothers me.
Can you manually run zramctl to adjust the zram device parameters?
..: Zucca :..

Code: Select all

init=/sbin/openrc-init
-systemd -logind -elogind seatd
I am NaN! I am a man!
Top
Anard
Apprentice
Apprentice
User avatar
Posts: 270
Joined: Thu Oct 01, 2020 8:11 am

  • Quote

Post by Anard » Mon May 27, 2024 8:04 am

I tried zramctl --reset /dev/zram0 which didn't work but recreating zram seems to work :

Code: Select all

$ zramctl
$ zramctl zram0
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd            0B   0B    0B    0B       4 
$ zramctl -f
/dev/zram0
$ sudo zramctl /dev/zram0 --algorithm zstd --size 4G
$ zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd            4G   0B    0B    0B       4 
However, it doesn't appears in my swaps :

Code: Select all

$ swapon --show
NAME      TYPE      SIZE USED PRIO
/dev/sdc4 partition  15G   0B   -2
[EDIT]
OK, just need to activate it after zramctl creation :

Code: Select all

$ sudo mkswap /dev/zram0
Configure l'espace d'échange (swap) en version 1, taille = 4 GiB (4294963200 octets)
pas d'étiquette, UUID=f32685e9-26b5-4033-a0a7-cbdc6a0fabef
$ sudo swapon /dev/zram0
$ swapon
NAME       TYPE      SIZE USED PRIO
/dev/sdb4  partition  15G   0B   -2
/dev/zram0 partition   4G   0B   -3
"iMack" : GA-H97M-D3H, Intel i7 4790, 24Go DDR3, Sapphire RX570 4Go, 2x SSD 256Go, HDD 500Go + Zpool 3x2To / Clover - macOS Mojave / Gentoo-Xfce
Top
stefantalpalaru
Tux's lil' helper
Tux's lil' helper
Posts: 76
Joined: Sun Jan 11, 2009 10:35 pm
Location: Italy
Contact:
Contact stefantalpalaru
Website

  • Quote

Post by stefantalpalaru » Tue May 28, 2024 1:36 pm

Anard wrote:I also use Zswap, this one works fine.
Then you do not need Zram.
Top
Zucca
Administrator
Administrator
User avatar
Posts: 4693
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Wed May 29, 2024 9:32 am

stefantalpalaru wrote:Then you do not need Zram.
This does not solve the problem.

However using zswap in addition to zram as swap will complicate things.
Memory pages used by zram will not be swapped, so then if kernel wants to move some memory pages to swap
  • first zswap compresses the memory page in hopes it'll then fit into ram
  • if zswap has its limits full, then kernel moves the memory page into swap area
  • since that swap area is zram the memory page will be compressed by zram
... so in short, you'll be moving compressed swap pages from zswap to zram based swap. Obviously this causes a lot of overhead.
So you should choose to use only one.

Now to the problem:
Can you set up the zram-init to create a regular filesystem? Does it work?
Does anything appear to dmesg while zram-init fails to start up swap?
..: Zucca :..

Code: Select all

init=/sbin/openrc-init
-systemd -logind -elogind seatd
I am NaN! I am a man!
Top
viacheslavg
n00b
n00b
Posts: 27
Joined: Fri Sep 23, 2016 1:55 pm

  • Quote

Post by viacheslavg » Sun Feb 22, 2026 5:56 pm

I have similar problem.

On my side it seems like zram module needs more time to be loaded before zram-init start setting up swap. In /etc/init.d/zram-init script there is

Code: Select all

sleep 1
between modprobe and actual zram setup.
If I increase these sleep then issue gone.

Another option is to set

Code: Select all

# load zram kernel module on start?
load_on_start=no

# unload zram kernel module on stop?
unload_on_stop=no
in zram-init config and load module by adding it to /etc/modules-load.d. In this case I also have no issue.
Top
Post Reply

8 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic