When you install a fresh linux distribution the default keyboard layout is set to En-en. If you need to reconfigure you keyboard settings then follow these steps.

Stop wasting your time trying to find the underscore or the slash button!

userk@dopamine:/$ sudo dpkg-reconfigure keyboard-configuration

This ncurses window will show up. Select your keyboard model. The default option should be ok.

Next select your keyboard layout according to your country.

If you want, you can modify the key for the AltGr function.

Then the package configuration asks you to use the Ctrl+Alt+Backspace to terminate the X server.

Ok, reboot your system and check whether the new configuration is correct.

Keyboard set up with a minimal Linux distribution

This method requires a computer with the correct keyboard layout, let's call it PC-A. It is based on the loadkmap command (from busybox) which loads a keyboard translation table from a file. We first need to store in a .kmap file the informations related to the keyboard layout we want to use.

From PC-A, save the current keyboard layout.

userk@dopamine:/$ cd
userk@dopamine:~$ busybox | grep kmap
	dos2unix, dpkg, dpkg-deb, du, dumpkmap, dumpleases, echo, ed, egrep,
	loadfont, loadkmap, logger, login, logname, logread, losetup, ls,
userk@dopamine:~$ sudo busybox dumpkmap > qwerty_it.kmap
userk@dopamine:~$ ls | grep .kmap

Mount your filesystem in PC-A. If you have an SD card with the linux distribution installed, insert it. It will be mounted in /media. Copy the .kmap file in /etc folder of your target device.

userk@dopamine:~$ sudo cp qwerty_it.kmap /media/$USER/RootFileSystem/etc/

Now we just need to load the .kmap file at startup by editing in your target device the /etc/init.d/rcS file.

userk@dopamine:~$ sudo nano media/$USER/RootFileSystem/etc/init.d/rcS

And add the following line.

loadkmap < /etc/qwerty_it.kmap

Ok, start the target device and check if the keyboard has been correctly configured.