mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2024-11-23 13:40:51 +07:00
sequentialio: add new
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
52e688cf9b
commit
72d764ef8b
110
sequentialio/all/usr/bin/sequentialio.sh
Executable file
110
sequentialio/all/usr/bin/sequentialio.sh
Executable file
@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and 007revad <https://github.com/007revad>
|
||||
#
|
||||
# This is free software, licensed under the MIT License.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
script="Sequential I/O SSD caches"
|
||||
color=no
|
||||
|
||||
# Check script is running as root
|
||||
if [[ $( whoami ) != "root" ]]; then
|
||||
echo -e "$script"
|
||||
echo -e "ERROR This script must be run as sudo or root!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Save options used
|
||||
args=("$@")
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
kb="0"
|
||||
elif [[ "$1" == "true" ]]; then
|
||||
kb="0"
|
||||
elif [[ "$1" == "false" ]]; then
|
||||
kb="1024"
|
||||
fi
|
||||
|
||||
# Show options used
|
||||
if [[ ${#args[@]} -gt "0" ]]; then
|
||||
echo "Using options: ${args[*]}"
|
||||
fi
|
||||
|
||||
|
||||
# Get list of volumes with caches
|
||||
cachelist=("$(sysctl dev | grep skip_seq_thresh_kb)")
|
||||
IFS=$'\n' caches=($(sort <<<"${cachelist[*]}")); unset IFS
|
||||
|
||||
|
||||
if [[ ${#caches[@]} -lt "1" ]]; then
|
||||
echo "No caches found!" && exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Get caches' current setting
|
||||
for c in "${caches[@]}"; do
|
||||
volume="$(echo "$c" | cut -d"+" -f2 | cut -d"." -f1)"
|
||||
kbs="$(echo "$c" | cut -d"=" -f2 | awk '{print $1}')"
|
||||
volumes+=("${volume}|$kbs")
|
||||
|
||||
sysctl_dev="$(echo "$c" | cut -d"." -f2 | awk '{print $1}')"
|
||||
sysctl_devs+=("$sysctl_dev")
|
||||
done
|
||||
|
||||
|
||||
# Show cache volumes and current setting
|
||||
if [[ ${#volumes[@]} -gt 0 ]]; then
|
||||
IFS="|" read -r cachevol setting <<< "${volumes}"
|
||||
cachevols=("$cachevol")
|
||||
fi
|
||||
|
||||
|
||||
for v in "${sysctl_devs[@]}"; do
|
||||
for c in "${cachevols[@]}"; do
|
||||
if [[ $v =~ "$c" ]]; then
|
||||
cachevol="$c"
|
||||
|
||||
# Get cache's key name
|
||||
cacheval="$(sysctl dev | grep skip_seq_thresh_kb | grep "$cachevol")"
|
||||
key="$(echo "$cacheval" | cut -d"=" -f1 | cut -d" " -f1)"
|
||||
|
||||
# Set new cache kb value
|
||||
val="$(synosetkeyvalue /etc/sysctl.conf "$key")"
|
||||
if [[ $val != "$kb" ]]; then
|
||||
synosetkeyvalue /etc/sysctl.conf "$key" "$kb"
|
||||
fi
|
||||
|
||||
if echo "$v" | grep "$cachevol" >/dev/null; then
|
||||
echo "$kb" > "/proc/sys/dev/${v}/skip_seq_thresh_kb"
|
||||
fi
|
||||
|
||||
# Check we set key value
|
||||
check="$(synogetkeyvalue /etc/sysctl.conf "$key")"
|
||||
if [[ "$check" == "0" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Green}Enabled${Off} in /etc/sysctl.conf"
|
||||
elif [[ "$check" == "1024" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Red}Disabled${Off} in /etc/sysctl.conf"
|
||||
elif [[ -z "$check" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Red}not set${Off} in /etc/sysctl.conf"
|
||||
else
|
||||
echo -e "Sequential I/O for $cachevol cache is set to ${Cyan}$check${Off} in /etc/sysctl.conf"
|
||||
fi
|
||||
|
||||
# Check we set proc/sys/dev
|
||||
val="$(cat /proc/sys/dev/"${v}"/skip_seq_thresh_kb)"
|
||||
if [[ "$val" == "0" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Green}Enabled${Off} in /proc/sys/dev\n"
|
||||
elif [[ "$val" == "1024" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Red}Disabled${Off} in /proc/sys/dev\n"
|
||||
elif [[ -z "$val" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Red}not set${Off} in /proc/sys/dev\n"
|
||||
else
|
||||
echo -e "Sequential I/O for $cachevol cache is set to ${Cyan}$val${Off} in /proc/sys/dev\n"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
exit 0
|
41
sequentialio/install.sh
Executable file
41
sequentialio/install.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env ash
|
||||
#
|
||||
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304>
|
||||
#
|
||||
# This is free software, licensed under the MIT License.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
if [ "${1}" = "late" ]; then
|
||||
echo "Installing addon sequentialio - ${1}"
|
||||
mkdir -p "/tmpRoot/usr/arc/addons/"
|
||||
cp -vf "${0}" "/tmpRoot/usr/arc/addons/"
|
||||
|
||||
cp -vf /usr/bin/sequentialio.sh /tmpRoot/usr/bin/sequentialio.sh
|
||||
|
||||
mkdir -p "/tmpRoot/usr/lib/systemd/system"
|
||||
DEST="/tmpRoot/usr/lib/systemd/system/sequentialio.service"
|
||||
echo "[Unit]" >${DEST}
|
||||
echo "Description=Sequential I/O SSD caches" >>${DEST}
|
||||
echo "After=multi-user.target" >>${DEST}
|
||||
echo >>${DEST}
|
||||
echo "[Service]" >>${DEST}
|
||||
echo "Type=oneshot" >>${DEST}
|
||||
echo "RemainAfterExit=yes" >>${DEST}
|
||||
echo "ExecStart=/usr/bin/sequentialio.sh $@" >>${DEST}
|
||||
echo >>${DEST}
|
||||
echo "[Install]" >>${DEST}
|
||||
echo "WantedBy=multi-user.target" >>${DEST}
|
||||
|
||||
mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants
|
||||
ln -vsf /usr/lib/systemd/system/sequentialio.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/sequentialio.service
|
||||
elif [ "${1}" = "uninstall" ]; then
|
||||
echo "Installing addon sequentialio - ${1}"
|
||||
|
||||
rm -f "/tmpRoot/usr/lib/systemd/system/multi-user.target.wants/sequentialio.service"
|
||||
rm -f "/tmpRoot/usr/lib/systemd/system/sequentialio.service"
|
||||
|
||||
[ ! -f "/tmpRoot/usr/arc/revert.sh" ] && echo '#!/usr/bin/env bash' >/tmpRoot/usr/arc/revert.sh && chmod +x /tmpRoot/usr/arc/revert.sh
|
||||
echo "/usr/bin/sequentialio.sh --restore" >> /tmpRoot/usr/arc/revert.sh
|
||||
echo "rm -f /usr/bin/sequentialio.sh" >> /tmpRoot/usr/arc/revert.sh
|
||||
fi
|
19
sequentialio/manifest.yml
Normal file
19
sequentialio/manifest.yml
Normal file
@ -0,0 +1,19 @@
|
||||
version: 1
|
||||
name: sequentialio
|
||||
description: "Enables sequential I/O for your SSD caches (Can cause overheating)"
|
||||
system: false
|
||||
beta: false
|
||||
all:
|
||||
install-script: "install.sh"
|
||||
copy: "all"
|
||||
apollolake: true
|
||||
broadwell: true
|
||||
broadwellnk: true
|
||||
broadwellnkv2: true
|
||||
broadwellntbap: true
|
||||
denverton: true
|
||||
geminilake: true
|
||||
purley: true
|
||||
v1000: true
|
||||
r1000: true
|
||||
epyc7002: true
|
Loading…
Reference in New Issue
Block a user