You are on page 1of 4

Ubuntu Server 11.

10
How to change keyboard layout permanently

Foreword / Disclaimer Basics The problem A workaround (Step 0 - Preparation) Step 1 - Creating links Step 2 - Saving the keyboard-layout a. Reconfigure console-setup b. Do what reconfigure console-setup does Step 3 - Ignoring /etc/default/keyboard a. Empty /etc/default/keyboard b. Ignore the lines responsible for use the keyboard file Caveates Appendix / Sources

Foreword / Disclaimer
All information has been gathered from various sources and testing. Im not responsible for misinformation or destroying your system. Use the commands at your own risk. The sources are listed at the end of the document and I tip my hat to all those in the opensource community working to provide alternatives for everybody (with varying degrees of success) ! If you feel something is missing or this is incomplete, please do not hesitate to tell me so !

Basics
Among other things keyboard layouts are loaded at boot time (if so configured). First the kernels default keyboard layout is loaded and then the users keyboard layout is loaded using the loadkeymap program. Most keymaps are available in the console-data package which creates the /usr/share/keymaps folder containing quite a few keymaps / keyboard layouts. console-data (using dpkg-configure) and install-keymap (found in the data-common package) are the programs I found to change my keyboard layout. The both call loadkeymap and copy the keyboard layout file to /etc/console/boottime.kmap.gz , which was maybe once used to load the user-defined keyboard layout at boot-time.

The problem
Apparently after a few changes loading keyboard layouts isnt actually a unified process and (just like I did) you might end up only loading a keyboard layout temporarily / until the next reboot.

A workaround
If you havent done so yet install console-common which will install console-data as one of its dependencies. > sudo apt-get install console-common

(Step 0 - Preparation)

Find the keyboard layout you want to have. This can be done (if not already while installing console-common) by reconfiguring console-data. > sudo dpkg-reconfigure console-data

Step 1 - Creating links


console-setup sets up the console in a persistent manner, which includes keyboard layouts, so we will be using that feature. The only shortcoming of console-setup is that it completely ignores the keyboard layout selected by console-data and uses /etc/default/keyboard. In addition it keeps a cached copy of a keyboard map in /etc/console-setup/ . If you read the chapter Basics above you might also be about to do what I just did (and it work btw). 1. Delete the cached copy > sudo rm /etc/console-setup/cached.kmap.gz 2. Create a symbolic link to the file copied by dpkg-reconfigure common-data and install-keymap > sudo ln -s /etc/console/bottime.kmap.gz 3. Make console-setup ignore /etc/default/keyboard

Step 2 - Saving the keyboard-layout


We have two options here which in the end have the same result:

a. Reconfigure console-setup
> sudo dpkg-reconfigure console-setup

b. Do what reconfigure console-setup does


> sudo setupcon -v > sudo update-initramfs -k all -u

Step 3 - Ignoring /etc/default/keyboard


Once again there are two ways to do this. Reconfiguring console-setup wont work if /etc/default/keyboard doesnt exist so deleting it isnt an option ;)

a. Empty /etc/default/keyboard
Whatever commands you use it doesnt matter just empty it e.g > sudo echo > /etc/default/keyboard

b. Ignore the lines responsible for use the keyboard file

Again, how you do doesnt matter, but the culprit lines are in /etc/default/console-setup. if [ -f /etc/default/keyboard ]; then . /etc/default/keyboard fi Delete them, prepend them with an exit, do what you like.

Caveats
Using option a you never know which other programs rely on the file. Using option b reinstalling console-setup will reverse the changes you made. forcing you to do them again.

Appendix / Sources
https://bugs.launchpad.net/ubuntu/+source/console-common/+bug/198483 https://secure.wikimedia.org/wikipedia/en/wiki/Linux_console#Font.2C_character_set_and_keyb oard_layout

You might also like