User:NeoAmsterdam/Installing build 8.0.2 to a bootable SD card

From OLPC
< User:NeoAmsterdam
Revision as of 17:01, 13 February 2011 by NeoAmsterdam (talk | contribs) (How did I manage to omit *that*?)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This document will explain how to make a bootable SD card for use with your XO (and then abuse your newfound storage capacity).

Read Me First

Warnings

  • This procedure will erase and overwrite everything stored on the XO and the SD card. Back up your data!
  • Do not execute this procedure on battery power. Any power interruption could lead render your XO irrecoverable.
  • This procedure requires the use of fdisk for partitioning. Do not attempt this procedure if you are a Linux novice.
  • Execute this procedure at your own risk. I will provide clarifications and explanations if requested, but I will not provide tech-support-style help.

Caveats

  • The SD card will be formatted as an ext3 filesystem. This is not an ideal filesystem for SD cards.
  • This document assumes you already have a developer key.
  • This document assumes that fdisk automatically recognizes the starting and ending cylinders for the SD card.
  • The XO may not boot automatically from the SD card if devices are plugged in to the USB slots (I have no idea why this may be).

Notes

  • This document assumes that the USB drive is already formatted as a vfat/ms-dos file system.
  • All the instructions on this page are verbose. Even though it takes longer, it'll allow you to keep tabs on the XO's progress.
  • Children should get permission from a parent, guardian, teacher, and/or Linux guru before attempting this procedure.
    Adult supervision is not required, but is highly recommended.

Requirements

  • An XO
    Obviously.
  • A USB drive
    512 MB is barely large enough, 1 GB will do nicely.
  • An SD card
    512 MB is barely large enough, 1 GB will do, but larger will always be better.
  • A developer's key
    The instructions for obtaining a developer's key can be found here.
  • Internet connectivity
    You will need to download two files.

Optional

  • You will probably want to use a second computer to download two required files and to back up the XO's data.

The Procedure

Safeguarding Your Data

  1. Plug in the USB drive, insert the SD card.
  2. Backup your data by copying files/activities to your USB drive.
  3. Drop into the the console.
    Press ◆ ctrl + ◇ alt + Mesh key f1 small.png f1 to enter the console, then press Key enter.jpg  enter to log in as root.
  4. Determine the USB drive's mount point.
    mount will output a series of mounted devices. Look for something like /dev/sda1 on /media/USB type vfat: make note of the mount point (/media/USB in this example).
  5. Copy the developer key to the USB drive.
    mkdir -pv /media/USB/security ; cp -v /security/develop.sig /media/USB/security
  6. Return to the graphical environment.
    Press ◆ ctrl + ◇ alt + Home key f3 small.png f3.
  7. Enter the Journal and unmount the USB key.
    Unmounting is explained here
  8. Unplug the USB drive.

Acquiring the Software

The directions in this section assume that you're using a second computer.

  1. Backup your data by copying files/activities from your USB drive.
  2. Download fs.zip and os802.img to your USB drive.
    You should now have fs.zip, os802.img, and a folder called security which contains develop.sig on the USB drive.
  3. Eject the USB drive.

The remainder of this document assumes that you're using the XO.

Preparing for Installation

  1. Drop into the the console.
  2. Stop Sugar and the automounting daemon by lowering the runlevel.
    /sbin/init 3
  3. Determine mounted devices
    mount will list all the mounted devices.
    If you see /dev/mmcblk0p1 mentioned, run umount /dev/mmcblk0p1.
    If the XO responds with the device is busy error message, try cd / ; umount /dev/mmcblk0p1.
    If the device still can't be unmounted, stop what you're doing - you cannot proceed any further.
  4. Quick-format the SD card
    dd if=/dev/zero of=/dev/mmcblk0 bs=512 count=8
  5. Paritition the SD card
    fdisk /dev/mmcblk0
    You will now be running fdisk interactively. Create a new primary partition that runs the length of the drive, flag it as bootable, make sure it's type 83 (Linux), and write the changes.
  6. Format the SD card
    mkfs.ext3 -L "OLPC-SD" /dev/mmcblk0p1
  7. Turn off the XO
    shutdown -h now

Installing the OS

  1. With the XO powered off, plug in the USB drive.
  2. Hold down all four game keys (, , , and ) while your power on the XO.
    Do note release the four game keys until you see "Release the game keys to continue" at the top of the screen.
    Once you release the game keys, the XO will begin installing the OS to the NAND.
  3. Wait.
    • I recommend setting up a fresh pot of coffee during this intermission. By the time you turn on the coffee machine, the XO will present you with the registration screen.
  4. Drop into the the console.
    ◆ ctrl + ◇ alt + Mesh key f1 small.png f1.
  5. Mount the USB drive.
    mkdir /mnt/USB ; mount -t vfat /dev/sda1 /mnt/USB
  6. Mount the SD card.
    mkdir /mnt/SD ; mount -t ext3 /dev/mmcblk0p1 /mnt/SD
  7. Copy the developer key from the USB drive to the SD card.
    cp -rv /mnt/USB/security /mnt/SD
  8. Copy the OS from the NAND to the SD card.
    cp -prv /versions/pristine/802 /mnt/SD
  9. Wait.
    • Remember that fresh pot of coffee you set up a short while ago? Now is the time to pour yourself a cup. By the time you're halfway through the coffee, the XO will be ready for you.
  10. Create the olpc user's home directory.
    mkdir -pv /mnt/SD/home/olpc ; chown -rv olpc:olpc /mnt/SD/home/olpc
  11. Unmount the USB drive and SD card.
    umount /mnt/USB ; unmount /mnt/SD
  12. Remove the temporary directories.
    rmdir -v /mnt/USB /mnt/SD
  13. Restart.
    shutdown -r now

You should now be booting off of the SD card.

Post-Install Tricks

Since you now have a fairly large storage drive, you may want to take advantage of the space to create a swap file or install packages onto the XO that aren't included in the "standard" OS with yum. This post-install section addresses both temptations.

Prevent Package-Induced Chaos

  1. Drop into console and log in as root.
  2. Alter the list of excluded packages.
    Optional: Archive a copy of the exclusion list with bzip2 -v9k /etc/yum/olpc-exclude
    1. nano /etc/yum/olpc-exclude
      You'll want to keep the following on the exclusion list:
      • NetworkManager and all its affiliated files
      • cerebro
      • telepathy
      • Any package beginning with olpc or sugar
      • portaudio
      • initscripts
      • yum
    2. Save /etc/yum/olpc-exclude and yum install your packages.

Creating a Swap File

  • Based upon instructions found here. Please read the instructions regarding /etc/fstab if you want the swap space to be started automatically on startup.
  1. Drop into console and login as root.
  2. Create a blank file ≥256 MB to be used for swap space.
    For some reason (out of memory error?), a large blank file can't be made on demand in one fell swoop. In order to get around this, create a 1 MB file and repeatedly concatenate it to the intended swap file. This example makes a 512 MB swapfile:
    dd if=/dev/zero of=/var/1m bs=1048576 count=1 ; for i in {1..512} ; do echo -en "$i\t"; cat /var/1m >> /var/vm && echo "OK" ; done && rm /var/1m
  3. chmod 600 /var/vm ; mkswap /var/vm
    You now have an on-demand swapfile ready for use via swapon /var/vm.

See Also