Ubuntu Lucid on OLPC XO: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
(Proper name for Open Firmware)
 
(70 intermediate revisions by 13 users not shown)
Line 1: Line 1:
== Introduction ==
== Introduction ==
This guide describes how to install Ubuntu Lucid (10.04) on the OLPC XO.
This guide describes how to install '''Ubuntu 10.04.1 LTS (Lucid Lynx)''' on the OLPC XO. The method of installing Ubuntu described herein is aimed at power users who know what they're doing and know what they want - but plain old folks are welcome to give it a try, of course.
This guide solves the problem that earlier methods had with getting Upstart to work, now we won't have to take a step backwards to sysvinit.
At the time of writing, Lucid is still in the development phase, but will soon be released in a stable version.
The method of installing Ubuntu described herein is aimed at power users who know what they're doing and know what they want - but plain old folks are welcome to give it a try, of course.
This guide solves the problem that earlier methods had with Upstart, so we won't have to take a step backwards to sysvinit.


== Requirements ==
== Requirements ==
* The Ubuntu 10.04.1 LTS CD image: http://releases.ubuntu.com/10.04.1/ubuntu-10.04.1-desktop-i386.iso
You will need a USB flashdrive or an SD card big enough to fit the Ubuntu system, 4 GB should work.
* A USB flashdrive or an SD card big enough to fit the Ubuntu system, 4 GB should work.
You will also need a computer other than the XO, to create the Ubuntu system on. We will be using a virtualisation software on this computer to create the Ubuntu image which will be written to the flashdrive/SD card. I will be using an Ubuntu system (surprise!) with VirtualBox. Qemu should work too.
* A computer other than the XO, to create the Ubuntu system on. We will be using a virtualization software on this computer to install Ubuntu on the flashdrive/SD card. I will be using an Ubuntu system (surprise!) with VirtualBox. Qemu should work too.
* A [[Activation and Developer Keys|developer key]], to unlock the XO bootloader,
* Recent [[Firmware]], since the instructions here depend on firmware features not available until recently,


== Creating the Ubuntu Image ==
== Known issues ==
* Audio does not work. The/A driver seems to load, but ALSA doesn't seem to recognize it. I haven't had time to dig into this yet. (See [[Talk:Ubuntu_Lucid_on_OLPC_XO#audio_fix]] for a possible fix)
Create a disk image in VirtualBox or Qemu, slightly smaller than your destination flashdrive/SD card.
* There seems to be some video issues, some elements (window borders?) are goofy and don't repaint properly. I have not yet investigated how/if the Ubuntu Xorg driver differs from the stock XO Fedora driver.
Then continue with installing Ubuntu Lucid as you normally would. If you need guidance on how to operate your virtualisation software or install Ubuntu in it, please look elsewhere - the Internet has plenty of guides on that.
* Hardware buttons (around the screen as well as the funky F1-F12 buttons on the XO) are not mapped. The F* buttons should be easy to map with the "Keyboard shortcuts" tool in Gnome's Preferences menu. The directional pad/rotate button/game buttons are slightly trickier, but I believe instructions exist somewhere in this wiki.


== Installing Ubuntu on the USB/SD drive ==
'''Attention:''' Make sure to use the manual partition editor during the installation, and format the root partition as Ext3. Do not use the default setting of Ext4, as it is not yet supported by the OpenFirmware bootloader in the XO.
The following is all done on the computer with the virtualization software.
* You need to have permissions to access your USB flashdrive/SD card as a normal user:
$ sudo usermod -a -G disk <your username>
'''Now log out''', and log back in for this to take effect.


* Ubuntu likes to automount things. Thus, first make sure your USB flashdrive/SD card is unmounted:
After installing Ubuntu and running "sudo apt-get upgrade" to install the latest packages, you might want to install the "Netbook Remix" packages. They give Ubuntu a new desktop interface optimized for netbooks, which works nicely on the XO's small display. To do so, run "sudo apt-get install ubuntu-netbook".
$ sudo umount /dev/sdX
...where sdX is your USB/SD drive.


* If you are using VirtualBox, add your USB flashdrive or SD card as a virtual hard drive that we can install Ubuntu onto.
== Writing image to the drive ==
$ cd ~/.VirtualBox/HardDisks
Shut down your virtual Ubuntu machine. Now convert your virtual disk image to a raw format that can be written to your flashdrive/SD card. If you are using VirtualBox, the command to do this is:
$ VBoxManage internalcommands converttoraw <vbox-image>.vdi ubuntu-image.raw
$ VBoxManage internalcommands createrawvmdk -filename olpc-xo.vmdk -rawdisk /dev/sdX -register
If you are using Qemu or something else, you're on your own to figure out how to do this.


* With Qemu, the commandline option "-hda /dev/sdX" should do the trick.
Now write the image to your flashdrive/SD card:
$ dd if=ubuntu-image.raw of=/dev/sdX bs=1M
...where sdX is your drive (do not include partition number - use e.g. ''sda'' instead of ''sda1'')
This will apply the partition table created with the Ubuntu installer - and needless to say, all data on the drive will vanish.
Now, the root partition on the drive has to be renamed in order for the bootloader to find it:
$ sudo tune2fs /dev/sdb1 -L OLPCRoot


== Making Ubuntu bootable on the XO ==
* Install Ubuntu as you normally would onto the USB/SD drive.<br />
If you need guidance on how to operate your virtualization software or how to install Ubuntu in it, please look elsewhere - the Internet has plenty of guides on that.
The XO uses OpenFirmware as its "BIOS" and bootloader (the GRUB bootloader in your new Ubuntu system will not be used), and we need to add a couple of files that tell OpenFirmware what to do. First, your XO probably has firmware security enabled. When this is the case, you need a developer key in order to make it boot anything but the original XO system on the builtin NAND drive. Secondly, we need a bootloader script file that tells OpenFirmware how to boot our system.


'''Attention:''' Make sure to use the manual partition editor during the installation, and format the root partition as '''Ext3'''. Do not use the default setting of Ext4, as it is not yet supported by the Open Firmware bootloader in the XO.<br />
After writing the image to your drive in the previous step, unplug your drive and plug it back in, and most linux distros will automatically mount your drive again to give you access to the ubuntu root partition.
Also, '''do not create a swap partition.''' Flash drives die prematurely from the wear & tear of swapping.
Create a folder called "security" in the root, and save your developer key there, with the filename "develop.sig".
Now, in the boot folder, create a file named olpc.fth. This is a Forth script for controlling the OpenFirmware bootloader.


When the installation is complete, you will boot into your new system for the first time in the virtual machine.
For USB drives, use this script:
This is a good time to install the latest and greatest packages and updates:
" root=LABEL=OLPCRoot ro quiet splash" to boot-file
$ sudo apt-get update
" disk:\vmlinuz" to boot-device
$ sudo apt-get upgrade
" disk:\initrd.img" to ramdisk

unfreeze
== Adapting Ubuntu to the XO ==
boot
The following is done while you're still in the virtual machine.
If you are using an SD card, use the following script:

" root=mmcblk0p1 ro quiet splash" to boot-file
You might want to install the ubuntu-netbook packages. They give your desktop a new look, replacing your standard Gnome desktop with a slightly iPhone-inspired interface. The main menu and the desktop are replaced with a desktop-sized application launcher with nice, big icons. All windows are maximized to make good use of the small screen and take away the hassle of window manipulation.
" sd:\vmlinuz" to boot-device
$ sudo apt-get install ubuntu-netbook
" sd:\initrd.img" to ramdisk

unfreeze
The most important fix, however, is to replace the Linux kernel. For some reason, the stock Ubuntu kernel doesn't work on the XO. (It seems to boot, judging by miscellaneous flashing LEDs on the computer, but the display is stuck on the Open Firmware screen (even when unfrozen). Video driver issues?)
boot
* Download the latest XO-1 kernel from here: http://dev.laptop.org/~kernels/olpc-2.6.31-xo1/
or http://dev.laptop.org/~kernels/olpc-2.6.35-xo1/
Make sure to get the binary package, and not the source. Example: http://dev.laptop.org/~kernels/olpc-2.6.31-xo1/kernel-2.6.31_xo1-20100504.1635.1.olpc.7223ce6.i586.rpm

If you're using a more recent version than this one, make sure to change all references to it accordingly in the commands below.
$ sudo apt-get install rpm2cpio
$ cd /
$ sudo sh -c "rpm2cpio /home/user/Downloads/kernel-2.6.31_xo1-20100504.1635.1.olpc.7223ce6.i586.rpm | cpio -idmv"
$ sudo depmod 2.6.31_xo1-20100504.1635.1.olpc.7223ce6
For some reason, the WiFi firmware is messed up. Fix it thus:
$ sudo ln -s /lib/firmware/libertas/usb8388_v9.bin /lib/firmware/usb8388.bin

Now, we need to include our new modules in the Ubuntu initrd:
$ mkdir /tmp/initrd && cd /tmp/initrd
$ zcat /boot/initrd.img-2.6.xxxxxxx | cpio -idmv
$ cp -r /lib/modules/2.6.31_xo1-20100504.1635.1.olpc.7223ce6 lib/modules/
$ cp -r /lib/firmware/{libertas,usb8388.bin} lib/firmware/
$ sudo sh -c "find . | cpio -H newc -o | gzip > /boot/initrd.img-xo"
(Some people reported that they needed the WiFi firmware (libertas) in the initrd in order for the driver to work, so I included that for now)

* If firmware security is enabled on your XO (it most likely is), you will need a [[Activation and Developer Keys|developer key]] in order to boot anything but the stock Fedora/Sugar OS. Once you have your key, create a folder: "sudo mkdir /security", and save your '''develop.sig''' file there.

The last step is to create the Forth script that tells Open Firmware how to boot our system. Save the following as /boot/olpc.fth:
\ Open Firmware boot script for Ubuntu
" '''sd''':\boot\initrd.img-xo" to ramdisk
dcon-unfreeze
boot '''sd''':\boot\vmlinuz-2.6.31_xo1-20100504.1635.1.olpc.7223ce6 ro root=LABEL=OLPCRoot rootdelay=30
This script is for booting from an SD card; if you use a USB drive, replace '''sd''' with '''u'''.

* Now, shut down your virtual machine. It will soon be time to try out our creation on the XO!

'''Attention:''' You might have noticed that the root partition is referenced by its label in the boot script above. Thus, in order for the Linux kernel to find it, you need to give it the right label at this point:
$ sudo tune2fs /dev/sdX1 -L OLPCRoot

== Good luck! ==
Plug your USB drive or SD card into the XO and boot it up - with any luck, it might work! :]

'''Just one more thing: it'd be awfully nice if you leave a comment on the Discussion tab above.
Just tell us whether it all went smoothly, or if something needs to be worked on. Thanks for contributing!'''

[[Category:Linux distributions]]

Latest revision as of 23:50, 6 October 2012

Introduction

This guide describes how to install Ubuntu 10.04.1 LTS (Lucid Lynx) on the OLPC XO. The method of installing Ubuntu described herein is aimed at power users who know what they're doing and know what they want - but plain old folks are welcome to give it a try, of course. This guide solves the problem that earlier methods had with getting Upstart to work, now we won't have to take a step backwards to sysvinit.

Requirements

  • The Ubuntu 10.04.1 LTS CD image: http://releases.ubuntu.com/10.04.1/ubuntu-10.04.1-desktop-i386.iso
  • A USB flashdrive or an SD card big enough to fit the Ubuntu system, 4 GB should work.
  • A computer other than the XO, to create the Ubuntu system on. We will be using a virtualization software on this computer to install Ubuntu on the flashdrive/SD card. I will be using an Ubuntu system (surprise!) with VirtualBox. Qemu should work too.
  • A developer key, to unlock the XO bootloader,
  • Recent Firmware, since the instructions here depend on firmware features not available until recently,

Known issues

  • Audio does not work. The/A driver seems to load, but ALSA doesn't seem to recognize it. I haven't had time to dig into this yet. (See Talk:Ubuntu_Lucid_on_OLPC_XO#audio_fix for a possible fix)
  • There seems to be some video issues, some elements (window borders?) are goofy and don't repaint properly. I have not yet investigated how/if the Ubuntu Xorg driver differs from the stock XO Fedora driver.
  • Hardware buttons (around the screen as well as the funky F1-F12 buttons on the XO) are not mapped. The F* buttons should be easy to map with the "Keyboard shortcuts" tool in Gnome's Preferences menu. The directional pad/rotate button/game buttons are slightly trickier, but I believe instructions exist somewhere in this wiki.

Installing Ubuntu on the USB/SD drive

The following is all done on the computer with the virtualization software.

  • You need to have permissions to access your USB flashdrive/SD card as a normal user:
$ sudo usermod -a -G disk <your username>

Now log out, and log back in for this to take effect.

  • Ubuntu likes to automount things. Thus, first make sure your USB flashdrive/SD card is unmounted:
$ sudo umount /dev/sdX

...where sdX is your USB/SD drive.

  • If you are using VirtualBox, add your USB flashdrive or SD card as a virtual hard drive that we can install Ubuntu onto.
$ cd ~/.VirtualBox/HardDisks
$ VBoxManage internalcommands createrawvmdk -filename olpc-xo.vmdk -rawdisk /dev/sdX -register
  • With Qemu, the commandline option "-hda /dev/sdX" should do the trick.
  • Install Ubuntu as you normally would onto the USB/SD drive.

If you need guidance on how to operate your virtualization software or how to install Ubuntu in it, please look elsewhere - the Internet has plenty of guides on that.

Attention: Make sure to use the manual partition editor during the installation, and format the root partition as Ext3. Do not use the default setting of Ext4, as it is not yet supported by the Open Firmware bootloader in the XO.
Also, do not create a swap partition. Flash drives die prematurely from the wear & tear of swapping.

When the installation is complete, you will boot into your new system for the first time in the virtual machine. This is a good time to install the latest and greatest packages and updates:

$ sudo apt-get update
$ sudo apt-get upgrade

Adapting Ubuntu to the XO

The following is done while you're still in the virtual machine.

You might want to install the ubuntu-netbook packages. They give your desktop a new look, replacing your standard Gnome desktop with a slightly iPhone-inspired interface. The main menu and the desktop are replaced with a desktop-sized application launcher with nice, big icons. All windows are maximized to make good use of the small screen and take away the hassle of window manipulation.

$ sudo apt-get install ubuntu-netbook

The most important fix, however, is to replace the Linux kernel. For some reason, the stock Ubuntu kernel doesn't work on the XO. (It seems to boot, judging by miscellaneous flashing LEDs on the computer, but the display is stuck on the Open Firmware screen (even when unfrozen). Video driver issues?)

or http://dev.laptop.org/~kernels/olpc-2.6.35-xo1/ Make sure to get the binary package, and not the source. Example: http://dev.laptop.org/~kernels/olpc-2.6.31-xo1/kernel-2.6.31_xo1-20100504.1635.1.olpc.7223ce6.i586.rpm

If you're using a more recent version than this one, make sure to change all references to it accordingly in the commands below.

$ sudo apt-get install rpm2cpio
$ cd /
$ sudo sh -c "rpm2cpio /home/user/Downloads/kernel-2.6.31_xo1-20100504.1635.1.olpc.7223ce6.i586.rpm | cpio -idmv"
$ sudo depmod 2.6.31_xo1-20100504.1635.1.olpc.7223ce6

For some reason, the WiFi firmware is messed up. Fix it thus:

$ sudo ln -s /lib/firmware/libertas/usb8388_v9.bin /lib/firmware/usb8388.bin

Now, we need to include our new modules in the Ubuntu initrd:

$ mkdir /tmp/initrd && cd /tmp/initrd
$ zcat /boot/initrd.img-2.6.xxxxxxx | cpio -idmv
$ cp -r /lib/modules/2.6.31_xo1-20100504.1635.1.olpc.7223ce6 lib/modules/
$ cp -r /lib/firmware/{libertas,usb8388.bin} lib/firmware/
$ sudo sh -c "find . | cpio -H newc -o | gzip > /boot/initrd.img-xo"

(Some people reported that they needed the WiFi firmware (libertas) in the initrd in order for the driver to work, so I included that for now)

  • If firmware security is enabled on your XO (it most likely is), you will need a developer key in order to boot anything but the stock Fedora/Sugar OS. Once you have your key, create a folder: "sudo mkdir /security", and save your develop.sig file there.

The last step is to create the Forth script that tells Open Firmware how to boot our system. Save the following as /boot/olpc.fth:

\ Open Firmware boot script for Ubuntu
" sd:\boot\initrd.img-xo" to ramdisk
dcon-unfreeze
boot sd:\boot\vmlinuz-2.6.31_xo1-20100504.1635.1.olpc.7223ce6 ro root=LABEL=OLPCRoot rootdelay=30

This script is for booting from an SD card; if you use a USB drive, replace sd with u.

  • Now, shut down your virtual machine. It will soon be time to try out our creation on the XO!

Attention: You might have noticed that the root partition is referenced by its label in the boot script above. Thus, in order for the Linux kernel to find it, you need to give it the right label at this point:

$ sudo tune2fs /dev/sdX1 -L OLPCRoot

Good luck!

Plug your USB drive or SD card into the XO and boot it up - with any luck, it might work! :]

Just one more thing: it'd be awfully nice if you leave a comment on the Discussion tab above. Just tell us whether it all went smoothly, or if something needs to be worked on. Thanks for contributing!