From 0ce3e114d327bcca439256a7924ad7a7c247142d Mon Sep 17 00:00:00 2001 From: Tommy Date: Sat, 20 Jan 2024 00:04:03 -0700 Subject: [PATCH] Tuned for Ubuntu and Kali Signed-off-by: Tommy --- Kali-Linux.sh | 28 +++++++++++++++++++++++++++- Ubuntu-22.04-Desktop.sh | 24 +++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Kali-Linux.sh b/Kali-Linux.sh index 08fbc4b..f4f0e78 100644 --- a/Kali-Linux.sh +++ b/Kali-Linux.sh @@ -45,4 +45,30 @@ sudo chmod 644 /etc/sysctl.d/30_silent-kernel-printk.conf unpriv curl https://raw.githubusercontent.com/Kicksecure/security-misc/master/usr/lib/sysctl.d/30_security-misc_kexec-disable.conf | sudo tee /etc/sysctl.d/30_security-misc_kexec-disable.conf sudo chmod 644 /etc/sysctl.d/30_security-misc_kexec-disable.conf sudo sed -i 's/kernel.yama.ptrace_scope=2/kernel.yama.ptrace_scope=3/g' /etc/sysctl.d/990-security-misc.conf -sudo sysctl -p \ No newline at end of file +sudo sysctl -p + +# Installing tuned first here because virt-what is 1 of its dependencies anyways +sudo apt install tuned -y +virt_type=$(virt-what) +if [ "$virt_type" = '' ]; then + output 'Virtualization: Bare Metal.' +elif [ "$virt_type" = 'openvz lxc' ]; then + output 'Virtualization: OpenVZ 7.' +elif [ "$virt_type" = 'xen xen-hvm' ]; then + output 'Virtualization: Xen-HVM.' +elif [ "$virt_type" = 'xen xen-hvm aws' ]; then + output 'Virtualization: Xen-HVM on AWS.' +else + output "Virtualization: $virt_type." +fi + +# Setup tuned +if [ "$virt_type" = '' ]; then + # Don't know whether using tuned would be a good idea on a laptop, power-profiles-daemon should be handling performance tuning IMO. + sudo apt remove tuned -y +else + sudo tuned-adm profile virtual-guest +fi + +# Enable fstrim.timer +sudo systemctl enable --now fstrim.timer \ No newline at end of file diff --git a/Ubuntu-22.04-Desktop.sh b/Ubuntu-22.04-Desktop.sh index a335fc2..13f84ef 100644 --- a/Ubuntu-22.04-Desktop.sh +++ b/Ubuntu-22.04-Desktop.sh @@ -123,6 +123,28 @@ sudo nmcli general reload conf sudo hostnamectl hostname 'localhost' sudo hostnamectl --transient hostname '' -# Enable fstrim.timer +# Installing tuned first here because virt-what is 1 of its dependencies anyways sudo apt install tuned -y +virt_type=$(virt-what) +if [ "$virt_type" = '' ]; then + output 'Virtualization: Bare Metal.' +elif [ "$virt_type" = 'openvz lxc' ]; then + output 'Virtualization: OpenVZ 7.' +elif [ "$virt_type" = 'xen xen-hvm' ]; then + output 'Virtualization: Xen-HVM.' +elif [ "$virt_type" = 'xen xen-hvm aws' ]; then + output 'Virtualization: Xen-HVM on AWS.' +else + output "Virtualization: $virt_type." +fi + +# Setup tuned +if [ "$virt_type" = '' ]; then + # Don't know whether using tuned would be a good idea on a laptop, power-profiles-daemon should be handling performance tuning IMO. + sudo apt remove tuned -y +else + sudo tuned-adm profile virtual-guest +fi + +# Enable fstrim.timer sudo systemctl enable --now fstrim.timer \ No newline at end of file