diff options
author | Dave Cobbley <david.j.cobbley@linux.intel.com> | 2018-08-14 20:05:37 +0300 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-08-23 04:26:31 +0300 |
commit | eb8dc40360f0cfef56fb6947cc817a547d6d9bc6 (patch) | |
tree | de291a73dc37168da6370e2cf16c347d1eba9df8 /meta-openembedded/meta-oe/recipes-extended/zram | |
parent | 9c3cf826d853102535ead04cebc2d6023eff3032 (diff) | |
download | openbmc-eb8dc40360f0cfef56fb6947cc817a547d6d9bc6.tar.xz |
[Subtree] Removing import-layers directory
As part of the move to subtrees, need to bring all the import layers
content to the top level.
Change-Id: I4a163d10898cbc6e11c27f776f60e1a470049d8f
Signed-off-by: Dave Cobbley <david.j.cobbley@linux.intel.com>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-openembedded/meta-oe/recipes-extended/zram')
3 files changed, 130 insertions, 0 deletions
diff --git a/meta-openembedded/meta-oe/recipes-extended/zram/zram/init b/meta-openembedded/meta-oe/recipes-extended/zram/zram/init new file mode 100644 index 000000000..a2c9c2123 --- /dev/null +++ b/meta-openembedded/meta-oe/recipes-extended/zram/zram/init @@ -0,0 +1,85 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: zram +# Required-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Increased Performance In Linux With zRam (Virtual Swap Compressed in RAM) +# Description: Adapted from systemd scripts at https://github.com/mystilleef/FedoraZram +# Included as part of antix-goodies package by anticapitalista <antiX@operamail.com> +# This script was written by tradetaxfree and is found at http://crunchbanglinux.org/forums/topic/15344/zram-a-good-idea/ +# Copy this script (as root) from /usr/local/bin to /etc/init.d and then #update-rc.d zram defaults +# After booting verify the module is loaded with: lsmod | grep zram +### END INIT INFO +set -e + +start() { + # get the number of CPUs + num_cpus=$(grep -c processor /proc/cpuinfo) + # if something goes wrong, assume we have 1 + [ "$num_cpus" != 0 ] || num_cpus=1 + + # set decremented number of CPUs + last_cpu=$((num_cpus - 1)) + + #default Factor % = 90 change this value here or create /etc/default/zram + FACTOR=90 + #& put the above single line in /etc/default/zram with the value you want + [ -f /etc/default/zram ] && . /etc/default/zram || true + factor=$FACTOR # percentage + + # get the amount of memory in the machine + memtotal=$(grep MemTotal /proc/meminfo | awk ' { print $2 } ') + mem_by_cpu=$(($memtotal/$num_cpus*$factor/100*1024)) + + # load dependency modules + modprobe zram num_devices=$num_cpus + echo "zram devices probed successfully" + + # initialize the devices + for i in $(seq 0 $last_cpu); do + echo 1 > /sys/block/zram$i/reset + echo $mem_by_cpu > /sys/block/zram$i/disksize + # Creating swap filesystems + mkswap /dev/zram$i + # Switch the swaps on + swapon -p 100 /dev/zram$i + done +} + +stop() { + # get the number of CPUs + num_cpus=$(grep -c processor /proc/cpuinfo) + + # set decremented number of CPUs + last_cpu=$((num_cpus - 1)) + + # Switching off swap + for i in $(seq 0 $last_cpu); do + if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then + swapoff /dev/zram$i + sleep 1 + fi + done + sleep 1 + rmmod zram +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + sleep 3 + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + RETVAL=1 +esac +exit $RETVAL diff --git a/meta-openembedded/meta-oe/recipes-extended/zram/zram/zram.service b/meta-openembedded/meta-oe/recipes-extended/zram/zram/zram.service new file mode 100644 index 000000000..4a19367d9 --- /dev/null +++ b/meta-openembedded/meta-oe/recipes-extended/zram/zram/zram.service @@ -0,0 +1,12 @@ +[Unit] +Description=Enable zram compressed in-memory swap. +After=multi-user.target + +[Service] +RemainAfterExit=yes +ExecStart=/usr/bin/zram-load.sh --load +ExecStop=/usr/bin/zram-load.sh --unload +Type=oneshot + +[Install] +WantedBy=multi-user.target diff --git a/meta-openembedded/meta-oe/recipes-extended/zram/zram_0.1.bb b/meta-openembedded/meta-oe/recipes-extended/zram/zram_0.1.bb new file mode 100644 index 000000000..dfd75e71c --- /dev/null +++ b/meta-openembedded/meta-oe/recipes-extended/zram/zram_0.1.bb @@ -0,0 +1,33 @@ +SUMMARY = "Linux zram compressed in-memory swap" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +inherit update-rc.d systemd + +RDEPENDS_${PN} = "util-linux-swaponoff kmod" +RRECOMMENDS_${PN} = "kernel-module-zram" + +PR = "r3" + +SRC_URI = " \ + file://init \ + file://zram.service \ +" + +do_install () { + # Sysvinit + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/zram + + install -d ${D}${systemd_unitdir}/system + install -m 0644 ${WORKDIR}/zram.service ${D}${systemd_unitdir}/system +} + +FILES_${PN} = "${sysconfdir}" +INITSCRIPT_NAME = "zram" +INITSCRIPT_PARAMS = "start 05 2 3 4 5 . stop 22 0 1 6 ." + +RPROVIDES_${PN} += "${PN}-systemd" +RREPLACES_${PN} += "${PN}-systemd" +RCONFLICTS_${PN} += "${PN}-systemd" +SYSTEMD_SERVICE_${PN} = "zram.service" |