From 0287cf74a6a0356a1fe0aa48fd47333550bd82fb Mon Sep 17 00:00:00 2001 From: Tommy Date: Fri, 1 Dec 2023 19:42:32 -0700 Subject: [PATCH] Add real-ucode for Red Hat systems Signed-off-by: Tommy --- Fedora-Workstation-38.sh | 35 +++++++++++++++++++++++++++++++++++ RHEL-Server-9.sh | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/Fedora-Workstation-38.sh b/Fedora-Workstation-38.sh index f23b84b..fd3d725 100644 --- a/Fedora-Workstation-38.sh +++ b/Fedora-Workstation-38.sh @@ -136,4 +136,39 @@ sudo dnf -y install gnome-console git-core gnome-shell-extension-appindicator gn # Enable auto TRIM sudo systemctl enable fstrim.timer +### Differentiating bare metal and virtual installs + +# Installing tuned first here because virt-what is 1 of its dependencies anyways +sudo dnf install tuned -y + +virt_type=$(echo $(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 dnf remove tuned -y +else + sudo tuned-adm profile virtual-guest +fi + +# Setup real-ucode +if [ "$virt_type" = "" ]; then + sudo dnf install 'https://divested.dev/rpm/fedora/divested-release-20230406-2.noarch.rpm' + sudo sed -i 's/^metalink=.*/&?protocol=https/g' /etc/yum.repos.d/divested-release.repo + sudo dnf config-manager --save --setopt=divested.includepkgs=divested-release,real-ucode,microcode_ctl,amd-ucode-firmware + sudo dnf install real-ucode + sudo dracut -f +fi + ## The script is done. You can also remove gnome-terminal since gnome-console will replace it. diff --git a/RHEL-Server-9.sh b/RHEL-Server-9.sh index 8160f64..f764bfb 100644 --- a/RHEL-Server-9.sh +++ b/RHEL-Server-9.sh @@ -153,9 +153,39 @@ ExecStart=/usr/bin/fwupdmgr update' | tee /etc/systemd/system/fwupd-refresh.serv sudo systemctl daemon-reload sudo systemctl enable --now fwupd-refresh.timer -# Setup tuned -sudo dnf install tuned -y -sudo tuned-adm profile virtual-guest - # Enable fstrim.timer -sudo systemctl enable --now fstrim.timer \ No newline at end of file +sudo systemctl enable --now fstrim.timer + +### Differentiating bare metal and virtual installs + +# Installing tuned first here because virt-what is 1 of its dependencies anyways +sudo dnf install tuned -y + +virt_type=$(echo $(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 + sudo tuned-adm profile latency-performance +else + sudo tuned-adm profile virtual-guest +fi + +# Setup real-ucode +if [ "$virt_type" = "" ]; then + sudo dnf install 'https://divested.dev/rpm/fedora/divested-release-20230406-2.noarch.rpm' + sudo sed -i 's/^metalink=.*/&?protocol=https/g' /etc/yum.repos.d/divested-release.repo + sudo dnf config-manager --save --setopt=divested.includepkgs=divested-release,real-ucode,microcode_ctl,amd-ucode-firmware + sudo dnf install real-ucode + sudo dracut -f +fi \ No newline at end of file