User-Assigned Variables
Variables in the /etc/default/grub file are read and acted upon as needed. This allows users to add their own variables in a central location and then alter the GRUB 2 scripts to meet their needs. Keeping the user-defined variables within this file allows easier management of, and change to, those variables when desired. To add a variable, use the following format:
export <VARIABLE>
The following example would define a variable used to omit a specific Ubuntu partition from the menu:
Define and export the variable in /etc/default/grub :
export GRUB_EXCLUDE_PARTITION="/dev/sda1"
Establish the conditional in /etc/grub.d/30_os-prober in the 10_linux section:
if [ $GRUB_EXCLUDE_PARTITION = $LROOT ]; then
or
if [ ! $GRUB_EXCLUDE_PARTITION = $LROOT ]; then
Complete the conditional at the appropriate point in the script
Save the files and run sudo update-grub to incorporate the changes into the GRUB 2 menu.