Nokia N810 chroot

By: Owen T. Heisler

About

The Nokia N810 Internet Tablet runs Maemo Linux, which is “based on Debian”. Unfortunately, it is impossible to run mainline Linux on this without giving up GPS and reasonable power management.

So, the next best thing? A Debian chroot. With a chroot, I have been able to nearly clone my primary Debian system (excluding X applications). Software packages, personal configuration, data, and scripts I have written are now available for use on my N810!

How-To

This HOWTO loosely outlines the process for setting up a Debian chroot on the Nokia N810. It assumes that:

  • you have done a backup,

  • you know better than to blindly run commands like fdisk and mkfs,

  • the tablet is in devel mode (sudo gainroot works),

  • you want your chroot on the internal flash, and

  • a miniSDHC flash card has been inserted and you want your /home there.

Verify device nodes when partitioning and formatting.

Much of this is from memory; it has not all been tested.

  1. Connect the tablet to a Linux system via USB.

  2. Create a single partiton on internal flash and format as ext3.

    # fdisk -l

    Verify the device node!

    # fdisk /dev/sdb
    # mkfs.ext3 -L debian_root /dev/sdb1
  3. Now build the chroot on the Linux system. Use an appropriate mirror for your location.

    # debootstrap --arch=armel --foreign squeeze tablet-chroot \
      http://ftp.us.debian.org/debian
  4. Move the chroot to the tablet.

    # mount /dev/sdb1 /mnt/tmp
    # mv tablet-chroot/* /mnt/tmp/
    # umount /dev/sdb1

    Wait for the umount to finish.

  5. Disconnect the tablet. Maemo should remount the 2 flash medias.

Most of the remaining steps are performed on the tablet.

  1. Finish building the chroot.

    Open a terminal, and become root by running sudo gainroot.

    # mount -t proc proc /media/mmc2/proc
    # mount -o bind /dev /media/mmc2/dev
    # mount -o bind /sys /media/mmc2/sys
    # mount -t devpts none /media/mmc2/dev/pts
    # chroot /media/mmc2 /debootstrap/debootstrap --second-stage
  2. Perform chroot setup and configuration.

    # chroot /media/mmc2 bash

    Create swapfile if desired. Replace $MB with size of swapfile in mebibytes.

    # dd if=/dev/zero of=/var/swap bs=1048576 count=$MB
    # mkswap -L swap /var/swap
    # swapon /var/swap

    [Lots of other package installation and configuration.] Including: add yourself (your user name) to the tty group.

    Set up /home, a single ext3 partition on external flash card.

    # fdisk /dev/mmcblk1p1
    # mkfs.ext3 -L debian_home -m 1 /dev/mmcblk0p1

    Now exit the chroot and remove the bind mounts.

    # exit
    # umount /media/mmc2/dev/pts
    # umount /media/mmc2/sys
    # umount /media/mmc2/dev
    # umount /media/mmc2/proc
  3. Place these start/stop scripts for the chroot in /home/user/MyDocs/ (the root displayed in the file manager and other file dialogs).

    These scripts take care of setting up the chroot, as well as running fsck on both root and home filesystems. You may need to modify these somewhat for your setup (eg. change the bash login lines to your username in the chroot).

    start-chroot.sh

    stop-chroot.sh

  4. Do some surgery on Maemo to make it more cooperative.

    This is for Navit, in case you want to run it.

    # ln -s /usr/lib/libcrypto.so.0.9.8 /usr/lib/libcrypto.so.0.9.7

    Nokia broke AGPS; this fixes it again.

    # echo "66.35.236.25 supl.nokia.com" >> /etc/hosts

    Move the media indexer out of the way so it does not waste power (if you do not need it).

    # mv /usr/bin/metalayer-crawler /usr/bin/metalayer-crawler.bak

    Move the mounting scripts out of the way so we can mount the flash medias with the scripts.

    # mv /usr/sbin/osso-mmc-mount.sh /usr/sbin/osso-mmc-mount.sh.bak
    # mv /usr/sbin/mmc-mount /usr/sbin/mmc-mount.bak

    Move the start/stop scripts and make them executable and owned by root.

    # mv /home/user/MyDocs/st*-chroot.sh /home/user
    # chown root:root st*-chroot.sh
    # chmod u+x st*-chroot.sh
  5. Now reboot Maemo. Open the terminal and run sudo gainroot to become root. Then try out the chroot. Probably I missed something, but if it works, you will see a Debian bash prompt!

    # ./start-chroot.sh
  6. Before rebooting or halting Maemo, you should shut down everything in the chroot and run (as root, outside of the chroot):

    # ./stop-chroot.sh

Enjoy your Debian chroot, and hopefully future tablets will be able to actually run mainline Linux.

Notes

  • For some reason the backspace key does not work when running screen in the terminal. You can fix this with a line in your screenrc:

    bindkey ^@ stuff "\177"