bazzite/system_files/desktop/shared/usr/bin/bazzite-hardware-setup

87 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
source /etc/default/bazzite
# GLOBAL
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
KARGS=$(rpm-ostree kargs)
NEEDED_KARGS=""
echo "Current kargs: $KARGS"
# FSTAB CONFIGURATION
if [[ $(grep "compress=zstd" /etc/fstab) ]]; then
echo "Applying fstab param adjustments"
sed -i 's/compress=zstd:1/noatime,lazytime,commit=120,compress-force=zstd:1,space_cache=v2,discard=async/g' /etc/fstab
if grep -q '64GB' <<< $(lsblk -o MODEL); then
echo "Increasing compression for detected 64GB eMMC"
sed -i 's/compress-force=zstd:1/compress-force=zstd:3/g' /etc/fstab
fi
else
echo "No fstab param adjustments needed"
fi
# DECK KERNEL ARGUMENTS
if [[ ":Jupiter:" =~ ":$SYS_ID:" ]]; then
echo "Checking for needed karg changes (Jupiter)"
if [[ ! $KARGS =~ "amd_pstate" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=amd_pstate=active"
fi
if [[ ! $KARGS =~ "amd_iommu" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=amd_iommu=off"
fi
if [[ ! $KARGS =~ "amdgpu.gttsize" ]]; then
if [[ "$(awk '/MemTotal/{print $(NF-1)}' /proc/meminfo)" = "31664740" ]]; then
echo "32GB Steam Deck detected"
NEEDED_KARGS="$NEEDED_KARGS --append=amdgpu.gttsize=16256"
else
NEEDED_KARGS="$NEEDED_KARGS --append=amdgpu.gttsize=8128"
fi
fi
if [[ ! $KARGS =~ "spi_amd.speed_dev" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=spi_amd.speed_dev=1"
fi
if [[ ! $KARGS =~ "audit" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=audit=0"
fi
if [[ ! $KARGS =~ "initcall_blacklist" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=initcall_blacklist=simpledrm_platform_driver_init"
fi
fi
if [[ $IMAGE_NAME =~ "nvidia" ]]; then
echo "Checking for needed karg changes (Nvidia)"
if [[ ! $KARGS =~ "rd.driver.blacklist" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=rd.driver.blacklist=nouveau"
fi
if [[ ! $KARGS =~ "modprobe.blacklist" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=modprobe.blacklist=nouveau"
fi
if [[ ! $KARGS =~ "nvidia-drm.modeset" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=nvidia-drm.modeset=1"
fi
fi
if [[ $KARGS =~ "nomodeset" ]]; then
echo "Removing nomodeset"
NEEDED_KARGS="$NEEDED_KARGS --delete=nomodeset"
fi
if [[ ! $KARGS =~ "rd.luks.options" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=rd.luks.options=discard"
fi
if [[ ! -z "$NEEDED_KARGS" ]]; then
echo "Found needed karg changes, applying the following: $NEEDED_KARGS"
rpm-ostree kargs ${NEEDED_KARGS} --reboot
else
echo "No karg changes needed"
fi