Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mark Verlinde
zram
Commits
4231a974
Commit
4231a974
authored
May 23, 2021
by
Mark Verlinde
Browse files
Bump to upstream 0.4
- lz4 is suported on el8 x86-64
parent
e84d4bc5
Changes
4
Hide whitespace changes
Inline
Side-by-side
SOURCES/zram.conf
View file @
4231a974
# 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
SOURCES/zramstart
View file @
4231a974
...
...
@@ -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 multit
h
readed 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
"
\n
Error during
$zramdev
activation!
\n
"
exit
1
else
echo
-e
"
\n
Activated ZRAM swap device of
${
zram_size
}
MB
\n
"
exit
0
fi
echo
-e
"
\n
Activated ZRAM swap device of
${
zram_size
}
MB
\n
"
SOURCES/zramstop
View file @
4231a974
#!/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
SPECS/zram.spec
View file @
4231a974
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}%{_d
oc
dir}/%{name}/
install -pm 0644 %{SOURCE0} %{buildroot}%{_d
oc
dir}/%{name}/COPYING
install -d %{buildroot}%{_d
ata
dir}/
licenses/
%{name}/
install -pm 0644 %{SOURCE0} %{buildroot}%{_d
ata
dir}/
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment