#3 + zram-0.5-1 Turn zram into a configuration-only package to enable zram
Closed a year ago by pbrobinson. Opened a year ago by hadess.
Unknown source master  into  master

file added
+3
@@ -0,0 +1,3 @@

+ [zram0]

+ memory-limit = 9048

+ zram-fraction = 0.33

file removed
-14
@@ -1,14 +0,0 @@

- [Unit]

- Description=Enable compressed swap in memory using zram

- DefaultDependencies=no

- Before=swap.target

- 

- [Service]

- Type=oneshot

- RemainAfterExit=yes

- TimeoutStartSec=30sec

- ExecStart=/usr/sbin/zramstart

- ExecStop=/usr/sbin/zramstop

- 

- [Install]

- WantedBy=swap.target

file removed
-4
@@ -1,4 +0,0 @@

- # The factor determines the ratio 1/n of RAM to allocate to the ZRAM block device, where FACTOR = n.

- FACTOR=2

- 

- PRIORITY=1000

file modified
+12 -21
@@ -1,26 +1,23 @@

  Name:      zram

- Version:   0.4

+ Version:   0.5

  Release:   1%{?dist}

  Summary:   ZRAM for swap config and services for Fedora

  License:   GPLv2+

  

  # No upstream as it's Fedora specific.

  Source0:   COPYING

- Source1:   zram.conf

- Source2:   zram-swap.service

- Source3:   zramstart

- Source4:   zramstop

+ Source1:   zram-generator.conf

  

  BuildArch: noarch

  

  %{?systemd_requires}

  BuildRequires: systemd

- Requires: util-linux gawk grep

+ Requires: zram-generator

  

  %description

  ZRAM is a Linux block device that can be used for compressed swap in memory.

- It's useful in memory constrained devices. This provides a service to setup

- ZRAM as a swap device based on criteria such as available memory.

+ It's useful in memory constrained devices. This provides a default

+ configuration to setup ZRAM as a swap device based on available memory.

  

  %prep

  # None required
@@ -32,27 +29,21 @@

  install -d %{buildroot}%{_datadir}/licenses/%{name}/

  install -pm 0644 %{SOURCE0} %{buildroot}%{_datadir}/licenses/%{name}/COPYING

  

- install -d %{buildroot}%{_sysconfdir}/

- install -pm 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/

- 

- install -d %{buildroot}%{_unitdir}/

- install -pm 0644 %{SOURCE2} %{buildroot}%{_unitdir}/

- 

- install -d %{buildroot}%{_sbindir}

- install -pm 0755 %{SOURCE3} %{buildroot}%{_sbindir}

- install -pm 0755 %{SOURCE4} %{buildroot}%{_sbindir}

+ install -d %{buildroot}%{_sysconfdir}/systemd/

+ install -pm 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/systemd/

  

  %postun

  %systemd_postun zram-swap.service

  

  %files

  %license COPYING

- %config(noreplace) %{_sysconfdir}/%{name}.conf

- %{_unitdir}/zram-swap.service

- %{_sbindir}/zramstart

- %{_sbindir}/zramstop

+ %config(noreplace) %{_sysconfdir}/systemd/zram-generator.conf

  

  %changelog

+ * Mon Jul 22 2019 Bastien Nocera <bnocera@redhat.com> - 0.5-1

+ + zram-0.5-1

+ - Turn zram into a configuration-only package to enable zram

+ 

  * Wed Jun 26 2019 Peter Robinson <pbrobinson@fedoraproject.org> 0.4-1

  - General improvements (Chris Murphy)

  

file removed
-27
@@ -1,27 +0,0 @@

- #!/bin/bash

- #set -x

- # default factor of 1/3 of RAM

- factor=3

- # default priority is maximum priority

- priority=32767

- [ -f /etc/zram.conf ] && source /etc/zram.conf || true

- [ -z "$FACTOR" ] || factor=$FACTOR

- [ -z "$PRIORITY" ] || priority=$PRIORITY

- 

- # Calculate ZRAM size

- mem_total=$(free -w |grep "^Mem" |awk '{printf("%d",$2)}')

- zram_size=$((${mem_total} / ${factor} /1024))

- 

- # ZRAM in recent kernels is multithreaded so we don't need to balance across CPUs

- modprobe -q zram num_devices=1

- 

- # Create ZRAM with first device, lz4 algorithm

- zramdev=$(zramctl --find --algorithm lz4 --size ${zram_size}MB 2>&1)

- # The above returns the device. Use it below

- mkswap $zramdev

- swapon -p $priority $zramdev

- 

- # Investigate this and swapiness

- # echo 0 > /proc/sys/vm/page-cluster

- 

- echo -e "\nActivated ZRAM swap device of ${zram_size} MB\n"

file removed
-5
@@ -1,5 +0,0 @@

- #!/bin/sh

- 

- for i in $(grep '^/dev/zram' /proc/swaps | awk '{ print $1 }'); do

- 	swapoff "$i" && zramctl --reset "$i"

- done

no initial comment

I haven't been able to test this just yet, but it should also fix the brittleness of the bash script. The only thing left in the package would be a configuration file with approximately the same defaults as the old code.

I'll test this, and if it works, then I'll revert the "zram.service" enablement.

rebased onto 69d7a9c

a year ago

What brittleness? What issues have you seen? In the few releases we've been shipping this I've not had a single report of issues.

What brittleness? What issues have you seen? In the few releases we've been shipping this I've not had a single report of issues.

I literally filed a bug last week and talked to you about it:
https://bugzilla.redhat.com/show_bug.cgi?id=1731443

The code does no error checking right now, and will break if the state isn't exactly as it expects.

Though it's still better than the zram-generator that I'd want to depend on, which simply fails:
https://github.com/systemd/zram-generator/issues/4

I'll close this as zram-generator is just broken. Might reopen when it isn't.

Pull-Request has been closed by pbrobinson

a year ago