There was a thread posted today in the Ubuntu forums about a bug in Ubuntu 9.04 Jaunty Jackalope that causes the keyboard to be set to a different layout during login. Since I few other folks came by to confirm that the bug is not just a one-off, I thought I’d post here the workaround that I devised, with the help of the bug reporter, of course.
Basically the user attempted to log in but the letters in the username/password box appeared in an Arabic alphabet instead of Latin (it was later revealed that it was the Afghanistan keyboard layout). Because the keyboards are mapped differently, merely typing in the username and password did not allow the user to log in. Note that another user reported that for them the letters appeared in Hebrew.
Here is the fix:
If you don’t already have a LiveCD, you will need to make one on another computer. It doesn’t have to be a jaunty CD, any old intrepid/hardy/etc CD will do. Boot into the LiveCD and bring up a terminal. You need to mount your root partition, but to do that you have to know what it is named. If you don’t, run:
sudo fdisk -l
The result you get will vary, but here’s what mine looks like:
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2dc2fb0c
Device Boot Start End Blocks Id System
/dev/sda1 * 1 18726 150416563+ 83 Linux
/dev/sda2 18727 19457 5871757+ 5 Extended
/dev/sda5 18727 19457 5871726 82 Linux swap / Solaris
In this case, my root partition is obviously sda1. So that’s the partition I’m going to mount.
sudo mount -t ext3 -o defaults /dev/sda1 mountpoint
Replace sda1 with the correct root partition for you, and mountpoint with an empty directory of your choosing to place the mounted files.
Now we have to edit the config file that sets your default keyboard layout when you login. That file is located at “/etc/default/console-setup”. Go to that file and find the exact filepath (it will vary depending on how you named your directory in the last step). Then go to your terminal:
sudo gedit filepath
This will open up the config file. Scroll down to the second to last paragraph. This is what mine says:
# The following variables describe your keyboard and can have the same
# values as the XkbModel, XkbLayout, XkbVariant and XkbOptions options
# in /etc/X11/xorg.conf.
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""
The bug reporter’s config, on the other hand, said this:
# The following variables describe your keyboard and can have the same
# values as the XkbModel, XkbLayout, XkbVariant and XkbOptions options
# in /etc/X11/xorg.conf.
XKBMODEL="pc105"
XKBLAYOUT="af"
XKBVARIANT=""
XKBOPTIONS=""
See the problem here? Replace whatever is written in XKBLAYOUT with “us” (or whatever keyboard layout you want) and save the file. Now you can reboot your computer, remove the LiveCD, and boot back into your hard drive! Hooray!!
The bug reporter is going to file a bug report over at Launchpad. I strongly suggest that if you have this problem too, you go and comment (when (s)he has posted it, I’ll report back here with a URL). The more people report the bug, the faster it gets fixed. In the meantime, with this workaround you should be able to at least access your hard drive. Whether it will continue to change your keyboard layout remains to be seen.
A quick thanks to Ubuntu user lizardbliz420 for being my guinea pig for this bug fix. The thread in its entirety can be found here.
Happy Clicking!
UPDATE
There is a bug report filed at launchpad here. It is rated high importance but as of 11 April still incomplete. If you are affected by this bug, please stop by and chime in.
Also, it appears that while this fix cures the login woes, there are still problems with using the console. To fix these, run:
sudo dpkg-reconfigure console-setup
and make sure that when it asks you about keyboard language you set it to “USA,” “UK,” or whatever is your desired keyboard layout.