Playing a Tune At Boot With Grub

The grub bootloader can be configured to play a tune at boot.
This allows you to select different kernels or operating systems at boot without having to see
the grub menu. It is quite simple to make grub issue a single beep at boot time. To do this, perform the following steps:

  1. Edit the file /etc/default/grub. At the end there are lines like the following:
    # Uncomment to get a beep at grub start
    #GRUB_INIT_TUNE="480 440 1"

    Remove the hash sign from the beginning of the line that begins “#GRUB_INIT_TUNE”.
    Save the file and exit your text editor.

  2. Open a terminal window and issue the following command:
    sudoo update-grub
  3. Reboot. You should hear a single beep when the grub menu appears.

Using grub-init-tune

Making grub play a tune at boot time is somewhat more difficult. To make this
process easier, you can use a utility called

  1. Download the grub-init-tune script.
    chmod 0755 grub-init-tune
  2. The easiest way to start testing tunes is to uncomment one of the pre-defined tunes in
    the grub-init-tune script. To do this, open the script in a text editor and remove the hash sign from the beginning of the line for the tune you want to try. Save the file and
    exit your text editor. Then run the script again. It should play your selected tune
    and echo the configuration line to your screen.

    Another way to test a tune is to set the GRUB_INIT_TUNE environmental variable to the tune
    you wish to try. For example:

    export GRUB_INIT_TUNE="220 900 2 1000 2 800 2 400 2 600 3"

    This will play the theme from the movie “Close Encounters”.
    If you haven’t uncommented a line for a tune within the script or set the GRUB_INIT_TUNE environmental variable,
    the script plays the tune defined in /etc/default/grub (if any).

  3. Once you have settled on a tune, you can configure grub to play it at boot by saving it to the file /etc/default/grub.
    sudo grub-init-tune >> /etc/default/grub
    sudo update-grub
  4. More information on writing your own tunes can be found in the
    GNU GRUB Manual,
    specifically, the section on the
    play command.

Leave a Reply

Your email address will not be published. Required fields are marked *