Backup: Difference between revisions

From OLPC
Jump to navigation Jump to search
(avoid conflating need for developer key with unsecured laptop, use correct terms)
No edit summary
Line 9: Line 9:
To backup and restore your GNOME files, drag and drop with a USB drive.
To backup and restore your GNOME files, drag and drop with a USB drive.


To backup the operating system and Sugar environment, use this page.
To backup the operating system, Sugar environment, Journal and GNOME files, use this page. By making a backup of everything on the XO, you can later restore to recover from a mistake or disaster.


Backup is also useful for testing of different software builds; make a backup, test the other build, restore the backup.
This page is for XO users who want to 'backup' the entire storage memory state of their OLPC XO, so that they can do a later 'restore' if needed to recover from a disaster. This is also useful for development testing of different software builds.


However, this is not a reliable method for cloning, because there are unwelcome [[Imaging/Side_effects|side effects]] of restoring a backup on another laptop.
Backup is not an easy method for cloning, because there are unwelcome [[Imaging/Side_effects|side effects]] of restoring a backup on another laptop.


There are two sections depending on what model of XO you have.
XO internal storage has changed over time, to keep costs down. There are sections below depending on what model of XO you have:

* [[#XO_1|XO-1]],
* [[#XO_1.5|XO-1.5]].

There is no documentation here yet for XO-1.75 backup.


= XO-1 =
= XO-1 =


The internal storage of an XO-1 is 1GB of non-removable NAND Flash memory.
Backup the the XO-1's internal 1 GB of NAND Flash memory using the 'save-nand' command in OpenFirmware. If you know of alternate techniques, please write them in a new section of this page.


=== What you will need (besides an XO laptop) ===
=== What you will need (besides an XO laptop) ===
Line 31: Line 36:
Some of these steps are optional, included to boost reliability and confidence. Press the [enter] key after typing commands at the 'ok' prompt.
Some of these steps are optional, included to boost reliability and confidence. Press the [enter] key after typing commands at the 'ok' prompt.


# Reflash to [[OLPC_Firmware_q2f05|Q2F05]] or later, for the best USB support,
# Ensure the USB memory device is formatted as FAT or FAT32 or VFAT. Factory-formatted devices are apparently preferred or least troublesome.
# Ensure the USB memory device is formatted as FAT or FAT32 or VFAT. Factory-formatted devices are apparently preferred or least troublesome.
# Ensure there is at least 1 GB (1024 MB) of free space available on the USB memory device.
# Ensure there is at least 1 GB (1024 MB) of free space available on the USB memory device.
Line 39: Line 45:
# (optional) Type: <tt>disk-free u:</tt> to see if there is enough free space. A full NAND requires 1 GB space on the USB device. A half-full NAND requires about 500 MB. You can estimate that amount of space you need by typing <tt>scan-nand</tt> and looking at the relative percentage of green (used) vs. blue (unused) squares. If you need to free up some space, you can delete files from OFW with, for example, <tt>rm u:\myfile.xyz</tt>. You can also use wildcards, as in <tt>rm u:\*.img</tt>
# (optional) Type: <tt>disk-free u:</tt> to see if there is enough free space. A full NAND requires 1 GB space on the USB device. A half-full NAND requires about 500 MB. You can estimate that amount of space you need by typing <tt>scan-nand</tt> and looking at the relative percentage of green (used) vs. blue (unused) squares. If you need to free up some space, you can delete files from OFW with, for example, <tt>rm u:\myfile.xyz</tt>. You can also use wildcards, as in <tt>rm u:\*.img</tt>
# Type: <tt>save-nand u:\backup.img</tt><br>(The filename 'backup.img' may be something else such as 'my759bak.img'; use a short 8.3 format filename, and stay with the .img extension.)
# Type: <tt>save-nand u:\backup.img</tt><br>(The filename 'backup.img' may be something else such as 'my759bak.img'; use a short 8.3 format filename, and stay with the .img extension.)
# Wait anywhere from a few minutes to a few hours as the XO copies its internal NAND flash memory contents over to the USB memory device. The displayed hexadecimal block count will count from 0 to 1FFF, at a varying speed, then OFW will report 'Done' and report the name of a CRC file such as 'backup.crc'.
# Wait anywhere from a few minutes to a few hours as the XO copies its internal NAND flash memory contents over to the USB memory device. A graphical display of blocks will be shown, with the current block indicated. Below the blocks is a hexadecimal block count, which will count from 0 to 1FFF, at a varying speed. When finished OFW will report 'Done' and report the name of a CRC file such as 'backup.crc'.
# Type: <tt>dir u:</tt> (if you wish to see the final contents of USB memory).
# Type: <tt>dir u:</tt> (if you wish to see the final contents of USB memory).
# Remove the USB memory device. Your backup is now complete.
# Remove the USB memory device. Your backup is now complete.
# You may copy the two files 'backup.img' and 'backup.crc' from the USB memory onto some other media, such as a Windows PC, for redundant backup or to free your USB memory device for other uses. Always keep the two files together.
# You may copy the two files 'backup.img' and 'backup.crc' from the USB memory onto some other media, such as another computer, for redundant backup or to free your USB memory device for other uses. Always keep the two files together.


=== To restore your XO ===
=== To restore your XO ===
Line 53: Line 59:
# Verify that your desired '.img' and '.crc' files are there.
# Verify that your desired '.img' and '.crc' files are there.
# Type: <tt>copy-nand u:\backup.img</tt>
# Type: <tt>copy-nand u:\backup.img</tt>
# Wait til done, then remove the USB memory device, then restart your XO!
# Wait until done, then remove the USB memory device, then restart your XO!


=== Notes ===
=== Notes ===

Revision as of 22:17, 13 November 2011

An XO internal storage contains:

  • an operating system,
  • the Sugar environment,
  • your Journal,
  • your GNOME files.

To backup and restore your Journal, either drag and drop entries to a USB drive, or use the Sugar Backup and Restore activities available in the Sugar Activity Library.

To backup and restore your GNOME files, drag and drop with a USB drive.

To backup the operating system, Sugar environment, Journal and GNOME files, use this page. By making a backup of everything on the XO, you can later restore to recover from a mistake or disaster.

Backup is also useful for testing of different software builds; make a backup, test the other build, restore the backup.

Backup is not an easy method for cloning, because there are unwelcome side effects of restoring a backup on another laptop.

XO internal storage has changed over time, to keep costs down. There are sections below depending on what model of XO you have:

There is no documentation here yet for XO-1.75 backup.

XO-1

The internal storage of an XO-1 is 1GB of non-removable NAND Flash memory.

What you will need (besides an XO laptop)

  • a 1 GB (or larger) USB flash drive
  • if your laptop is secured, a Developer key,
  • 10 minutes to 3 hours (depending on your luck and skill)

To backup your XO-1

Some of these steps are optional, included to boost reliability and confidence. Press the [enter] key after typing commands at the 'ok' prompt.

  1. Reflash to Q2F05 or later, for the best USB support,
  2. Ensure the USB memory device is formatted as FAT or FAT32 or VFAT. Factory-formatted devices are apparently preferred or least troublesome.
  3. Ensure there is at least 1 GB (1024 MB) of free space available on the USB memory device.
  4. Insert your USB memory device into one of the USB ports on the XO.
  5. Start or restart your XO, while holding down the (X) Escape key at upper-left of the keyboard. This should get you to the OpenFirmware Ok prompt. (This won't work if the laptop is secured)
  6. (optional) At the OFW 'ok' prompt, type: probe-usb
  7. (optional) Ensure your USB device shows up as a USB2 device. USB1 is too slow. (Compare the output of probe-usb with and without the USB memory plugged in.)
  8. (optional) Type: disk-free u: to see if there is enough free space. A full NAND requires 1 GB space on the USB device. A half-full NAND requires about 500 MB. You can estimate that amount of space you need by typing scan-nand and looking at the relative percentage of green (used) vs. blue (unused) squares. If you need to free up some space, you can delete files from OFW with, for example, rm u:\myfile.xyz. You can also use wildcards, as in rm u:\*.img
  9. Type: save-nand u:\backup.img
    (The filename 'backup.img' may be something else such as 'my759bak.img'; use a short 8.3 format filename, and stay with the .img extension.)
  10. Wait anywhere from a few minutes to a few hours as the XO copies its internal NAND flash memory contents over to the USB memory device. A graphical display of blocks will be shown, with the current block indicated. Below the blocks is a hexadecimal block count, which will count from 0 to 1FFF, at a varying speed. When finished OFW will report 'Done' and report the name of a CRC file such as 'backup.crc'.
  11. Type: dir u: (if you wish to see the final contents of USB memory).
  12. Remove the USB memory device. Your backup is now complete.
  13. You may copy the two files 'backup.img' and 'backup.crc' from the USB memory onto some other media, such as another computer, for redundant backup or to free your USB memory device for other uses. Always keep the two files together.

To restore your XO

  1. Start or restart your XO, while holding down the (X) Escape key at upper-left of the keyboard. This should get you to the OpenFirmware 'ok' prompt.
  2. Insert your USB memory device into one of the USB ports on the XO.
  3. At the OFW 'ok' prompt, type: probe-usb
  4. Ensure your USB device shows up as a USB2 device. USB1 is too slow.
  5. Type: dir u:
  6. Verify that your desired '.img' and '.crc' files are there.
  7. Type: copy-nand u:\backup.img
  8. Wait until done, then remove the USB memory device, then restart your XO!

Notes

This procedure becomes easy after you have done it 3 times.

Some brands of USB memory work better than others. Backups in the 10-minute range for half-full XO's are achievable. If save-nand is too slow, then try a different brand of USB memory. Default factory-formatted USB memories are reported to work better than devices that have been reformatted, for example by a Windows PC. If you have a USB memory device that is working well with your XO, try to avoid ever reformatting it; delete files using file delete commands rather than device format commands. FAT filesystems with large cluster sizes (like 16 KiB) are particularly efficient for this purpose. (Don't use ext2 filesystems if your OFW version is Q2E15 or earlier; the OFW write support for ext2 in those versions is buggy and inefficient.)

There are variations possible, for example using an SD flash memory device (use sd: instead of u: for the OFW commands). But a USB memory device will generally be more convenient.

Accessing individual files from a backup.img file generally requires you to restore the entire backup to your XO. Albeit complicated, you could also access individual files using the procedure described on the Image forensics page, to mount your image and recover individual files.

OpenFirmware is designed to be simple, reliable, and powerful, but not idiot-proof. Using the recipe given above will usually work well. Deviations could make trouble or confusion unless you know what you are doing. You have been warned!

Another approach

You can boot a different Linux distribution from a USB drive, mount the XO-1's NAND file system, then use a backup utility such as the tar command to back up its files.

This is similar to what the xo-backup command in the XO version of Tiny Core Linux does, although that is specific to the #XO-1.5.

XO-1.5

The January 2011 release of the XO-1.5 Tiny Core Linux build contains three scripts for backup and restore.

Disable Security

Most XO-1.5 laptops have security disabled by default. This procedure requires security to be disabled.

Prepare USB drive

  • select a USB drive of at least 128 MB, which will contain Tiny Core Linux,

That's it. You can delete the .tar file if you don't need to keep it. You will see a folder boot with three files; vmlinuz, initrd, and olpc.fth. OpenFirmware reads the olpc.fth file when the laptop turns on, and this file directs it to load vmlinuz and initrd, which contain the rest of Tiny Core Linux.

Shutdown

Shutdown the laptop in the usual way. This is so that it can be booted from the USB drive.

Start Tiny Core Linux

  • insert the USB drive into the laptop,
  • start the laptop, you will see a white screen, then a black screen with a penguin, then a prompt;
root@box:~# 

At this point you may remove the USB drive if you do not need it for the next step.

Backup

  • insert a USB drive of at least 4 GB capacity, (the backup should not be larger than the size of the internal microSD card, which in most cases is 4 GB, but may be as small as 1.4 GB if there is very little added content or activities on the laptop),
  • start the backup by typing xo-backup then press enter;
root@box:~# xo-backup
ok
root@box:~# 
  • when the ok is displayed, it means the backup has completed properly.

It usually takes ten minutes for a USB flash drive, and five minutes for a USB hard drive. It will take longer if you have added activities, downloads or documents to the laptop.

Remove the USB drive, and look at it with another computer; the backup is in a file xo.tar. You may wish to copy it to other media for safekeeping. Also copy Tiny Core Linux and these instructions, since you may need both to restore.

Restore

WARNING: this destroys all data on the internal microSD card.

  • either leave the USB drive in place, or insert another USB drive instead, one with an xo.tar file on it from the backup step above,
  • start the restore by typing xo-restore then press enter;
root@box:~# xo-restore
ok
root@box:~# 
  • when the ok is displayed, it means the restore has completed properly.

It usually takes between 22 and 40 minutes to restore, depending on the size of the backup, and the speed of the microSD card. The microSD card is usually much slower at writing than reading.

Repartition and Restore

WARNING: this destroys all data on the internal microSD card.

This creates the partition table again on the microSD card. This should only be necessary if the partition table on the microSD card is incorrect. Do this before xo-restore. Like so:

root@box:~# xo-repart
ok
root@box:~# xo-restore
ok
root@box:~#