mirror of
https://gitdl.cn/https://github.com/chakralinux/desktop.git
synced 2025-01-23 09:22:12 +08:00
fix zramswap
This commit is contained in:
parent
cc99d6f4af
commit
cfd668c7ea
@ -5,7 +5,7 @@
|
||||
|
||||
pkgname=zramswap
|
||||
pkgver=1.1
|
||||
pkgrel=1
|
||||
pkgrel=2
|
||||
pkgdesc="Sets up zram swap devices on boot."
|
||||
arch=('any')
|
||||
url="http://en.wikipedia.org/wiki/ZRam"
|
||||
@ -17,6 +17,6 @@ sha256sums=('f682f5199d72b38d37b7f92d84ce49bd9b1b3c7ff146507a08a3d602abde5f6f'
|
||||
'1d0a4ea2e48a3cd2aacdbfa5ddc4eea4abc43ad4fd3ff0e64cf40272f1adada6')
|
||||
|
||||
package() {
|
||||
install -Dm644 "${srcdir}/zramswap.service" "${pkgdir}/usr/lib/systemd/system/zramswap.service"
|
||||
install -Dm644 "${srcdir}/zramctrl" "${pkgdir}/etc/default/zramctrl"
|
||||
install -Dm755 zramctrl $pkgdir/usr/lib/systemd/scripts/zramctrl
|
||||
install -Dm644 zramswap.service $pkgdir/usr/lib/systemd/system/zramswap.service
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
# The factor is how much (from 0 to 100, percentage)
|
||||
# of system RAM to allocate to ZRAM block devices
|
||||
# Too big, and your system will start killing off processes
|
||||
FACTOR=90
|
@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Enable compressed swap in memory using zram
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/sbin/zramstart
|
||||
ExecStop=/usr/sbin/zramstop
|
||||
Type=oneshot
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
num_cpus=$(grep -c processor /proc/cpuinfo)
|
||||
[ "$num_cpus" != 0 ] || num_cpus=1
|
||||
|
||||
last_cpu=$((num_cpus - 1))
|
||||
FACTOR=90
|
||||
[ -f /etc/default/zram ] && source /etc/default/zram || true
|
||||
factor=$FACTOR # percentage
|
||||
|
||||
memtotal=$(grep MemTotal /proc/meminfo | awk ' { print $2 } ')
|
||||
mem_by_cpu=$(($memtotal/$num_cpus*$factor/100*1024))
|
||||
|
||||
modprobe -q zram num_devices=$num_cpus
|
||||
|
||||
for i in $(seq 0 $last_cpu); do
|
||||
echo $mem_by_cpu > /sys/block/zram$i/disksize
|
||||
mkswap /dev/zram$i
|
||||
swapon -p 100 /dev/zram$i
|
||||
done
|
@ -1,13 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
num_cpus=$(grep -c processor /proc/cpuinfo)
|
||||
[ "$num_cpus" != 0 ] || num_cpus=1
|
||||
|
||||
last_cpu=$((num_cpus - 1))
|
||||
|
||||
for i in $(seq 0 $last_cpu); do
|
||||
grep -q "/dev/zram$i" /proc/swaps && swapoff /dev/zram$i
|
||||
done
|
||||
|
||||
sleep 1
|
||||
rmmod zram
|
Loading…
Reference in New Issue
Block a user