Bug 1033250 - The keyboard layout for the virtual console cannot be changed using “localectl set-keymap <map>; dracut -f; reboot;”
Summary: The keyboard layout for the virtual console cannot be changed using “localect...
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: dracut
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: dracut-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords:
Depends On: 1035316
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-21 19:02 UTC by Mike FABIAN
Modified: 2014-01-22 10:57 UTC (History)
8 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2014-01-22 10:57:15 UTC


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Bugzilla 875567 None None None Never

Internal Trackers: 875567

Description Mike FABIAN 2013-11-21 19:02:55 UTC
See also: https://bugzilla.redhat.com/show_bug.cgi?id=1028207#c73

Tested on Fedora-20-TC2-x86_64-netinst.

After installation using one keyboard layout, try changing 
to a different keyboard layout for the virtual console by executing:

   “localectl set-keymap <new-map>; dracut -f; reboot;”

“localectl set-keymap <new-map>” writes the map into
/etc/vconsole.conf as KEYMAP=<new-map>.

After “dracut -f”, the etc/vconsole.conf in initramfs also contains
KEYMAP=<new-map>. The keymap for <old-map> will then have
been removed from usr/lib/kbd/keymaps/ in initramfs and the new keymap
<new-map> will be there instead.

But the /boot/grub/grub.cfg file still contains
“vconsole.keymap=<old-map>” on the kernel command line.

So during reboot, systemd-vconsole-setup reads the keymap from the
etc/vconsole.conf in initramfs, which is <new-map> and then
passes it to loadkeys. But loadkeys fails because only <old-map>
is in usr/lib/kbd/keymaps in initramfs.

Therefore, the new keyboard layout is not applied after a reboot.

Comment 1 Mike FABIAN 2013-11-21 19:20:54 UTC
In the “Send key” menu of remote-viewer, there is

Ctrl+Alt+F1
Ctrl+Alt+F2
...

Clicking “Ctrl+Alt+F2” should switch the guest
to the virtual console, shouldn’t it?

But it does not, it only inserts 

   ;5Q

into the gnome-terminal I see in the guest.

Comment 2 Mike FABIAN 2013-11-21 19:22:43 UTC
(In reply to Mike FABIAN from comment #1)
> In the “Send key” menu of remote-viewer, there is

Sorry, I pasted that into the wrong window ☹. It was intended for bug#1033262

Comment 3 Adam Williamson 2013-11-21 19:48:48 UTC
Mike points out that https://bugzilla.redhat.com/show_bug.cgi?id=875567 explains why we write the layout to cmdline at all, but I'm not sure it was really the right fix for that bug. Presumably, if we keep this system of having the layout specified in cmdline, we'd have to make localed change grub.cfg when it changes the keyboard layout, which seems messy.

Comment 4 Mike FABIAN 2013-11-25 12:48:24 UTC
(In reply to Mike FABIAN from comment #0)
> See also: https://bugzilla.redhat.com/show_bug.cgi?id=1028207#c73
> 
> So during reboot, systemd-vconsole-setup reads the keymap from the
> etc/vconsole.conf in initramfs, which is <new-map> and then
> passes it to loadkeys. But loadkeys fails because only <old-map>
> is in usr/lib/kbd/keymaps in initramfs.

Looks like I was confused while writing that. Trying again:

The vconsole.keymap=... on the kernel command line always wins.

Therefore, after trying to switch to a different keymap for the
virtual console by doing

   “localectl set-keymap <new-map>; dracut -f; reboot;”

it does not work because grub.cfg is unchanged and still contains
vconsole.keymap=<old-map> which is preferred by
systemd-vconsole-setup.

But when doing

   “localectl set-keymap <new-map>; dracut -f; reboot;”

the old map was deleted from and the new map copied
into usr/lib/kbd/keymaps in initrd and etc/vconsole.conf in
initrd contains KEYMAP=<new-map>

But systemd-vconsole-setup takes the value from vconsole.keymap=<old-map>
from the kernel command line and passes it to loadkeys, which fails
because the old map is not there anymore in initrd.

So one gets neither the old nor the new map, the loadkeys command just fails.

Comment 5 Adam Williamson 2013-11-25 17:57:27 UTC
Per the discussion in https://bugzilla.redhat.com/show_bug.cgi?id=875567#c21 onwards, the way to fix this might be to stop writing the layout into the kernel cmdline - it sounds like we may not have a reason to do that any more.

Do we also want to make system-config-keyboard regenerate the initramfs when you change keyboard layout, or is that a bit dangerous?

Comment 6 Adam Williamson 2013-11-25 18:01:12 UTC
Proposing as a freeze exception: if the fix is not to write the kernel cmdline entry then we need to do that as an FE, since it's in anaconda. But if we do decide to do that we should do it _soon_, so we have time to find any breakage prior to release.

Comment 7 Adam Williamson 2013-11-25 18:01:54 UTC
er, re comment #5, I should've said 'localed' not 'system-config-keyboard'.

Comment 8 Mike FABIAN 2013-11-27 09:19:45 UTC
I tested on Fedora-20-TC3-x86_64-netinst.iso, not writing the keyboard
layout on the kernel command line works.

I tested like this:

- install in Japanese, add German keyboard layout in anaconda
  and make it top priority
- chose to encrypt disk, use the password “zzzz”
  (on the German keyboard layout the “z” is on the key where the “y”
  is on the US layout)
- complete installation, reboot
- make snapshot (1) of the virtual machine at the grub prompt

- continue booting
- Entering “zzzz” as the password for the encryption works with the
  German layout, after booting the German layout is active on the console
- load snapshot (1) of the virtual machine to go back to the grub prompt
- remove vconsole.keymap=de from the kernel command line, continue booting
- “zzzz” using the German layout still works as the password for the disc
  encryption
- when booting is finished, German layout works on the vconsole.
- execute “localectl set-keymap fr; dracut -f; reboot”
- make snapshot (2) of the virtual machine at the grub prompt

- continue booting
- Using the German layout to enter “zzzz” as the disk encryption password
  does not work (because only fr.map is now in initrd, vconsole.keymap=de
  is on the kernel command line but the German layout cannot be loaded)
- Using the French (azwerty) layout to enter “zzzz” (press the “w” key
  on an US keyboard to get a “z” with the French layout) does not work either
  because the vconsole.keymap=de on the command line causes
  an attempt to load the German layout, which fails
- load snapshot (2) of the virtual machine to go back to the grub prompt
- edit the kernel command line to remove the vconsole.keymap=de
- continue booting
- now entering “zzzz” as the encryption password works using the
  French layout (press the “w” key on a US Hardware keyboard)

I.e. when vconsole.keymap=... is not on the kernel command line,
everything works as it should.

Comment 9 Vratislav Podzimek 2013-11-27 12:39:19 UTC
(In reply to Mike FABIAN from comment #8)
> I tested on Fedora-20-TC3-x86_64-netinst.iso, not writing the keyboard
> layout on the kernel command line works.
Could you please file a bug on anaconda that it should stop writing out that boot option, propose it as a FreezeException and assign it to me? Thanks!

Comment 10 Adam Williamson 2013-11-27 19:08:25 UTC
Well, I don't see that we needed a new bug to be filed really, but since it's happened and that one has been approved as an FE, withdrawing the FE nomination for this one.

Comment 11 Adam Williamson 2013-12-05 05:20:28 UTC
I think the change we made to fix this will break keyboard layout during fedup stage2 initramfs for F20-F21 (marking about the fourth different way we've broken that...). Filed as https://bugzilla.redhat.com/show_bug.cgi?id=1038413 .

Comment 12 Harald Hoyer 2013-12-10 12:22:03 UTC
See https://bugzilla.redhat.com/show_bug.cgi?id=881624#c60


Note You need to log in before you can comment on or make changes to this bug.