LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-03-2008, 03:18 AM   #1
malo_umoran
Member
 
Registered: Dec 2003
Distribution: Desktop: Slackware 13.1 &13.37 | Server: Debian 6.0
Posts: 270

Rep: Reputation: 32
How to add non-US keyboard layout to initrd (cryptsetup)?


Hi,

I was trying to optimize my system yesterday, to remove unneeded packages, configs, make it faster etc.

I am using initrd for boot, because my / partition is encrypted. When cryptsetup asks for the password I have to be really careful, because I have german keyboard. But the initrd is using US keyboard layout.

Any ideas how to change this?

I also thought about copying keymap file from /usr/share/kbd/keymaps/ (with all dependencies) and loading it. But maybe you have a more simple solution.


I found for debian or ubuntu solutions like "add this line to xxxx.conf" and I thought about dismantling ubuntu's initrd and check everything line by line.

Thanks.

Last edited by malo_umoran; 04-03-2008 at 04:05 AM.
 
Old 04-03-2008, 08:00 AM   #2
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Hm, yes this should be nice to add to mkinitrd. It is not even hard.
But taking into account that Slackware 12.1 release candidate 1 was made available today, I guess that only the serious bugs are going to be solved at this time. Your feature request would be added to the next Slackware development release at the earliest.

In the meantime what you can try is this:

You should already have a directory /boot/initrd-tree which is created when you run the 'mkinitrd' command. It contains the full content of the initrd image that gets zipped into /boot/initrd.gz
  • Download the file http://www.slackware.com/~alien/tools/keymaps.tar.gz and copy it to /boot/initrd-tree/etc/. This file is part of the Slackware installer, you will not find it anywhere in the Slackware source tree but I extracted it for you from the /isolinux/initrd.img file.
  • Create a file /boot/initrd-tree/keymap in which you write the name of your language for the keyboard (like nl for the dutch keyboard or de-latin1-nodeadkeys for one of the german keyboards which are available in the keymaps.tar.gz)
  • In the /boot/initrd-tree/init script, add this line in the beginning:
    Code:
    KEYMAP=`cat /keymap`
    further down add the following lines to actually load the keyboard map - make sure the commands are added before the point where cryptsetup runs and asks for a passphrase:
    Code:
    # Load a custom keyboard mapping:
    if [ -n "$KEYMAP" ]; then
      echo "${INITRD}:  Loading '$KEYMAP' keyboard mapping:"
      tar xzOf /etc/keymaps.tar.gz ${KEYMAP}.bmap | loadkmap
    fi

All this advice is untested, I just made it up. But it should work, and I will test this by creating a modified mkinitrd package as soon as I have the time.
If this worked for you please let me know ASAP!

Eric
 
Old 04-03-2008, 09:05 AM   #3
malo_umoran
Member
 
Registered: Dec 2003
Distribution: Desktop: Slackware 13.1 &13.37 | Server: Debian 6.0
Posts: 270

Original Poster
Rep: Reputation: 32
I hoped that you will come out with solution like this . Really nice.

I did it other way, but I did not test it. I copied /usr/bin/loadkeys in /boot/initrd-tree/bin and I put de.map in a new folder /boot/initrd-tree/share/kbd folder, chrooted in /boot/initrd-tree and tried to load it with

Code:
/bin/loadkeys /share/kbd/de.map
It complained about missing include euro2.map and a few other files. I copied all of these files in the same folder and it does not complain any more in the chrooted environment. It just says that keymap is loaded.I will reboot when I come home.

Your solution is much more universal and cleaner and I will test it today. I will let you know does it work.

Thanks Eric.

M.
 
Old 04-04-2008, 03:02 PM   #4
malo_umoran
Member
 
Registered: Dec 2003
Distribution: Desktop: Slackware 13.1 &13.37 | Server: Debian 6.0
Posts: 270

Original Poster
Rep: Reputation: 32
Hi Eric

I tested your code a few minutes ago. It works in principle, but I had to make a few changes for initrd image, because it did not work "out of the box":

1. I had to download/recompile busybox, because applets like tar or loadkmap are not available in Slackware's busybox.

I also added some other commands to handle better cryptsetup errors like poweroff and reboot. If user enters wrong password three times, init shows an error message and runs /bin/poweroff instead of kernel panic error. I did not test it, but it could look something like this:

Code:
    /bin/clear
    /sbin/cryptsetup luksOpen ${LUKSDEV} $ROOTDEV </dev/systty >/dev/systty 2>&1
    ROOTDEV="/dev/mapper/${ROOTDEV}"

    if [ ! -e $ROOTDEV ]; then
        echo
        echo "Three times wrong password, you loser? Bye bye..."
        echo
        echo -n "Press Enter/Return to reboot or wait 5 seconds for system to shutdown."

        read -t 5 SHUTDOWN
        if [ -z $SHUTDOWN ]; then
             echo "Running poweroff..."
             /bin/poweroff
        else
             echo "Rebooting..."
             /bin/reboot
        fi
    fi

2. loadkmap did not want to run, because /dev/tty0 was missing.

Is there a reason why tty0 is not included in initrd-tree.tar.gz?

There are /dev/tty1, 2, 3 and 4, but tty0 is missing. I was not able to tell loadkmap to use /dev/tty1 so I just made a symlink to tty1.

Code:
# Load a custom keyboard mapping:
if [ -n "$KEYMAP" ]; then
    echo "${INITRD}:  Loading '$KEYMAP' keyboard mapping:"
    ln -s /dev/tty1 /dev/tty0
    tar xzOf /etc/keymaps.tar.gz ${KEYMAP}.bmap | loadkmap
fi
It is working just great. Other more simpler and cleaner solution would be to make /boot/initrd-tree/dev/tty0 before running mkinitrd or to tell sh somehow to use tty1 instead of tty0. But you know that probably much better than me.

Thanks a lot.


Two partly off-topic but still initrd questions:
1. is there some kind of bootsplash which could be used to have at least some kind of GUI for entering password? This is my girlfriend's official request . I tried Ubuntu's usplash, but I was not able to make it work on Slackware (screen just becomes black).

2. I totally stripped down kernel image in modules to load fastes by using just unnecessary features in kernel and to make it come faster to cryptsetup's "Enter password". Still most of the time takes disk detection (6 disks). Do you know is it somehow possible to tell ata/sata_nv module(s) just to check /dev/sda or sdb and ignore other? Some kind of modprobe /insmod param like insmod /lib/.../sata_nv onlydetect=/dev/sda ? I do not believe that there is something like that because this detection "creates" sd[abcdef], but I still wanted to ask


Thanks.

M.

Last edited by malo_umoran; 04-04-2008 at 03:07 PM.
 
Old 04-04-2008, 05:24 PM   #5
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Quote:
Originally Posted by malo_umoran View Post
Hi Eric

I tested your code a few minutes ago. It works in principle, but I had to make a few changes for initrd image, because it did not work "out of the box":

1. I had to download/recompile busybox, because applets like tar or loadkmap are not available in Slackware's busybox.
My HOWTO was targeted at Slackware's development version (-current) where the busybox is already compiled with the functionality needed. But you did well by recompiling your Slackware's busybox.

Quote:
I also added some other commands to handle better cryptsetup errors like poweroff and reboot. If user enters wrong password three times, init shows an error message and runs /bin/poweroff instead of kernel panic error. I did not test it, but it could look something like this:
Well... someone who enters the LUKS password incorrectly three times is a loser. Your poweroff solution is userfriendly but Slackware's initrd will remain as it is ;-) It'll teach you not to enter three incorrect passwords.

Quote:
2. loadkmap did not want to run, because /dev/tty0 was missing.

Is there a reason why tty0 is not included in initrd-tree.tar.gz?
In Slackware 12.1 (soon to be released) initrd-tree there is a /dev/tty0 , so that solves your problem.

Quote:
Two partly off-topic but still initrd questions:
1. is there some kind of bootsplash which could be used to have at least some kind of GUI for entering password? This is my girlfriend's official request . I tried Ubuntu's usplash, but I was not able to make it work on Slackware (screen just becomes black).
No bootsplash in Slackware... and that will remain so.

Quote:
2. I totally stripped down kernel image in modules to load fastes by using just unnecessary features in kernel and to make it come faster to cryptsetup's "Enter password". Still most of the time takes disk detection (6 disks). Do you know is it somehow possible to tell ata/sata_nv module(s) just to check /dev/sda or sdb and ignore other? Some kind of modprobe /insmod param like insmod /lib/.../sata_nv onlydetect=/dev/sda ? I do not believe that there is something like that because this detection "creates" sd[abcdef], but I still wanted to ask
If you have six disks, I assume you want to use them don't you? Anyway, the disk probing should not take long. And you can take those disks out and buy a single big disk as replacement.

Eric

PS: The mkinitrd of slackware-current was just enhanced today with the parameter "-l <language>" to add support for a non-US keyboard in the initrd... which adds exactly the functionality we are talking about in this thread ;-) You can take the mkinitrd sources out of Slackware-current and run the mkinitrd.SlackBuild, it will create a package for your Slackware that you can use instead of what you have now.
 
Old 04-04-2008, 05:44 PM   #6
malo_umoran
Member
 
Registered: Dec 2003
Distribution: Desktop: Slackware 13.1 &13.37 | Server: Debian 6.0
Posts: 270

Original Poster
Rep: Reputation: 32
Thanks for the help and including -l in mkinitrd.

Quote:
Originally Posted by Alien Bob View Post
No bootsplash in Slackware... and that will remain so.
I absolutely agree with you and I do not need it for the boot process.
But She (me too in the meanwhile ) would like to have some kind of shiny gui until password is typed in.

And I also remember finding yesterday splashy or some other sort of bootsplash package on your repository and it was made by you (no no ) and I thought that you have an idea which bootsplash application supports user input.
 
Old 04-05-2008, 08:44 AM   #7
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,645

Rep: Reputation: 146Reputation: 146
Quote:
Originally Posted by Alien Bob View Post
PS: The mkinitrd of slackware-current was just enhanced today with the parameter "-l <language>" to add support for a non-US keyboard in the initrd... which adds exactly the functionality we are talking about in this thread ;-)
Hi Eric, since it's you who has done this, may I suggest a little and not in any way critical patch to you, regarding the mkinitrd man page? [EDIT: "cosmetical change", I think that's the term I was looking for ] BTW, many thanks for your work, it's very convenient to have the keymap option IMHO.

Code:
--- mkinitrd.8.old   2008-04-05 15:30:22.008347000 +0200
+++ mkinitrd.8  2008-04-05 15:32:23.236344761 +0200
@@ -7,7 +7,7 @@
 .ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
 .el .TP "\\$1"
 ..
-.TH MKINITRD 8 "04 March 2008" "Slackware Version 12.1"
+.TH MKINITRD 8 "05 March 2008" "Slackware Version 12.1"
 .SH NAME
 mkinitrd \- create or rebuilt an initrd (initial ramdisk) using initramfs (simple cpio+gzip).
 .SH SYNOPSIS
@@ -28,6 +28,9 @@
 .B \-k kernel_version
 ]
 [
+.B \-l keymap
+]
+[
 .B \-m module1:module2:module3...
 ]
 [

Last edited by titopoquito; 04-05-2008 at 08:50 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Switching keyboard layout - Mandriva2006 - K.D.E. Windows Layout! itz2000 Mandriva 3 08-13-2006 06:43 PM
KDE Keyboard Shortcuts with different Keyboard Layout hellblade Linux - Software 5 04-18-2006 12:40 AM
Need to add Danish layout for my keyboard... anti.corp Arch 4 01-17-2006 12:15 PM
keyboard layout fckivanc Ubuntu 4 09-29-2005 03:00 AM
add keyboard layout to kxkb LinuxLala Linux - General 1 06-28-2004 06:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration