clevo/sata-suspend-fixup: add

Signed-off-by: Maciej Pijanowski <maciej.pijanowski@3mdeb.com>
This commit is contained in:
Maciej Pijanowski
2022-11-06 18:17:10 +01:00
parent 739969fd58
commit 48391a9e68
2 changed files with 61 additions and 0 deletions
+49
View File
@@ -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
+12
View File
@@ -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