OS images for USB disks: Difference between revisions

From OLPC
Jump to navigation Jump to search
(cleaned up dedicated USB disk instructions)
(reworked using images an on existing partition)
Line 22: Line 22:
Now you should be able to boot the OLPC operating system off the USB storage device.
Now you should be able to boot the OLPC operating system off the USB storage device.


=== Installing in an existing partition on a USB storage device ===
== USB disk with existing partitions ==


If you don't want to completely wipe the USB stick or hard drive, you can also try transferring the partition within the image file into an existing partition on your storage device. Using dd to transfer the image directly onto the device completely replaces the existing data and partition table. Instead, you can use loopback mounts to copy the partition across and then set-up grub on the device.
Useful notes:


=== Partitioning ===
* Make sure your root partition is ext3, ''not'' ext2
* Label for root partition needs to be OLPCRoot (e.g: "tune2fs -L OLPCRoot /dev/sdb1" to set the label on an existing partition)


Don't follow this set of instructions if you don't know how to partition your disk or create filesystems. There are some things you need to know that the [[OS images]] assume:
If you don't want to completely wipe the USB stick or hard drive, you can also try transferring the partition within the image file into an existing partition on your storage device. Using dd to transfer the image directly onto the device completely replaces the existing data and partition table. Instead, you can use loopback mounts to copy the partition across and then set-up grub on the device.


==== ext3 root filesystem ====
For example, I have a 200GB USB hard disk partitioned into 3 partitions:
* sdb1 - 10GB (for the root filesystem)
* sdb2 - 1.5GB swap partition
* sdb3 - the rest as a storage partition.


Make sure the root partition is the ext3 filesystem, ''not'' ext2.
Retrieve and unzip the appropriate OLPC image file as above. This file contains a partition table, which describes exactly one partition. What we want to do is to mount that partition (using a loopback device) and copy the contents to the USB hard disk, then make that hard disk bootable.

==== ''OLPCRoot'' volume label ====

The OS images look for the volume label ''OLPCRoot' to determine the root FS. You can set this for an ext3 filesystem with:

# tune2fs -L OLPCRoot /dev/sdb1

Where <tt>/dev/sdb1</tt> is the partition containing your root FS.

=== Mounting the image ===

Retrieve and unzip the appropriate OLPC image file as described above. This file contains a partition table, which describes exactly one partition. What we want to do is to mount that partition (using a loopback device) and copy the contents to the USB hard disk, then make that hard disk bootable.


First, we need to setup the image file on a loopback device so we can inspect that partition table:
First, we need to setup the image file on a loopback device so we can inspect that partition table:
Line 42: Line 50:


Now, use fdisk to look at the contents:
Now, use fdisk to look at the contents:

# fdisk -l -u /dev/loop0
# fdisk -l -u /dev/loop0

Disk /dev/loop0: 504 MB, 504626688 bytes
Disk /dev/loop0: 504 MB, 504626688 bytes
16 heads, 32 sectors/track, 1924 cylinders, total 985599 sectors
16 heads, 32 sectors/track, 1924 cylinders, total 985599 sectors
Line 50: Line 60:


In this case, the partition we want starts at sector 32, and each sector is 512 bytes = 16384 bytes into the image file. Now, we can set up a second loopback device to load this partition and mount it:
In this case, the partition we want starts at sector 32, and each sector is 512 bytes = 16384 bytes into the image file. Now, we can set up a second loopback device to load this partition and mount it:

# losetup /dev/loop1 -o 16384 olpc-stream-development-59-20060808_1153-rpm-ext3.img
# losetup /dev/loop1 -o 16384 olpc-stream-development-59-20060808_1153-rpm-ext3.img
# mount -text3 /dev/loop1 /media/tmp/
# mount -text3 /dev/loop1 /media/tmp/

=== Copying files to the new disk ===


Now, copy the files to your USB hard disk:
Now, copy the files to your USB hard disk:

# cd /media/tmp; find | cpio -p --unconditional --preserve-modification-time --dot /media/usbdisk
# cd /media/tmp; find | cpio -p --unconditional --preserve-modification-time --dot /media/usbdisk

=== Bootloader setup ===


And finally, we need to set up grub on the disk to boot from the first partition. We do this using the GRUB shell. Note that in this example, we're installing on (hd1), because the external disk is the 2nd disk connected to the system. When it boots on the OLPC board, it will be the primary disk and grub will treat it as (hd0)
And finally, we need to set up grub on the disk to boot from the first partition. We do this using the GRUB shell. Note that in this example, we're installing on (hd1), because the external disk is the 2nd disk connected to the system. When it boots on the OLPC board, it will be the primary disk and grub will treat it as (hd0)

Revision as of 19:02, 23 August 2006

Dedicated USB disk

If you can devote an entire USB flash drive or hard disk for trying images out, using the images is easy.

To try out an image, simply download the appropriate .img.bz2 file, e.g.,

olpc-stream-development-42-20060714_1709-rpm-ext3.img.bz2

unzip it, and transfer it to a USB storage device via dd, e.g.,

# bunzip2 olpc-stream-development-42-20060714_1709-rpm-ext3.img.bz2
# dd if=olpc-stream-development-42-20060714_1709-rpm-ext3.img of=/dev/sdb bs=1M
# sync

Remember to:

  • Make sure any old partitions from the storage device are unmounted.
  • Do this as the super user / root
  • Replace /dev/sdb with the device file of the USB storage device. The images do contain a partition table and boot loader, so make sure to write to the device and not a partition on the device (e.g. not /dev/sdb1)
  • The USB storage device must be 512 MB or larger. All existing data will be lost.

Now you should be able to boot the OLPC operating system off the USB storage device.

USB disk with existing partitions

If you don't want to completely wipe the USB stick or hard drive, you can also try transferring the partition within the image file into an existing partition on your storage device. Using dd to transfer the image directly onto the device completely replaces the existing data and partition table. Instead, you can use loopback mounts to copy the partition across and then set-up grub on the device.

Partitioning

Don't follow this set of instructions if you don't know how to partition your disk or create filesystems. There are some things you need to know that the OS images assume:

ext3 root filesystem

Make sure the root partition is the ext3 filesystem, not ext2.

OLPCRoot volume label

The OS images look for the volume label OLPCRoot' to determine the root FS. You can set this for an ext3 filesystem with:

# tune2fs -L OLPCRoot /dev/sdb1

Where /dev/sdb1 is the partition containing your root FS.

Mounting the image

Retrieve and unzip the appropriate OLPC image file as described above. This file contains a partition table, which describes exactly one partition. What we want to do is to mount that partition (using a loopback device) and copy the contents to the USB hard disk, then make that hard disk bootable.

First, we need to setup the image file on a loopback device so we can inspect that partition table:

# losetup /dev/loop0 olpc-stream-development-59-20060808_1153-rpm-ext3.img 

Now, use fdisk to look at the contents:

# fdisk -l -u /dev/loop0
 Disk /dev/loop0: 504 MB, 504626688 bytes
 16 heads, 32 sectors/track, 1924 cylinders, total 985599 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Device Boot      Start         End      Blocks   Id  System
 /dev/loop0p1        32      985599      492784   83  Linux

In this case, the partition we want starts at sector 32, and each sector is 512 bytes = 16384 bytes into the image file. Now, we can set up a second loopback device to load this partition and mount it:

# losetup /dev/loop1 -o 16384 olpc-stream-development-59-20060808_1153-rpm-ext3.img
# mount -text3 /dev/loop1 /media/tmp/

Copying files to the new disk

Now, copy the files to your USB hard disk:

# cd /media/tmp; find | cpio -p --unconditional --preserve-modification-time --dot /media/usbdisk

Bootloader setup

And finally, we need to set up grub on the disk to boot from the first partition. We do this using the GRUB shell. Note that in this example, we're installing on (hd1), because the external disk is the 2nd disk connected to the system. When it boots on the OLPC board, it will be the primary disk and grub will treat it as (hd0)

# grub
Probing devices to guess BIOS drives. This may take a long time.
# grub> root (hd1)
root (hd1)
Filesystem type unknown, using whole disk
# grub> root (hd1,0)
root (hd1,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1)
setup (hd1)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd1)"...  15 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.
# grub> ^C
#
  • When I tried booting from this drive on the OLPC, GRUB started but didn't load its configuration correctly - just dropping me into the grub shell instead. I needed to run 'root' and 'setup' again on the actual board to get GRUB to set itself up right. If anyone knows how to avoid this step, please fix the instructions.