various fixes and improvements
[automated-distro-installer] / fai / config / scripts / GRUB_PC / 11-iank
index 8a9eab792b8ebd230366dae0b40df959de60ff2c..aaebc82a5593404759132ab4f278a2eaea3b7a5e 100755 (executable)
@@ -104,10 +104,29 @@ if [[ $FAI_ACTION != dirinstall ]] && ! ifclass NOCRYPT; then
     speed=115200
     cmdline="rd.luks.crypttab=no net.ifnames=0 console=ttyS0,${speed}n8 console=tty0"
     case $HOSTNAME in
-      # https://wiki.archlinux.org/index.php/Solid_state_drive#Resolving_NCQ_errors
-      # evo-870 doesnt get along well with d16 with etiona.
-      # the number is based on dmesg errors
-      kd) cmdline+=" libata.force=4.00:noncq" ;;
+      kd)
+        fcopy -v /usr/bin/myncq
+
+        cat >$target/etc/systemd/system/myncq.service <<'EOF'
+[Unit]
+Description=fix ncq errors
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/myncq
+TimeoutStartSec=20
+
+[Install]
+# https://www.enricozini.org/blog/2017/debian/systemd-07-devices/
+WantedBy=dev-disk-by\x2did-ata\x2dSamsung_SSD_870_QVO_8TB_S5VUNG0N900656V.device
+EOF
+
+  chroot $FAI_ROOT bash <<'EOFOUTER'
+systemctl enable myncq.service
+/usr/bin/myncq no-upgrub
+EOFOUTER
+
+          ;;
       # per rubens suggestion to make a d16 more stable
       kd|kw) cmdline+=" pci=realloc=off" ;;
     esac
@@ -132,7 +151,15 @@ EOF
   chroot $FAI_ROOT bash <<EOF
 set -eE -o pipefail
 # https://askubuntu.com/questions/33416/how-do-i-disable-the-boot-splash-screen-and-only-show-kernel-and-boot-text-inst
-# we remove quiet and splash, and all thats left is what we want
+
+sed -ri 's/(^GRUB_CMDLINE_LINUX_DEFAULT=")quiet/\1/;s/^(GRUB_CMDLINE_LINUX_DEFAULT=".*) quiet([ "])/\1\2/' /etc/default/grub
+sed -ri 's/(^GRUB_CMDLINE_LINUX_DEFAULT=")splash/\1/;s/^(GRUB_CMDLINE_LINUX_DEFAULT=".*) splash([ "])/\1\2/' /etc/default/grub
+
+for arg in $cmdline; do
+  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
+  fi
+done
 
 if grep -qF "$cmdline" /etc/default/grub; then
   # already set things, exit
@@ -144,7 +171,12 @@ sed -ri 's/^ *GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="$cmdline
 # warning about it in error.log
 sed -i '/^ *GRUB_HIDDEN_TIMEOUT/d' /etc/default/grub
 
-update-grub2
+if type -P update-grub2 &>/dev/null; then
+  update-grub2
+else
+  update-grub
+fi
+
 EOF
 fi ##### end != dirinstall && != NOCRYPT
 
@@ -249,7 +281,6 @@ iface eth0 inet6 static
 address 2600:3c00:e000:280::2/64
 EOF
   fi
-
 fi
 
 # I prefer to stick with ifup/down for now. a. networkd is not in its
@@ -263,15 +294,14 @@ EOF
 
 
 if ifclass VOL_BUSTER_BOOTSTRAP; then
-  fcopy -riM /etc/systemd/system
+  fcopy /etc/systemd/system/faicheck.service
   chroot $FAI_ROOT bash <<'EOFOUTER'
-systemctl enable fai_check.service
+systemctl enable faicheck.service
 EOFOUTER
   exit 0 # avoid unnecessary stuff in bootstrap vol
 fi
 
 
-
 ## misc settings
 chroot $FAI_ROOT bash <<'EOFOUTER'
 #### begin .ssh setup ###