Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:regataos
regataos-games
regataos-zram.sh
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File regataos-zram.sh of Package regataos-games
#!/bin/bash # # This script helps to decide the "vm.swappiness" value, # according to the size of the RAM memory available in the hardware, # so that the zRAM can have at least one block device compressed in the 1GB RAM. # Set the value of the "vm.swappiness" option and configure zram rules ram_size=$(free -g | grep Mem | awk '{print $2}') if [ $ram_size -le 8 ]; then sysctl vm.page-cluster=0 sysctl vm.dirty_ratio=10 sysctl vm.dirty_background_ratio=6 sysctl vm.vfs_cache_pressure=50 sysctl vm.admin_reserve_kbytes=1048576 sysctl vm.oom_kill_allocating_task=1 fi if [ $ram_size -le 1 ]; then sysctl vm.swappiness=100 /sbin/mkswap /dev/zram0 524288 /sbin/swapon -p 100 /dev/zram0 elif [ $ram_size -le 2 ]; then sysctl vm.swappiness=80 /sbin/mkswap /dev/zram0 1048576 /sbin/swapon -p 100 /dev/zram0 elif [ $ram_size -le 4 ]; then sysctl vm.swappiness=60 /sbin/mkswap /dev/zram0 1572864 /sbin/swapon -p 100 /dev/zram0 elif [ $ram_size -le 5 ]; then sysctl vm.swappiness=60 /sbin/mkswap /dev/zram0 2097152 /sbin/swapon -p 100 /dev/zram0 elif [ $ram_size -le 8 ]; then sysctl vm.swappiness=20 /sbin/mkswap /dev/zram0 4194304 /sbin/swapon -p 100 /dev/zram0 elif [ $ram_size -le 12 ]; then sysctl vm.swappiness=20 /sbin/mkswap /dev/zram0 4194304 /sbin/swapon -p 100 /dev/zram0 else sysctl vm.swappiness=20 /sbin/mkswap /dev/zram0 4194304 /sbin/swapon -p 100 /dev/zram0 fi # Configure ZSwap function createSwapFile() { mkdir -p "/swap" truncate -s 0 /swap/swapfile if [[ $(df -hT | grep ^/) == *"btrfs"* ]]; then chattr +C /swap/swapfile fi fallocate -l 4G /swap/swapfile chmod 0600 /swap/swapfile mkswap /swap/swapfile /sbin/swapon -p 10 /swap/swapfile } if test -e "/swap/swapfile"; then /sbin/swapoff /swap/swapfile rm -f "/swap/swapfile" createSwapFile elif test -e "/swapfile"; then /sbin/swapoff /swapfile rm -f "/swapfile" createSwapFile else createSwapFile fi sudo systemctl daemon-reload
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor