39 lines
1.3 KiB
Bash
39 lines
1.3 KiB
Bash
# Install using: sudo su -c "bash <(wget -qO- /url/to/vm-tweaks.sh)"
|
|
|
|
# Make sure script is ran as root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
exec sudo /bin/bash "$0" "$@"
|
|
fi
|
|
REALUSER=$(logname)
|
|
|
|
# Add floppy to modprobe blacklist
|
|
# https://askubuntu.com/questions/719058/blk-update-request-i-o-error-dev-fd0-sector-0
|
|
rmmod floppy > /dev/null 2>&1 && (
|
|
echo "Adding floppy to modprobe blacklist"
|
|
echo "blacklist floppy" | tee /etc/modprobe.d/blacklist-floppy.conf
|
|
dpkg-reconfigure initramfs-tools
|
|
)
|
|
|
|
# Add common devices to multipath blacklist
|
|
# https://askubuntu.com/questions/1242731/ubuntu-20-04-multipath-configuration
|
|
if [[ -f "/etc/multipath.conf" ]] && ! grep -q "blacklist" "/etc/multipath.conf"; then
|
|
echo Updating /etc/multipath.conf
|
|
cat <<EOT >> "/etc/multipath.conf"
|
|
blacklist {
|
|
devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st|sda)[0-9]*"
|
|
}
|
|
EOT
|
|
/etc/init.d/multipath-tools restart
|
|
fi
|
|
|
|
# Disable Cloud-init
|
|
if [ ! -f "/etc/cloud/cloud-init.disabled" ]; then
|
|
echo "Disabling cloud-init"
|
|
touch /etc/cloud/cloud-init.disabled
|
|
fi
|
|
|
|
# Fix: apt-get upgrade auto restart services
|
|
# https://askubuntu.com/questions/1367139/apt-get-upgrade-auto-restart-services
|
|
sed -i -e "s/#\$nrconf{restart} = 'i';/\$nrconf{restart} = 'a';/g" /etc/needrestart/needrestart.conf
|
|
|
|
echo 'Installation complete. You should reboot to apply changes.' |