How to setup Ubuntu under MacOS X on a Macbook with Swedish keyboard (svenskt tangentbord) using VirtualBox

Today I will present a guest appearance by my friend and colleague Stefan Hellkvist, a fellow programmer and the guy behind the standingonabeach.com photo blog. He will describe how to fix some problems when running Ubuntu as a guest OS in VirtualBox on a Mac OS X host. Over to Stefan:

“The installation of VirtualBox is straight forward. You just download it from its website and install it as any other MacOS X application. Then you create your virtual machine, download the latest Ubuntu ISO from its website, boot Ubuntu and install that within VirtualBox.

What you are left with now is a Ubuntu running at 800×600 screen resolution and a not fully working keyboard. Keys such as pipe (|), back-slash (), at-sign (@) etc are impossible to type even if you set the “right” keyboard layout at installation. So it’s a system not very useful for hacking on unfortunately.

First off – screen resolution. It turns out that this was fairly easy to solve. You just need to install the Guest Addition tools.

guestadditiontools

When you choose this option in VirtualBox it will place an ISO into your CDROM. All you then need to do is to, on the Ubuntu machine, go into /media/cdrom and type “sudo sh VBoxLinuxAdditions-x86.run” if you are using a 32-bit linux (the 64-bit version is there as well). This will install the required kernel modules
so that, after reboot, you shall be able to run ubuntu full-screen on your Macbook.

Secondly – the Swedish keyboard layout. Partly this is a problem with VirtualBox choosing the apple-key as “host”-key – the key that you switch between the virtual machine and the host with (in this case OS X). This key is normally used for typing these special characters on a Macbook. There are many ways to work around this but one way to make this work is to do two things in Ubuntu.

1) You open up the keyboard setting dialog (System->Preferences->Keyboard)

keyboardpreferences

and for Keyboard Model you here select “Macbook/Macbook Pro” which is under “Apple”

2) Click “Other options”

layoutoptions

and in “Third level chooser” you select “Press right win-key to choose 3rd level”. Click ok to save these settings.

This will give you similar functionality as when working on a PC keyboard with Swedish characters – that you have an Alt-Gr key for these special keys. The only thing which I’ve noticed a bit strange is the placement of the characters for “<" and ">” which are in the upper left corner. Otherwise it works more or less as expected given that you cannot use the normal apple-key under Ubuntu.

The one thing that remains is to find some easy way to “right-click” under Ubuntu. I’ve seen a couple of options for this such as having a special button or screen area to switch the click function, or to use the eject key to right-click, but I would like to make the ctrl-click work as you normally use it under Mac.”

Thank you, Stefan. If someone knows the answer to Stefan’s remaining issue, please leave a comment here!

13 thoughts on “How to setup Ubuntu under MacOS X on a Macbook with Swedish keyboard (svenskt tangentbord) using VirtualBox

  1. I found a solution on the – °§ problem, under “Other Options” (Advanced options KDE) Open up Miscellaneous and check the “Swap keycodes of two keys when Mac keyboards are misdetected by kernel” box and thoose two keys should be switched. Althou it didnt work directly for me, i had to manually give the command :
    setxkbmap -option -option lv3:rwin_switch,apple:badmap , and now it seems to work just fine.

    //Patrik

  2. I use this xmodmap setting, seams to work fine with both laptop and external keyboard

    xmodmap -e “keycode 49 = less greater NoSymbol NoSymbol bar”
    xmodmap -e “keycode 94 = section onehalf”

    Haven’t figured out how to make the change permanent yet, any ideas?

  3. With Ubuntu 9.10 i get a question dialog at login which xmodmap files to load if i put the settings in ~/.Xmodmap There is also a checkbox if you don’t want to be asked again.

    Settings:
    keycode 49 = less greater NoSymbol NoSymbol bar
    keycode 94 = section onehalf

  4. Hi! Probably a little late but if you have two-finger “right-click” enabled on your macbook in the trackpad preferences your two-finger right-clicks will be read by ubuntu via screen sharing. Hope that helps : )

  5. I have a macbook pro retina and are installing linux mint 15. Should I choose “swedish” or “swedish (macintosh)” as keyboard layout?

Leave a Reply to Mattias Cancel reply

Your email address will not be published. Required fields are marked *