Bug 1806

Summary: Image Writer: provide an image writer tool to simplify the process of getting images to boot media
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: Darren Hart <dvhart>
Component: meta-yoctoAssignee: Darren Hart <dvhart>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Low CC: dexuan.cui, edwin.zhai, jiajun.xu, josh, kishore.k.bodke, poky.bs.watcher, poky.watcher, sgw, song.liu
Version: unspecified   
Target Milestone: 1.2 M4   
Hardware: x86   
OS: Multiple   
Whiteboard: (P1) (QA Testing Completed) Done
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---
Attachments:
Description Flags
Darren's prototype script none

Description Darren Hart 2011-12-02 15:03:37 UTC
Standard practice is to use the Linux "dd" command to write images to boot media. This can be error prone and the results of sloppy usage can be disastrous. Locating the device you want to use is a clumsy process, especially on a headless build system. I typically tail dmesg and look for which device was added most recently.

I wrote a script (attached) for my own use which does the following:

o Check the image and device exist
o Check the device is writable
o Compare the device to a blacklist and abort if it's listed
o Display useful identifying information about the image and device
o Prompt the user before commencing the write

The output looks something like this:

dvhart@rage:/build/poky/fri2
$ sudo ~/bin/ddimage tmp/deploy/images/core-image-sato-fri2-noemgd.hddimg /dev/sdk
Image details
=============
    image: `tmp/deploy/images/core-image-sato-fri2-noemgd.hddimg' -> `core-image-sato-fri2-noemgd-20111202214038.hddimg'
     size: 318568448 bytes
 modified: 2011-12-02 13:45:05.298897861 -0800
     type: x86 boot sector, code offset 0x58, OEM-ID "SYSLINUX", sectors/cluster 16, root entries 512, Media descriptor 0xf8, sectors/FAT 152, heads 64, hidden sectors 32, sectors 622204 (volumes > 32 MB) , serial number 0x4ed946e0, label: "boot       ", FAT (16 bit)

Device details
==============
  device: /dev/sdk
  vendor: Kingston
   model: DT 101 G2

Write tmp/deploy/images/core-image-sato-fri2-noemgd.hddimg to /dev/sdk [y/N]? y
Writing image...
303+1 records in
303+1 records out
318568448 bytes (319 MB) copied, 53.6766 s, 5.9 MB/s


Joshua and Kishore offered some initial feedback, including adding a feature where the script would present a list of available installation devices and allow the user to select from the list if they didn't provide a device as an argument. Joshua pointed me to https://github.com/abock/image-usb-stick which could provide a decent base for a more elaborate form of the tool.

Please share your thoughts about whether or not such a tool would be useful and what you would like to see it do. I'd want to ensure that it does at least all of the above and remains usable from the command line (but that doesn't preclude it from having a GUI).
Comment 1 Darren Hart 2011-12-02 15:05:37 UTC
Created attachment 285 [details]
Darren's prototype script
Comment 2 Dexuan Cui 2012-01-18 17:41:57 UTC
*** Bug 1737 has been marked as a duplicate of this bug. ***
Comment 3 Dexuan Cui 2012-03-13 06:28:40 UTC
Since we're creating GUI deploy tool(bug 1738), I think we don't need to supply an extra command line tool.
Hi Saul, Song and all, if you agree, can we close the bug, or make a duplicate of bug 1738?
Comment 4 Darren Hart 2012-03-13 16:23:29 UTC
A GUI tool is not a replacement for a cmdline tool. If the GUI tool you are creating cannot be run from the cmdline in an automated way, then we still need a cmdline tool.

Several people build on headless build systems and the GUI adds an unnecessary overhead running the graphics over the network (and libraries that must be installed, etc.). It also doesn't work for people who prefer to script various tasks which may include writing the image.
Comment 5 Dexuan Cui 2012-03-13 16:38:41 UTC
(In reply to comment #4)
> A GUI tool is not a replacement for a cmdline tool. If the GUI tool you are
> creating cannot be run from the cmdline in an automated way, then we still need
> a cmdline tool.
The GUI tool is being integrated as part of the HOB, so it can't run alone from cmdline.

> Several people build on headless build systems and the GUI adds an unnecessary
> overhead running the graphics over the network (and libraries that must be
> installed, etc.). It also doesn't work for people who prefer to script various
> tasks which may include writing the image.
Hi Darren, 
Could you please send your patch to oe-core mailing list? And, can I assign this bug to you? :-) 
I think your patch is good enough to be in poky master.
Comment 6 Darren Hart 2012-03-13 19:17:43 UTC
Patch on yocto mailing list adding ddimage to poky/scripts/contrib
Comment 7 Dexuan Cui 2012-03-14 23:43:31 UTC
(In reply to comment #6)
> Patch on yocto mailing list adding ddimage to poky/scripts/contrib

Darren, thanks!
Comment 8 Jiajun Xu 2012-04-04 13:48:57 UTC
QA tested the tool in 1.2 M4 RC1 testing, it could work well.
Comment 9 Darren Hart 2012-04-09 17:00:40 UTC
In poky master:

commit af193ae15a2ad2e170d4a9d4bcbfff3e429784f5
Author: Darren Hart <dvhart@linux.intel.com>
Date:   Tue Mar 13 12:02:51 2012 -0700

    ddimage: Add script for writing images to boot media