Debian Jessie on XO

From OLPC
Revision as of 03:01, 26 November 2015 by Quozl (talk | contribs) (using last instead of ext, more portable, and will also work if the SD card is ever booted over USB with adapter)
Jump to: navigation, search

Introduction

This guide was made to show others how they can install Debian GNU/Linux on the OLPC XO-1 (and possibly the XO-1.5, but I don't have one). Installing it on an XO-1.75 or XO-4 may be possible, but due to the vastly different architecture this guide will probably not work for those devices. I decided to install Debian because of its supported upgrade tool that's better than Ubuntu's and its long support periods. This guide should be usable to anyone who has at least some experience with Linux.

Requirements

  • An OLPC XO-1 or XO-1.5
  • An SD card large enough to hold the Debian rootfs, and formatted to ext4 (Mine was about 900 MB, so about 2 GB or over should be good, if you're going light on packages)
  • A computer running Debian (An XO already running Debian may work, but probably would be slow)
  • A developer key, to unlock the XO bootloader,
  • Recent Firmware

Installing Debian on the SD card

  • Disk mounting permissions are complicated, so I just used a local folder in my home folder. I then created the Debian rootfs using a utility called debootstrap.
mkdir ~/debroot
sudo apt-get install debootstrap binutils
debootstrap --arch i386 jessie debroot http://http.us.debian.org/debian/
  • Next, mount some files that are necessary to get the chroot running on your local system.
mount -o bind /dev debroot/dev
mount -o bind /proc debroot/proc
mount -o bind /sys debroot/sys
mount -o bind /tmp debroot/tmp
cp /etc/resolv.conf debroot/etc/resolv.conf
  • Then, I log in to the rootfs that I just created.
chroot debroot
  • You're in! First, the /etc/apt/sources.list file installed by the debootstrap program is a bit incomplete. Change it to this with nano (If you don't live in the US, replace the US mirrors with your country's mirrors to speed up package installs).
deb http://ftp.us.debian.org/debian jessie main contrib non-free
deb-src http://ftp.us.debian.org/debian jessie main contrib non-free

deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free
deb-src http://ftp.debian.org/debian/ jessie-updates main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free
  • Run apt-get update to pull in the latest packages (You may get an error about locales, just ignore it for now).
  • Add a hostname to your machine (I used XO-1)
echo "(your hostname)" > /etc/hostname
  • Add the same hostname to /etc/hosts with nano. Add it next to where it says localhost.
nano /etc/hosts
  • Make Debian stop complaining about your locale
apt-get install locales
dpkg-reconfigure locales
  • Install some essential software
apt-get install wpasupplicant rpm2cpio wget acpid acpi olpc-kbdshim olpc-powerd olpc-xo1-hw initramfs-tools
  • Make a user
adduser YOURUSERNAME
  • Choose a desktop environment or window manager. I went with Openbox, but I'd recommend LXDE for beginners.
apt-get install xserver-xorg xserver-xorg-video-geode lxde
  • Download the OLPC Linux kernel (the generic kernel doesn't support some OLPC hardware)
wget http://dev.laptop.org/~kernels/public_rpms/f20-xo1/kernel-3.10.0_xo1-20130716.1755.olpc.c06da27.i686.rpm
cd /
rpm2cpio kernel*.rpm | cpio -idmv
cd /boot
mv initrd-3.10.0_xo1-20130716.1755.olpc.c06da27.img initrd.img-3.10.0_xo1-20130716.1755.olpc.c06da27
update-initramfs -t -c -u -k 3.10.0_xo1-20130716.1755.olpc.c06da27
(cd /boot ; ln -s initrd.img-3.10.0_xo1-20130716.1755.olpc.c06da27 initrd.img)
(cd /boot ; ln -s vmlinuz-3.10.0_xo1-20130716.1755.olpc.c06da27 vmlinuz )
rm kernel-3.10.0_xo1-20130716.1755.olpc.c06da27.i686.rpm
  • Download some firmware for WiFi
mkdir /lib/firmware
cd /lib/firmware
wget -O usb8388.bin http://dev.laptop.org/pub/firmware/libertas/usb8388-5.110.22.p22.bin
  • Remove the old /boot/olpc.fth file, and create a new one with these lines:
\ Debian Jessie for XO
visible
" last:\boot\initrd.img" to ramdisk
" last:\boot\vmlinuz" to boot-device
" console=tty0 fbcon=font:SUN12x22 root=/dev/mmcblk0p1" to boot-file
boot
  • Make a swapfile so that when you run out of RAM, Linux doesn't start closing random applications
dd if=/dev/zero of=/swapfile bs=1M count=512
mkswap /swapfile
  • Replace the contents of /etc/fstab (file that shows what drives to mount) with this:
/dev/mmcblk0p1  /         ext4    defaults,noatime,errors=remount-ro  0 0
/swapfile none  swap    sw              0       0
devpts     /dev/pts  devpts  gid=5,mode=620   0 0
tmpfs      /dev/shm  tmpfs   defaults,size=50m         0 0
proc       /proc     proc    defaults         0 0
sysfs      /sys      sysfs   defaults         0 0
/tmp            /tmp            tmpfs         rw,size=50m 0 0
vartmp          /var/tmp        tmpfs         rw,size=50m 0 0
varlog          /var/log        tmpfs         rw,size=20m 0 0
  • Add "vm.swappiness=5" to the end of /etc/sysctl.conf. By default, this value is 60, meaining that if your RAM is more than 40% full, the XO will start swapping data from RAM to the SD card. This changes it to wait until your RAM is 95% full, which reduces the wear on your SD card.
  • Exit the chroot with the "exit" command.
  • Restart your computer to close out some processes that are left in use by the chroot.
  • As root, copy the folder to your SD card.
  • Power on the XO-1 with the SD card NOT in the slot (so you boot into Sugar). Plug in the SD card once the XO is fully booted, remove the SD card's "/etc/modprobe.d/" folder, and copy the /etc/modprobe.d/ folder from your XO to the SD card.
  • Restart your XO with the SD card still in. If all goes well, after a couple of minutes you should see a login screen.

Caveats

  • After a reboot, the system goes to sleep by itself once. After that, it's fine.
  • The XO will not sleep on lid close. However, sleeping from the power menu does work.
  • Due to nonstandard hardware, the battery monitor on LXDE doesn't work.
  • Because the XO's rotation button uses xrandr, using it on LXDE (where xrandr opens up LXrandr, its display settings window) doesn't work. However, it does work on Openbox.
  • The screen output may become corrupted when memory usage is high (This happens on Sugar, at least for me, as well). To fix this, log into a shell with Control-Alt-F1 (F1 is the key to the right of the search key), and log in. Run "sudo systemctl stop [your display manager, usually either lightdm, slim, kdm, or gdm]". Then run "su" to log in as root and "Xorg -configure" to create an xorg.conf file. Edit the file "/root/xorg.conf.new". At the end of the the "Device" section, add this line:
Option     "MigrationHeuristic" "greedy"

Copy the file to /etc/xorg.conf.

  • Suspend only turns the LCD screen off after you unplug the XO.