Software & AppsOperating SystemLinux

How To Change GRUB Shell Keyboard Layout in Virtualbox?

Ubuntu 21

In this article, we will delve into the process of changing the GRUB shell keyboard layout in Virtualbox. This can be particularly useful if you’re using a non-US keyboard layout and need to interact with the GRUB shell. Let’s get started.

Quick Answer

To change the GRUB shell keyboard layout in Virtualbox, you need to generate a GRUB keyboard layout file, modify the GRUB configuration files, and update GRUB. Ensure you are using GRUB 2 and follow the step-by-step instructions provided in the post.

Checking Your GRUB Version

Before we begin, it’s crucial to ensure that you’re using GRUB 2. You can do this by running the following command in your terminal:

grub-install --version

This command will display the version of GRUB you’re currently using. If you’re using GRUB 2, you can proceed with the following steps.

Generating a GRUB Keyboard Layout File

The next step involves creating a keyboard layout file for GRUB. This can be done using the grub-kbdcomp command. Here’s an example:

sudo grub-kbdcomp -o /boot/grub/bepo.gkb fr

In the above command, -o is used to specify the output file, /boot/grub/bepo.gkb is the output file where the keyboard layout will be saved, and fr is the language code for the French keyboard layout. You can replace bepo with your preferred filename and fr with the appropriate language code for your desired layout. You can find the language codes in the /usr/share/X11/xkb/symbols/ directory.

Editing the GRUB Configuration File

The next step involves modifying the GRUB configuration file. You can open the /etc/default/grub file with root privileges and modify the following line:

GRUB_TERMINAL_INPUT="at_keyboard"

This line sets the terminal input to use the keyboard.

Editing the Custom GRUB Configuration File

After editing the GRUB configuration file, you need to edit the custom GRUB configuration file. Open the /etc/grub.d/40_custom file with root privileges and add the following lines:

#!/bin/sh
exec tail -n +3 $0

insmod keylayouts
keymap /boot/grub/bepo.gkb

The insmod keylayouts line loads the keylayouts module, and the keymap /boot/grub/bepo.gkb line sets the keyboard layout to the one you generated earlier.

Updating GRUB

Finally, you need to update GRUB to apply the changes. You can do this by running the following command:

sudo update-grub

This command updates GRUB and applies the changes you’ve made.

Important Notes

Please be aware that using the Shift key to display the GRUB menu may not work when using the terminal_input at_keyboard option. Ensure that the #GRUB_HIDDEN_TIMEOUT=0 line in the /etc/default/grub file is properly commented.

Also, note that this solution may not work on laptops or in certain other scenarios. If you encounter any issues, refer to the comments in the original context for additional insights and potential solutions.

Conclusion

Changing the GRUB shell keyboard layout in Virtualbox can be a bit complex, but with the right steps, it’s definitely doable. Just ensure you’re using GRUB 2, generate a GRUB keyboard layout file, modify the GRUB configuration files, and update GRUB. Remember to be cautious and back up any important data before making changes to your system configuration.

How can I check the version of GRUB I’m using?

You can check the version of GRUB by running the command grub-install --version in your terminal.

Can I change the keyboard layout in GRUB if I’m using a non-US keyboard?

Yes, you can change the keyboard layout in GRUB. By generating a GRUB keyboard layout file and modifying the GRUB configuration files, you can set the desired keyboard layout.

Where can I find the language codes for different keyboard layouts?

You can find the language codes for different keyboard layouts in the /usr/share/X11/xkb/symbols/ directory.

How do I modify the GRUB configuration file?

You can modify the GRUB configuration file by opening the /etc/default/grub file with root privileges and editing the GRUB_TERMINAL_INPUT line to specify the keyboard input.

What is the purpose of the custom GRUB configuration file?

The custom GRUB configuration file (/etc/grub.d/40_custom) is used to add additional configuration options. In this case, it is used to load the keylayouts module and set the desired keyboard layout.

How do I update GRUB to apply the changes?

To update GRUB and apply the changes, you can run the command sudo update-grub in your terminal.

Will using the `Shift` key to display the GRUB menu work with the modified keyboard layout?

Using the Shift key to display the GRUB menu may not work when using the terminal_input at_keyboard option. Ensure that the #GRUB_HIDDEN_TIMEOUT=0 line in the /etc/default/grub file is properly commented.

Can this solution work on laptops or in all scenarios?

This solution may not work on laptops or in certain other scenarios. If you encounter any issues, refer to the comments in the original context for additional insights and potential solutions.

Leave a Comment

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