X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=fai%2Fconfig%2Ffiles%2Fusr%2Fbin%2Fmyncq%2Fkd;h=255d6d17f7a875c9bf0eafa1a8112ac21a682767;hb=edb1a99660561c51aa5c7803d978284c7b423842;hp=e2b6494a4b7b8a5bc5219bc0540e2ffc6ccfe9ec;hpb=739efea3642e2f8a7a672c4600da152a27bedf1a;p=automated-distro-installer diff --git a/fai/config/files/usr/bin/myncq/kd b/fai/config/files/usr/bin/myncq/kd index e2b6494..255d6d1 100755 --- a/fai/config/files/usr/bin/myncq/kd +++ b/fai/config/files/usr/bin/myncq/kd @@ -7,18 +7,42 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${P [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" + +# todo: we should make this be a service which sets the /sys/ value +# before the mount target or something like that, because if you hot +# plug a drive in, its ata number will change on reboot, meaning you +# have to remember to run this again and then reboot again. + +# example from t8 kernel +# Sep 01 14:35:01 watson kernel: ata7.00: status: { DRDY } +# Sep 01 14:35:01 watson kernel: ata7.00: failed command: WRITE FPDMA QUEUED +# Sep 01 14:35:01 watson kernel: ata7.00: cmd 61/08:c0:b8:bf:ff/00:00:01:00:00/40 tag 24 ncq 4096 out + + # https://wiki.archlinux.org/index.php/Solid_state_drive#Resolving_NCQ_errors # evo-870 doesnt get along well with d16. # Dmesg gives us an ata number we could disable specifically on the command line, but I've had that number change on me between oses, so reenabling ncq +debug=false +if [[ $1 == debug ]]; then + debug=true +fi + upgrub=true if [[ $1 == no-upgrub ]]; then upgrub=false fi -byid=/dev/disk/by-id/ata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V +regex='^.*-part[0-9]*$' +for path in /dev/disk/by-id/ata-Samsung_SSD_870*; do + if [[ ! $path =~ $regex ]]; then + byid=$path + break + fi +done + if [[ ! -e $byid ]]; then - # not plugged in we assume + if $debug; then echo "samsung 870 not plugged in or not found"; fi exit 0 fi @@ -34,6 +58,10 @@ if [[ $depth != 0 ]]; then if grep -qF libata.force=noncq /proc/cmdline; then echo $0: warning, cant change queue_depth due to globally disabled ncq else + if $debug; then + echo "updating to 1 if not: cat /sys/block/$dev/device/queue_depth" + cat /sys/block/$dev/device/queue_depth + fi echo 1 >/sys/block/$dev/device/queue_depth fi fi @@ -45,7 +73,7 @@ ata=${ata%%/*} arg=libata.force=${ata}.00:noncq if ! grep "^GRUB_CMDLINE_LINUX_DEFAULT=.*[\" ]${arg//./\\.}[\" ]" /etc/default/grub; then - sed -ri "s/^GRUB_CMDLINE_LINUX_DEFAULT=\"(.*)/GRUB_CMDLINE_LINUX_DEFAULT=\"$arg \1/" /etc/default/grub + sed -ri "s/([\" ])libata.force=[^ ]+ */\1/g;s/^GRUB_CMDLINE_LINUX_DEFAULT=\"(.*)/GRUB_CMDLINE_LINUX_DEFAULT=\"$arg \1/" /etc/default/grub if $upgrub; then echo "$0: warning: grub updated. you may want to reboot" if type -P update-grub2 &>/dev/null; then