remove GNU/Linux string from boot grub menu

I would like to remove the GNU/Linux part from grub boot menu too. That’s just too much and a distraction to mention it for each and every grub boot menu entry. Just too much text and not relevant to what the user is focusing on.

Related /etc/grub.d/10_linux code snippet:

if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
  OS=GNU/Linux
else
  case ${GRUB_DISTRIBUTOR} in
    Ubuntu|Kubuntu)
      OS="${GRUB_DISTRIBUTOR}"
      ;;
    *)
      OS="${GRUB_DISTRIBUTOR} GNU/Linux"
      ;;
  esac
  CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
fi

We’re either called Ubuntu or Kubuntu which is obviously not an option or string GNU/Linux gets injected into variable OS either way.

Translating that code snippet into human speech:

  • if GRUB_DISTRIBUTOR is unset, set OS to GNU/Linux
  • otherwise if GRUB_DISTRIBUTOR is set to Ubuntu or Kubuntu set OS to either of that
  • otherwise set OS to content of variable GRUB_DISTRIBUTOR and append GNU/Linux.

This would require an upstream patch. Change from:

Ubuntu|Kubuntu)

to

Ubuntu|Kubuntu|Whonix|Kicksecure)

or some other, more generic, non-hardcoded mechanism to be allowed to set variable OS.

(Discussion on Linux vs GNU/Linux see here from this post: remodeling/fixing whonix homepage ui - #7 by nurmagoz)

I’ve tried various stuff to remove GNU/Linux using a /etc/grub.d/ folder drop-in configuration script.

file /etc/grub.d/50_ungnu

sudo touch /etc/grub.d/50_ungnu
sudo chmod +x /etc/grub.d/50_ungnu


#!/bin/bash

set -x

cp /boot/grub/grub.cfg.new /boot/grub/grub.cfg.new.tmp
sed -i 's# GNU/Linux##g' /boot/grub/grub.cfg.new.tmp
cp /boot/grub/grub.cfg.new.tmp /boot/grub/grub.cfg.new

file /etc/grub.d/90_end

sudo touch /etc/grub.d/90_end
sudo chmod +x /etc/grub.d/90_end

#!/bin/bash

echo "### TEST"

But that adds some weird characters.

### BEGIN /etc/grub.d/50_ungnu ###
\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00### END /etc/grub.d/50_ungnu ###

### BEGIN /etc/grub.d/90_end ###
### TEST
### END /etc/grub.d/90_end ###

Alternatively

sed -i 's# GNU/Linux##g' /boot/grub/grub.cfg.new

But that breaks grub-mkconfig. The only thing that gets added.

### BEGIN /etc/grub.d/50_ungnu ###

Any files after it such as /etc/grub.d/90_end will not be properly processed anymore.

I guess that could be because /usr/sbin/grub-mkconfig is using:

exec > "${grub_cfg}.new"

Patching /boot/grub/grub.cfg would also be interesting to change (after above works) default menu entry Whonix to Whonix Persistent which would be useful for multiple boot modes for better security: persistent user | live user | persistent secureadmin | persistent superadmin | persistent recovery mode.

Any solution for above? Or any other hook that could be used to patch /boot/grub/grub.cfg?

Found a solution using an APT hook. Not an ideal solution but good enough.

https://github.com/Whonix/anon-base-files/blob/master/etc/apt/apt.conf.d/50grub-ungnu

https://github.com/Whonix/anon-base-files/blob/master/usr/lib/distro-base-files/grub-ungnu

(I was previously mistaken. DPkg::Post-Invoke runs once only at the end of APT. Not after each invocation of dpkg by APT.)

1 Like