Update tweaking.sh

This commit is contained in:
jerry048 2023-02-28 14:53:06 +08:00
parent 0a2483d53f
commit bbee0103dd
1 changed files with 15 additions and 20 deletions

View File

@ -45,7 +45,7 @@ function Network_Other_Tweaking {
apt-get -qqy install net-tools apt-get -qqy install net-tools
ifconfig $interface txqueuelen 10000 ifconfig $interface txqueuelen 10000
sleep 1 sleep 1
#Other 2 #Increaseing the congestion windows
iproute=$(ip -o -4 route show to default) iproute=$(ip -o -4 route show to default)
ip route change $iproute initcwnd 25 initrwnd 25 ip route change $iproute initcwnd 25 initrwnd 25
} }
@ -57,35 +57,30 @@ function Scheduler_Tweaking {
normal_1; echo "Changing I/O Scheduler"; warn_2 normal_1; echo "Changing I/O Scheduler"; warn_2
i=1 i=1
drive=() drive=()
#List out all the available drives
disk=$(lsblk -nd --output NAME) disk=$(lsblk -nd --output NAME)
#Count the number of drives
diskno=$(echo $disk | awk '{print NF}') diskno=$(echo $disk | awk '{print NF}')
#Putting the device name in an array to loop through later
while [ $i -le $diskno ] while [ $i -le $diskno ]
do do
device=$(echo $disk | awk -v i=$i '{print $i}') device=$(echo $disk | awk -v i=$i '{print $i}')
drive+=($device) drive+=($device)
i=$(( $i + 1 )) i=$(( $i + 1 ))
done done
i=1 i=1 x=0
x=0 #Changing the scheduler per disk depending on whether they are HDD or SSD
disk_name=$(printf $(lsblk | grep -m1 'disk' | awk '{print $1}')) while [ $i -le $diskno ]
disktype=$(cat /sys/block/$disk_name/queue/rotational) do
if [ "${disktype}" == 0 ]; then diskname=$(eval echo ${drive["$x"]})
while [ $i -le $diskno ] disktype=$(cat /sys/block/$diskname/queue/rotational)
do if [ "${disktype}" == 0 ]; then
diskname=$(eval echo ${drive["$x"]})
echo kyber > /sys/block/$diskname/queue/scheduler echo kyber > /sys/block/$diskname/queue/scheduler
i=$(( $i + 1 )) else
x=$(( $x + 1 ))
done
else
while [ $i -le $diskno ]
do
diskname=$(eval echo ${drive["$x"]})
echo mq-deadline > /sys/block/$diskname/queue/scheduler echo mq-deadline > /sys/block/$diskname/queue/scheduler
i=$(( $i + 1 )) fi
x=$(( $x + 1 )) i=$(( $i + 1 )) x=$(( $x + 1 ))
done done
fi
} }