Image replicator intro

From embeddedTS Manuals
Revision as of 19:43, 7 February 2022 by Kris (talk | contribs) (Initial creation, still WIP)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This platform supports our Image Replicator tool. The Image Replicator tool is intended for use by our end customers as a means to format and load bootable images or filesystems on to a device's media as part of their production process. In addition to writing media, the Image Replicator tool is capable of capturing images from a unit. This golden image can then be used to write other units.

The Image Replicator tool is a bootable USB drive based on Busybox with a set of scripts to handle the capture and write processes. This process, however, is flexible and can be used as-is or adapted in to larger production processes to format and load data on to devices. The single USB drive can be used to capture images from a unit, and then can be inserted in to other units to write those same images back to other devices.


Image Capture Process

1. Once booted, the scripts check to see if any valid images files exist on the drive. If none do, then it starts the capture process. 2. For each media present (eMMC, SD, SATA, etc.), the tool will repeat the following steps 3 through 7 3. Copy the whole disk image to an appropriately named file on the USB drive, e.g. sdimage.dd, no data is written to the source media and it is never mounted. The source disk can follow our stock partition layout, or implement a customized one. 4. Perform an fsck on the Linux rootfs in the image file. Note that, if deviating from our standard partition layout, it may be necessary to modify the scripts handling the capture process. 5. Perform a loopback mount of the Linux rootfs in the image file and sanitize the filesystem. The sanitization process removes temporary files (e.g. /log/ files), unique files (e.g. ssh private key files, machine ID files), adds a file to indicate that it is a custom image with the date as its contents, etc. The full list of operations can be found in this script. It may be necessary to modify this file. 6. If the partition layout uses only a single partition, the filesystem is packed in to a tarball which is appropriately named and compressed, e.g. sdimage.tar.xz. The image file is then unmounted and removed. 7. If the partition layout uses multiple partitions, then /dev/zero is written to a single file, flushed to disk, and removed. This is to create large areas of null bytes on disk for better compression. The image file is then unmounted, an md5sum of the image file taken, compressed to an appropriately named file, e.g. emmcimage.dd.xz, and then an md5sum of the compressed image is taken. 8. After all images are captured, indicate that the process is done.

Note that when using this process, the USB drive used must be sized large enough to handle multiple compressed images as well as the uncompressed copy of the media image actively being worked with. If the image capture process runs out of space, the process will indicate a failure.