Initial commit
This commit is contained in:
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
check_usb_port() {
|
||||
usb_path=$(udevadm info --query=path --name="$device")
|
||||
# Check the bus this USB device is on
|
||||
bus_num=$(echo "$usb_path" | grep -o 'usb[0-9]*' | grep -o '[0-9]*' | head -n1)
|
||||
# Read the speed from sysfs
|
||||
speed_file="/sys/bus/usb/devices/usb${bus_num}/speed"
|
||||
if [[ -f "$speed_file" ]]; then
|
||||
speed=$(cat "$speed_file")
|
||||
if [[ $speed -lt 1000 ]]; then
|
||||
spd-say -Cw "Warning. USB 2.0 detected. Please power off the Pi and move the USB drive to a USB 3 port for better performance."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# set performance
|
||||
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
|
||||
|
||||
# Find the USB bus speed for the boot drive
|
||||
device=$(findmnt / -o SOURCE -n | sed 's/[0-9]*$//')
|
||||
if [[ "$device" == /dev/sd* ]]; then
|
||||
check_usb_port
|
||||
fi
|
||||
|
||||
# File system trim
|
||||
rootPartition=$(findmnt / -o SOURCE -n)
|
||||
if [[ $(lsblk -b --discard $rootPartition | awk 'NR==2 { print $NF }') -gt 0 ]]; then
|
||||
if ! systemctl is-enabled fstrim.timer ; then
|
||||
sudo systemctl enable fstrim.timer
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user