diff --git a/clevo/sata-suspend-fixup b/clevo/sata-suspend-fixup new file mode 100755 index 0000000..97205f9 --- /dev/null +++ b/clevo/sata-suspend-fixup @@ -0,0 +1,49 @@ +#!/bin/bash + +# A script to install a service that enables SATA link power management on +# each boot. +# Enables suspend mode while a SATA SSD is attached to the system. + +# Location to the script that shall be executed on each boot. +SCRIPT="/usr/local/bin/enable_dipm.sh" +SERVICE="/etc/systemd/system/enable_dipm.service" + +if [ "$EUID" -ne 0 ] + then echo "This script needs to be executed as root." + exit +fi + +echo "#!/bin/bash + +SCSI_HOST=/sys/class/scsi_host + +if [ ! -d \$SCSI_HOST ]; then + exit +fi + +if [ -z '\$(ls -A \$SCSI_HOST)' ]; then + exit +fi + +for host in \$SCSI_HOST/host*; do + echo 'med_power_with_dipm' > \$host/link_power_management_policy +done +" > $SCRIPT + +chmod +x $SCRIPT + +echo " +[Unit] +Description=Enable SATA DIPM +After=multi-user.target + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/enable_dipm.sh + +[Install] +WantedBy=multi-user.target +" > $SERVICE + +systemctl daemon-reload +systemctl enable --now enable_dipm.service diff --git a/clevo/sata-suspend-fixup.bat b/clevo/sata-suspend-fixup.bat new file mode 100644 index 0000000..fd70670 --- /dev/null +++ b/clevo/sata-suspend-fixup.bat @@ -0,0 +1,12 @@ +@echo off + +echo Enabling SATA HIPM + DIPM mode... + +for /f "tokens=4 skip=1" %%f in ('powercfg -list ^| findstr \*') do set GUID=%%f + +powercfg /setacvalueindex %GUID% 0012ee47-9041-4b5d-9b77-535fba8b1442 0b2d69d7-a2a1-449c-9680-f91c70521c60 2 +powercfg /setdcvalueindex %GUID% 0012ee47-9041-4b5d-9b77-535fba8b1442 0b2d69d7-a2a1-449c-9680-f91c70521c60 2 + +echo Enabled successfully. Suspend mode should now be fully functional. + +pause