Commit 4231a974 authored by Mark Verlinde's avatar Mark Verlinde
Browse files

Bump to upstream 0.4

 - lz4 is suported on el8 x86-64
parent e84d4bc5
# The factor is the percentage of total system RAM to allocate to the ZRAM block device(s).
# The factor determines the ratio 1/n of RAM to allocate to the ZRAM block device, where FACTOR = n.
FACTOR=2
PRIORITY=1000
......@@ -2,36 +2,26 @@
#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
factor=$FACTOR
[ -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 multitreaded so we don't need to balance across CPUs
# ZRAM in recent kernels is multithreaded so we don't need to balance across CPUs
modprobe -q zram num_devices=1
# Lz4 is not supported on CentOS kernel for x86_64
arch=$(uname -m)
if [ "$arch" == "x86_64" ]; then
algorithm="lzo"
else
algorithm="lz4"
fi
# Create ZRAM with first device, lz4 algorithm
zramdev=$(zramctl --find --algorithm $algorithm --size ${zram_size}MB 2>&1)
zramdev=$(zramctl --find --algorithm lz4 --size ${zram_size}MB 2>&1)
# The above returns the device. Use it below
mkswap $zramdev
swapon $zramdev
swapon -p $priority $zramdev
# Investigate this and swapiness
# echo 0 > /proc/sys/vm/page-cluster
if [ $? -gt 0 ]; then
echo -e "\nError during $zramdev activation!\n"
exit 1
else
echo -e "\nActivated ZRAM swap device of ${zram_size} MB\n"
exit 0
fi
echo -e "\nActivated ZRAM swap device of ${zram_size} MB\n"
#!/bin/sh
for i in $(grep '^/dev/zram' /proc/swaps | awk '{ print $1 }'); do
swapoff "$i"
swapoff "$i" && zramctl --reset "$i"
done
if grep -q "^zram " /proc/modules; then
sleep 1
rmmod zram
fi
Name: zram
Version: 0.3
Version: 0.4
Release: 1%{?dist}
Summary: ZRAM for swap config and services for Fedora/NS7
Summary: ZRAM for swap config and services for Fedora
License: GPLv2+
# No upstream as it's Fedora/NS specific.
# No upstream as it's Fedora specific.
Source0: COPYING
Source1: zram.conf
Source2: zram-swap.service
......@@ -29,8 +29,8 @@ ZRAM as a swap device based on criteria such as available memory.
# None required
%install
install -d %{buildroot}%{_docdir}/%{name}/
install -pm 0644 %{SOURCE0} %{buildroot}%{_docdir}/%{name}/COPYING
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}/
......@@ -46,18 +46,18 @@ install -pm 0755 %{SOURCE4} %{buildroot}%{_sbindir}
%systemd_postun zram-swap.service
%files
%{_docdir}/%{name}/COPYING
%license COPYING
%config(noreplace) %{_sysconfdir}/%{name}.conf
%{_unitdir}/zram-swap.service
%{_sbindir}/zramstart
%{_sbindir}/zramstop
%changelog
* Fri Dec 14 2018 Mark Verlinde <mark.verlinde@gmail.com> 0.3-1
- Add CentOS7 x86_64 compat which lacks lz4 support (tk @gsanchietti)
* Wed Jun 26 2019 Peter Robinson <pbrobinson@fedoraproject.org> 0.4-1
- General improvements (Chris Murphy)
* Mon Oct 08 2018 Mark Verlinde <mark.verlinde@gmail.com> 0.2-2
- Rebuild for ns7, License moved to docdir
* Sat Nov 24 2018 Peter Robinson <pbrobinson@fedoraproject.org> 0.3-1
- Add support for swap priority
* Thu Jul 19 2018 Peter Robinson <pbrobinson@fedoraproject.org> 0.2-1
- Service ordering fixes, minor cleanup
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment