Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log2ram doesn't play nice with zramswap (from zram-tools package) #241

Open
reukiodo opened this issue Feb 20, 2025 · 2 comments
Open

log2ram doesn't play nice with zramswap (from zram-tools package) #241

reukiodo opened this issue Feb 20, 2025 · 2 comments

Comments

@reukiodo
Copy link

It seems that both log2ram and zramswap (from the zram-tools package) want to use /dev/zram0, but log2ram service starts earlier in boot and claims it first, so after installing log2ram, zramswap service always fails.

@reukiodo
Copy link
Author

upon much deeper inspection into /usr/local/bin/log2ram I see:

create_zram_log_drive() {
    # Check Zram Class created
    if [ ! -d "/sys/class/zram-control" ]; then
        modprobe zram
        RAM_DEV='0'
    else
        RAM_DEV=$(cat /sys/class/zram-control/hot_add)
    fi
    echo "$COMP_ALG" >"/sys/block/zram${RAM_DEV}/comp_algorithm"
    echo "$LOG_DISK_SIZE" >"/sys/block/zram${RAM_DEV}/disksize"
    echo "$SIZE" >"/sys/block/zram${RAM_DEV}/mem_limit"
    mke2fs -t ext4 "/dev/zram${RAM_DEV}"
}

where in /usr/sbin/zramswap there is only:

readonly SWAP_DEV="/dev/zram0"

this seems to me that log2ram uses the first (zram0) when zram module hasn't been loaded (which is always the case at startup), and creates new zram devices afterwards (restarts?), where zramswap (which loads later at boot) seems to always assume that zram module has never been loaded and claims the first device - is this accurate?

if this is true, then maybe the real issue is in the zram-tools package, but that would need a change in the debian package

@reukiodo
Copy link
Author

in this case, I 'fixed' it by changing the code in /usr/sbin/zramswap to https://github.com/reukiodo/zram-tools/blob/master/zramswap.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant