3

Due to a zram bug leading to machine lock-ups, I've had to disable zram.

I thought dpkg --purge zram-config as well as commenting any reference out of /etc/rc.local would do the trick, but the module (and its ominous dmesg warnings Buffer I/O error on device zram0, logical block 257912) keeps getting loaded.

I've grepped /etc/init and /etc/init.d for zram and there were no matches. I've even redefined mkswap to log how it was called (because the "buffer errors" occur when mkswap touches protected memory) -- amazingly I didn't get any calls. So I can't figure out what configures zram (calling mkswap + swapon).

I've taken to breaking the zram.ko to stop its loading. But I would still like to figure out what specific init script loads it. Any ideas?

Note that I'm looking for answers about how to track down which init or startup script configures zram -- I know very well that the bug might already be fixed, that you can disable zram in several ways etc, and such answers would be off-topic.

3
  • zRam is integrated into the kernel as of version 3.2 so I expect there not to be a startup service. Now if you installed the zram configuration tools manually (as described here: webupd8.org/2011/10/increased-performance-in-linux-with.html ) the service would be /etc/init.d/zramswap but that is not default.
    – Rinzwind
    Sep 17, 2013 at 7:10
  • mkswap and swapon /dev/zram0 are integrated in the kernel? I didn't know that was possible...
    – dan3
    Sep 17, 2013 at 7:15
  • Sure, but modprobing zram doesn't imply setting up zram. What is the zram disk size? Normally you set it up by writing to /sys/block/zram/size. Does the module also perform mkswap? I doubt it. Look, if I type modprobe zram then swapon /dev/zram0 I get an error, swapon: /dev/zram0: read swap header failed: Invalid argument. Which means the swap space isn't formatted. I suspect you might be confused.
    – dan3
    Sep 17, 2013 at 7:24

2 Answers 2

2

Try this (adapting the initrd location):

$ mkdir /tmp/x
$ cd /tmp/x
$ zcat /boot/initrd.img-3.8.0-31-generic | cpio -i
$ grep -lR zram .
./scripts/init-top/compcache
./lib/modules/3.8.0-31-generic/kernel/drivers/staging/zram/zram.ko
./lib/modules/3.8.0-31-generic/modules.dep
./lib/modules/3.8.0-31-generic/modules.dep.bin
./lib/modules/3.8.0-31-generic/modules.order
./sbin/compcache-enable
./etc/udev/rules.d/80-compcache.rules

The second last is the culprit, the last one shows the calling parameters. The script /etc/init/zram-config.conf wants to make one zram device per core, the one above is making a single one with 50%.

I can confirm that the last sector is bad in /dev/zram, probably an off-by-1 bug. A system with zram and the default settings will crash when it tries to use that sector. The options I see:

  1. Add swapoff /dev/zram0 to /etc/rc.local (Most basic).

  2. Blacklist zram (But will this unload it first? Because it's loaded in the initial ramdrive).

    Otherwise, if you want to use the zram, you must add -c to the relevant mkswap, and hope for the best, i.e., that everything works apart from the last sector. Reference: this post

  3. Add the -c to sbin/compcache-enable from inside the initrd image and repack (lost with kernel upgrades).

  4. Add -c to /etc/init/zram-config.conf. You also need a swapoff and rmmod before its modprobe, because the zram is already set when it runs, so setting the size will fail.

I chose 3 for now, but dmesg is still polluted with those Buffer I/O errors. I'll be watching for crashes, now at least I know where they come from.

1
  • I chose to rename zram.ko to zram.ko.givemeabreak :)
    – dan3
    Oct 1, 2013 at 15:39
-1

I prefer to have ZRAM off, since I already use a disk partition for swap. I'm on 13.10 on one machine and 12.0.4 on another.

I would suggest another possible change to /etc/init/zram-config.conf, to stop zram swaps completely. Assuming you're using the default Runlevel of 2, change the line:

start on runlevel [2345]

to

start on runlevel [345]

I've used the same trick on /etc/init/tty1.conf, to leave bootup console messages for view.r.

1
  • Didn't you read the first few lines of the post, where I complained that even purging zram-config didn't stop zram from loading? And it seems you don't understand the point of zram which can coexist with normal swap meaningfully.
    – dan3
    Jan 14, 2014 at 17:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .