mdomlop / systemd-zram

GNU General Public License v3.0
16 stars 3 forks source link

Outdated 3.14 Kernel methods copied from zram-config.0.5 #6

Open StuartIanNaylor opened 5 years ago

StuartIanNaylor commented 5 years ago

For some reason even though streams where added in 3.15 there are a plethora of copies and emulations of zram-config-0.1/0.5 out in the wild.

That package for most parts is broken and the first thing is there is never a check that zram devices already exist. So services like log2zram or zramdrive are just overwritten without check. Then it pointlessly creates devices based on cpu count whilst streams per core where added in 3.15 and is automatic per core, so just partitions into smaller less functional devices and as said pointlessly. Please read https://www.kernel.org/doc/Documentation/blockdev/zram.txt

I am trying to create awareness that the Ubuntu package that for some reason everybody seems to copy on the presumption it is correct is flawed on many levels and needs updating. mem-limit which was tacked on later is actually the only way sys-admins can control mem-usage and often its totally missing. Please have look at https://github.com/StuartIanNaylor/zram-swap-config hack and copy as you wish.

Always the simple check to see if zram already exists is missing and the hotplug system of zram never seems to be used.

if [ ! -d "/sys/class/zram-control" ]; then
            modprobe --verbose zram
            RAM_DEV='0'
else
            RAM_DEV=$(cat /sys/class/zram-control/hot_add)

Its that simple and always missing as the bad methods from zram-config-0.1/05 are copied blindly.

Mem_limit which for many sysadmins is extremely important is often missing not even employed and works purely by the guesswork of the virtual disk_size that in terms of memory usage can be 1:1 upwards to max compression ratio.

https://github.com/StuartIanNaylor/zram-swap-config

Swap is not the only use for zram as zram is a great kernel technology but without checks other services exist their drives just get overwritten and that is a broken method.

Check https://github.com/StuartIanNaylor/log2zram it wants to run early before journald so will get overwritten and logging to zram just like swaps for IoT/Maker devices to reduce block wear is extremely beneficial. Say if you have database or any folder that frequent writes occur then zram is a great addition. https://github.com/StuartIanNaylor/zramdrive

Swap is not the only use for zram and please check for other services as all it is, is the above few lines and zram is a hotadd / remove system and its pointless with todays kernels to be partitioning devices via cores. Read the kernel docs and don't copy Ubuntu blindly! https://www.kernel.org/doc/Documentation/blockdev/zram.txt

The main point of my post isn't my repo but due to how often the ubuntu packages gets blindly copied its crucial it gets updated and soon.

Also the move to zram from 'hdd' media of sd, nand or emmc means the default assumption of hdd in terms of swappiness and page-cluster need change to those more suited for the media employed. sysctl vm.page-cluster=${PAGE_CLUSTER} 0 sysctl vm.swappiness=${SWAPPINESS} 80

EdoaLive commented 5 years ago

For some reason even though streams where added in 3.15 there are a plethora of copies and emulations of zram-config-0.1/0.5 out in the wild.

Finally someone who knows something! Still I couldn't find a package in ubuntu or a deb that respects that. I know only (Gentoo's) zram-init (https://github.com/vaeth/zram-init/) which actually use streams and is able to use zram also for other things than swaps.

It would be happy to see a big merge of all this diffrent and partially outdated packages into a single one that is capable to do a very simple thing like managing swap (and others) on zram.

StuartIanNaylor commented 5 years ago

Yeah its really strange how many times its been copied without ref to https://www.kernel.org/doc/Documentation/blockdev/zram.txt I have been on my soapbox for a while now. Gentoo and Arch always seem to be far more in the know than the debian derivatives but even in AUR its just been copied whilst actually it quite broken if you check the bugs from the original Ubuntu script.