How to Fix Norwegian Keyboard Layout Issues in CentOS 7 Virtual Machine


2 views

When running CentOS 7 (specifically version 7.0.1406) in Oracle VirtualBox, many users encounter keyboard mapping issues where special characters like æ, ø, å, and | don't produce the expected output. This is particularly frustrating for Norwegian keyboard users who need these characters for programming and system administration tasks.

Most online guides suggest editing /etc/sysconfig/keyboard, but in modern CentOS 7 installations, this file doesn't exist by default. The system has moved to a different configuration approach using localectl and systemd.

First, check your current keyboard configuration:


# Check current keyboard settings
localectl status

# List available keymaps
localectl list-keymaps | grep -i nor

To permanently set the Norwegian keyboard layout:


# Set Norwegian keyboard layout
sudo localectl set-keymap no

# For Norwegian with dead keys (if needed)
sudo localectl set-keymap no-dvorak

# Verify the change
localectl status

If you're using a graphical environment, you'll also need to set the X11 layout:


sudo localectl set-x11-keymap no

To test changes without rebooting, load the new keymap temporarily:


# Load Norwegian keymap for current session
loadkeys no

If the above methods don't work, you can manually create the keyboard configuration:


# Create keyboard configuration file
echo 'KEYTABLE="no"' | sudo tee /etc/vconsole.conf
echo 'XKBLAYOUT="no"' | sudo tee -a /etc/vconsole.conf

For VirtualBox users, ensure your VM settings match:


1. Shut down the VM
2. Go to Settings → System → Motherboard
3. Set Pointing Device to "PS/2 Mouse"
4. In Settings → System → Processor, enable PAE/NX if available
5. Start the VM and test keyboard

If you specifically need the pipe character (|), try these key combinations:


Norwegian layout: AltGr + 9
US International: Shift + \

After making changes, verify they persist across reboots:


# Check all keyboard-related settings
cat /etc/vconsole.conf
systemctl status systemd-localed.service

After installing CentOS 7.0.1406 in VirtualBox with Norwegian keyboard layout selected during installation, many users encounter unexpected behavior when typing special Norwegian characters (æ, ø, å) and the pipe character (|). This differs from Ubuntu where the layout works correctly.

The root cause lies in how CentOS 7 handles keyboard configuration differently from other distributions. The traditional /etc/sysconfig/keyboard file doesn't exist in CentOS 7, which causes confusion when following older guides.

First, verify your current keyboard settings:

localectl status

To permanently change to Norwegian layout:

sudo localectl set-keymap no
sudo localectl set-x11-keymap no

If you need immediate changes in your X session:

setxkbmap -layout no

For testing pipe character location in Norwegian layout:

xev | grep keysym
# Then press the key where pipe should be

For systems without localectl (older versions):

sudo nano /etc/X11/xorg.conf.d/00-keyboard.conf

Add these contents:

Section "InputClass"
    Identifier "system-keyboard"
    MatchIsKeyboard "on"
    Option "XkbLayout" "no"
    Option "XkbModel" "pc105"
    Option "XkbVariant" "nodeadkeys"
EndSection

When running in VirtualBox, ensure:

# Check if VirtualBox Guest Additions are installed
lsmod | grep vboxguest
# If not, install them:
sudo yum install -y kernel-devel gcc make perl
sudo mount /dev/cdrom /mnt
sudo /mnt/VBoxLinuxAdditions.run