reconfigure zram to use zram-generator
This commit is contained in:
parent
7a2ca64d3c
commit
93d744a8f8
1 changed files with 21 additions and 7 deletions
|
@ -6,6 +6,12 @@ if [ $(whoami) == "root" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
sudo_remove_file_if_exists() {
|
||||
if [ -f $1 ]; then
|
||||
sudo rm $1
|
||||
fi
|
||||
}
|
||||
|
||||
# only fedora is up-to-date
|
||||
|
||||
command_exists() { type "$1" &>/dev/null; }
|
||||
|
@ -14,12 +20,20 @@ if command_exists "apt-get"; then
|
|||
sudo apt-get install kitty -y
|
||||
echo "Please install SchildiChat, nvim/neovim"
|
||||
elif command_exists "dnf"; then
|
||||
sudo dnf remove zram-generator -y
|
||||
echo 'zram' | sudo tee /etc/modules-load.d/zram.conf
|
||||
echo 'ACTION=="add", KERNEL=="zram0", ATTR{initstate}=="0", ATTR{comp_algorithm}="zstd", ATTR{disksize}="48G", RUN="/usr/bin/mkswap -U clear %N", TAG+="systemd"' | sudo tee /etc/udev/rules.d/99-zram.rules
|
||||
zram_fstab='/dev/zram0 none swap defaults,discard,pri=160 0 0'
|
||||
if ! grep -q "$zram_fstab" /etc/fstab; then
|
||||
echo "$zram_fstab" | sudo tee -a /etc/fstab
|
||||
# remove old zram stuff
|
||||
echo '' | sudo crontab -
|
||||
sudo_remove_file_if_exists /etc/modules-load.d/zram.conf
|
||||
sudo_remove_file_if_exists /etc/udev/rules.d/99-zram.rules
|
||||
sudo sed -i 's/\/dev\/zram0 none swap defaults,discard,pri=160 0 0//g' /etc/fstab
|
||||
|
||||
sudo dnf install zram-generator -y
|
||||
# set up zram
|
||||
if [ -f /usr/lib/systemd/zram-generator.conf ]; then
|
||||
sudo rm /usr/lib/systemd/zram-generator.conf
|
||||
fi
|
||||
echo '@reboot bash -c "mkswap -U clear /dev/zram0; swapon --discard --priority 160 /dev/zram0"' | sudo crontab -
|
||||
if ! [ -d /usr/local/lib/systemd ]; then
|
||||
sudo mkdir -p /usr/local/lib/systemd
|
||||
fi
|
||||
echo '[zram0]
|
||||
zram-size = ram * 3' | sudo tee /usr/local/lib/systemd/zram-generator.conf
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue