Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
zram doesn't work anymore
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Anard
Apprentice
Apprentice


Joined: 01 Oct 2020
Posts: 226

PostPosted: Sun May 26, 2024 11:18 am    Post subject: zram doesn't work anymore Reply with quote

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:
$ 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:
$ 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:
# 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 i5 4460, 16Go DDR3, Intel HD4600, 2x SSD 256Go, HDD 500Go+2To / Clover - macOS Mojave / Gentoo-Xfce
"Portable" : HP 350G3, HDD 500Go / rEFInd - Xubuntu 20.04 / Windows 10
Back to top
View user's profile Send private message
stefantalpalaru
n00b
n00b


Joined: 11 Jan 2009
Posts: 28
Location: Italy

PostPosted: Sun May 26, 2024 5:12 pm    Post subject: Reply with quote

Try zswap instead of zram: https://wiki.gentoo.org/wiki/Zswap
Back to top
View user's profile Send private message
Anard
Apprentice
Apprentice


Joined: 01 Oct 2020
Posts: 226

PostPosted: Mon May 27, 2024 5:22 am    Post subject: Reply with quote

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.
_________________
"iMack" : GA-H97M-D3H, Intel i5 4460, 16Go DDR3, Intel HD4600, 2x SSD 256Go, HDD 500Go+2To / Clover - macOS Mojave / Gentoo-Xfce
"Portable" : HP 350G3, HDD 500Go / rEFInd - Xubuntu 20.04 / Windows 10


Last edited by Anard on Mon May 27, 2024 8:26 am; edited 1 time in total
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3412
Location: Rasi, Finland

PostPosted: Mon May 27, 2024 7:06 am    Post subject: Reply with quote

Code:
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 :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Anard
Apprentice
Apprentice


Joined: 01 Oct 2020
Posts: 226

PostPosted: Mon May 27, 2024 8:04 am    Post subject: Reply with quote

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

Code:
$ 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:
$ swapon --show
NAME      TYPE      SIZE USED PRIO
/dev/sdc4 partition  15G   0B   -2


[EDIT]
OK, just need to activate it after zramctl creation :
Code:

$ 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 i5 4460, 16Go DDR3, Intel HD4600, 2x SSD 256Go, HDD 500Go+2To / Clover - macOS Mojave / Gentoo-Xfce
"Portable" : HP 350G3, HDD 500Go / rEFInd - Xubuntu 20.04 / Windows 10
Back to top
View user's profile Send private message
stefantalpalaru
n00b
n00b


Joined: 11 Jan 2009
Posts: 28
Location: Italy

PostPosted: Tue May 28, 2024 1:36 pm    Post subject: Reply with quote

Anard wrote:
I also use Zswap, this one works fine.


Then you do not need Zram.
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3412
Location: Rasi, Finland

PostPosted: Wed May 29, 2024 9:32 am    Post subject: Reply with quote

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 :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum