Commit Graph

51 Commits

Author SHA1 Message Date
Gilad Arnold
0534a6ec41 image_to_usb.sh: detect and allow to select between candidate images.
The script does not assume a single source image (chromiumos_image.bin)
but detects which images of a list of candidate images are present, and
lets the user select one.  The default choice is the first image in the
list to be detected.  If only one image was detected, it will be
automatically selected.  The list contains the aforementioned standard
image, as well as the default names for recovery, test, factory and
factory install images.  If the script is invoked with --test, --factory
or --factory_install flags, it will only seek for the standard image
(and attempt to generate the desired image from it, as was previously
done).

Also fixed some log messages; option strings; and improved the logic for
unmounting the target device, eliminating an unnecessary message and
a 3 second delay.

BUG=chromium-os:26010
TEST=Tested image_to_usb.sh with different images and flags.
CQ-DEPEND=I53a42a46a3c90fd486fead578bfbae248f64cfc2

Change-Id: I0d2f20dc8d62ce5fa18c10d9f8b51a46b2ddca5d
Reviewed-on: https://gerrit.chromium.org/gerrit/15528
Reviewed-by: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
2012-02-09 15:19:57 -08:00
Gilad Arnold
0ddf0241d4 image_to_usb.sh: cleanup and dead code removal
Migrated function definition to the beginning of the code; some minor
cosmetics.  This is a preliminary fix to the actual feature mentioned in
the cited issue.

BUG=chromium-os:26010
TEST=Executed in chroot environment with various combinations of flags
and connected devices

Change-Id: Ib73328e738ebecc38e6faafbd4feb33ced8804ad
Reviewed-on: https://gerrit.chromium.org/gerrit/15438
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
2012-02-07 23:21:27 -08:00
Gilad Arnold
602d1a17f6 image_to_usb.sh: autodetect a removable target device when none provided.
If no target device is provided, image_to_usb.sh will let the user
select one out of a list of autodetected devices. If only one device is
detected, it will be automatically selected.  Also improves the
descriptors shown for candidate/chosen target device(s), and prints
a noticeable warning when the target device does not appear to be
a USB/MMC one.

Also changed all fail/warning messages to use 'die' and 'warn',
respectively, for compliance with other scripts.  Slightly massaged
error/warning strings to be more compact and to-the-point.

BUG=chromium-os:25878
TEST=Executed in chroot environment with various combinations of flags
and connected devices

Change-Id: If248993b8e6f3bc8654c2c8f25f1e54e7899330d
Reviewed-on: https://gerrit.chromium.org/gerrit/15270
Reviewed-by: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Ready: Gilad Arnold <garnold@chromium.org>
2012-02-07 14:07:04 -08:00
Chris Wolfe
fe7aac1f82 image_to_usb: Add error for missing image
Add a clearer error message if the source image was not found.
This can occur if the --from directory exists, but the selected
image within it does not. An easy case is --from'ing a directory
from a chromeos-images zip.

Previously image_to_usb would copy zero bytes and return success.

BUG=None
TEST=Ran image_to_usb.sh for default, directory and .bin --froms.

Change-Id: I826f2bbc8effd9554f558e517b51cc03b4f832d5
Reviewed-on: https://gerrit.chromium.org/gerrit/15120
Tested-by: Chris Wolfe <cwolfe@chromium.org>
Reviewed-by: Jon Kliegman <kliegs@chromium.org>
Commit-Ready: Chris Wolfe <cwolfe@chromium.org>
2012-02-01 08:12:27 -08:00
Mike Frysinger
3e7245a788 image_to_usb: fix typo in flag checking which eats hard drives
The variable setup is "FLAGS_force_non_usb", not "FLAGS_force_non".
Trying to run this currently results in:
	./image_to_usb.sh: line 189: [: -ne: unary operator expected
	Copying USB image .../chromiumos_image.bin to device /dev/sdb...

This should have instead errored out:
	Error: Device /dev/sdb does not appear to be a USB or MMC disk!

Without this fix, image_to_usb.sh proceeds to corrupt the non-usb
disk (which in my case happened to be a backing store for lvm where
all my source was stored and ext4 not surprisingly barfed).

BUG=None
TEST=`./image_to_usb.sh --board=x86-alex -y --to=/dev/sdb` (where /dev/sdb is a disk) now errors out instead of clobbering data
TEST=`./image_to_usb.sh --board=x86-alex -y --to=/dev/sdc` (where /dev/sdc is USB) still works

Change-Id: Id691846393c02cf199309495ae2080b15626e684
Reviewed-on: https://gerrit.chromium.org/gerrit/14334
Reviewed-by: Zdenek Behan <zbehan@chromium.org>
Reviewed-by: Chris Wolfe <cwolfe@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-01-18 08:59:35 -08:00
Chris Wolfe
e87403d8f8 image_to_usb: Add flag to choose disk by product.
This adds a --to_product flag which chooses the destination
disk with a product value matching the specified pattern.
For the case where a developer is regularly writing to an
external USB drive, the product name may be more stable than
the raw device name.

Also added a help string for the --to flag. This was
accidentally deleted during some refactoring in 2010.

Tested with local cbuildbot internal pfq and manually:
  ./image_to_usb.sh
  ./image_to_usb.sh --to=/dev/sde
  ./image_to_usb.sh --to_product=\*Memory
  ./image_to_usb.sh --to_product=\*  # errors on multiple

BUG=chromium-os:22674
TEST=None

Change-Id: Ie7137e8c605217a3202c46d75896170fc6b7c4a5
Reviewed-on: https://gerrit.chromium.org/gerrit/11322
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Wolfe <cwolfe@chromium.org>
Commit-Ready: Chris Wolfe <cwolfe@chromium.org>
2011-11-09 06:53:02 -08:00
J. Richard Barnette
8b1328b17c Convert various scripts to use get_latest_image
Convert image_to_usb.sh, mod_image_for_recovery.sh, and
mod_image_for_test.sh to use get_latest image; previously these
scripts wouldn't honor the 'latest' symlink.

BUG=None
TEST=re-link 'latest' to an alternate directory; test scripts

Change-Id: Ibb56bb993eae9b6ff9dbfea5090c7cae46f2c133
Reviewed-on: http://gerrit.chromium.org/gerrit/10267
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
2011-10-19 11:05:33 -07:00
Brian Harring
d5d5dbffa1 Fix/standardize exiting if common.sh can't be found
The problem here is that most were doing their exiting w/in a subshell;
exit within a subshell kills the subshell, not the parent.  Not all scripts
were using set -e (which would pick up the failing subshell); as such
just rewriting them to remove the potential via eliminateing the subshelling.

Beyond that, removed a couple of custom (working, although non-standard)
approaches, and removed a duplicate common.sh sourc'ing w/in mk_memento_images.sh

TEST=force 'find_common_sh' to fail, note the scripts fails to exit
BUG=none

Change-Id: Ia1108a091a6399ad6aedd3cade4a107f4411686c
Reviewed-on: http://gerrit.chromium.org/gerrit/3905
Reviewed-by: Brian Harring <ferringb@chromium.org>
Tested-by: Brian Harring <ferringb@chromium.org>
2011-07-22 12:06:59 -07:00
Dave Parker
43395e3a70 Only copy the final image file on local disk if it is not in the default location.
BUG=None
TEST=run with a "--to" path that is the default location where the image is generated.
Verify the final image is not 0 bytes.

Change-Id: Ib9a7feceb17054362f00a813c369564e753cd3ab
Reviewed-on: http://gerrit.chromium.org/gerrit/2988
Tested-by: Dave Parker <dparker@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
2011-06-23 08:49:50 -07:00
Mario Limonciello
1f56fc6481 Add a new SD card image writing script
BUG=none
TEST=Write an image to an SD card

Change-Id: I79f2ab4a30c424ab2fbeee8f2636a4900338bcd8
Reviewed-on: http://gerrit.chromium.org/gerrit/1440
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Mario Limonciello <mario_limonciello@dell.com>
2011-06-08 09:56:29 -07:00
Nick Sanders
f9c49add44 Allow file in --from arg
* mount_gpt_image.sh
* image_to_usb.sh

BUG=chromium-os:12367
TEST=mount w/ --from file, check failure with file and -i, block dev and -i, check unmount, check image_to_usb, check --from dir -i file

Change-Id: I8d8604ee7ee83513edd687b0a66cda44f64db1f8

Review URL: http://codereview.chromium.org/6685101
2011-03-21 18:56:04 -07:00
Simon Glass
142ca06512 Factored out the code to copy an image and modify it for test
into mod_image_for_test.sh rather than slightly different versions
of the same in image_to_usb.sh and image_to_vm.sh

Added a function to get a test image into common.sh

Added --inplace option to mod_image_for_test, which is the default,
and preserves the original behaviour. But using --noinplace it will
now do the copy for you.

Found that chromiumos_image.bin appears throughout the scripts, so added it and the test variant to common.sh

BUG=chromiumos-10126
TEST=run mod_image_for_test.sh with and without --noinplace
run image_to_usb.sh and image_to_vm.sh with both options
test on Seaboard that correct image is provided

Really we should have automated testing for these scripts

Change-Id: I5cfa91792c7fded35e7f4ca8f8f27c6b270817fb

Committed: http://chrome-svn/viewvc/chromeos?view=rev&revision=4fc5227

Review URL: http://codereview.chromium.org/5271010
2011-02-09 13:39:43 -08:00
Greg Spencer
798d75f3be This starts to fix the scripts so that they load from /usr/lib/crosutils
from within the chroot.

It also fixes a number of style issues.

It changes the meaning of cros_workon "list-all" to list all available
packages, and adds "list-live" to list all live packages.

It changes things that load chromeos-common.sh from the installer to
load it from /usr/lib/installer.

BUG=chromium-os:4230
TEST=synced, rebuilt chroot, made packages, made images, built chrome
from source, and wrote an image to a USB stick.

Review URL: http://codereview.chromium.org/6240018

Change-Id: I90c34420af1a64020402bafef8e9e77f56837c02
2011-02-01 22:04:49 -08:00
Hung-Te Lin
7e366a5ed3 crosutils: refine image_to_usb progress output and performance
Adding "-B 4m" to balance pipe (+10% speed on some SD) and -b to make progress more readable.
Since the size report from pv (k=1024) and dd(k=1000) are different, we also disable dd's summary report to prevent confusion.

BUG=none
TEST=executed: ./image_to_usb.sh --from=... --to=/dev/sdX (ok)

Change-Id: I184c4ce2d9a8274079ddb26f0420ccf8f2a674dd

Review URL: http://codereview.chromium.org/3608013
2010-10-08 10:35:10 +08:00
Hung-Te Lin
2ffe2bed8b crosutils: refine imaging output message (as instructions)
image_to_usb has been made to work inside chroot for quite some time
(maybe since http://codereview.chromium.org/1991006), and some special
modes may even require it to be executed inside chroot.
However the output messages were not fixed, so we should remove the
"OUTSIDE CHROOT" alerts.

BUG=none
TEST=manually:
1. executed build_image and verified that output messages is correct, and the image is really built successfully.
2. executed image_to_usb.sh --from=... --to=/dev/sde and verified output messages is correct, and the USB device is really imaged by the given target

Change-Id: I8f4274c5f59a0aa585471469ac285e91c0cead13

Review URL: http://codereview.chromium.org/3519003
2010-10-05 08:15:40 +08:00
Hung-Te Lin
4732d5d0c3 crosutils: Improve dd in image_to_usb.sh
1. add oflags=sync to allow interrupting dd without hanging system I/O for a long time
   (since bs=4M, the speed is almost the same)
2. use pv to provide progress report if available.
   (add pv into host-depends in http://codereview.chromium.org/3608004)

BUG=none
TEST=manually:
1. install pv in chroot, then execute image_to_usb.sh --to /dev/sdX and verified there's progress bar
2. ctrl-c to break the dd process and verified it can stop immediately
3. remove pv from chroot, then execute image_to_usb.sh and verify that it still works

Change-Id: I62fc373a4feee6d7e61897325d9e1e6d84a74d63

Review URL: http://codereview.chromium.org/3581007
2010-10-04 11:01:11 +08:00
Kenneth Waters
e3049de00f build_image: Merge x86 and ARM where possible.
- I looked at all of the x86 and ARM paths through out build image scripts,
  these changes clean up stale comments, stale code, and unforks some small
  things.

BUG=none
TEST=Built images for x86-generic, arm-generic and tegra2-seaboard, booted tegra2-seaboard image.

Review URL: http://codereview.chromium.org/3448022

Change-Id: Ibad2774ff2cbf5f15528454506542b87e43e24a2
2010-09-30 14:20:34 -07:00
Kenneth Waters
cebafd2ec3 image_to_usb: Add an option to install to the USB stick.
- This is needed for devices which use a USB stick or MMC card as their
  primary storage.

BUG=1150
TEST=Installed an image to a MMC card, and copied an image to a MMC card.

Review URL: http://codereview.chromium.org/3337020

Change-Id: Ieb7f7cf7b8f9c608a23c55176c49b6805e08d382
2010-09-10 11:05:26 -07:00
Olof Johansson
b154b37ac8 image_to_usb: List available disks when /dev/sdX is specified
I'm lazy and sometimes copy and paste the output at the end of build_image
verbatim and accidentally include the newline at the end. This gives a
more useful output for that case.

Change-Id: I1a4abefa884a91cb75dfe2779c79b3ef4b60e807

BUG=none
TEST=./image_to_usb --from=../build/images/x86-generic/latest --to=/dev/sdX   (and /dev/sde)

Review URL: http://codereview.chromium.org/3212012
2010-09-01 00:04:25 -05:00
Chris Masone
d72ebe7050 image_to_usb.sh needs to pass --board to mod_image_for_test
At some point, mod_image_for_test started using emerge, but when we
call it from image_to_usb, we don't pass a --board flag...we just
assume the user is using the default_board magic file mechanism.

Review URL: http://codereview.chromium.org/2807028
2010-06-28 19:32:02 -07:00
Tom Wai-Hong Tam
0635a240d2 Sync after dd to disk in image_to_usb script.
Fix the bug happened to me that the script completed but the data haven't completely been written to disk.

Review URL: http://codereview.chromium.org/2831001
2010-06-15 10:29:05 +08:00
Paul Stewart
b227081ef5 Fixed size quotation (size is in 512 bytes blocks)
TEST=Verified against known device size and fdisk output
BUG=none

Review URL: http://codereview.chromium.org/2429004
2010-06-02 09:35:14 -07:00
Paul Stewart
5337440620 Print out disk manufacturer and product while asking user to confirm write to disk
Review URL: http://codereview.chromium.org/2363002
2010-05-28 13:43:48 -07:00
Paul Stewart
66dc143902 Add a few more safeguards to image_to_usb.sh so we don't accidentally overwrite a hard drive. Also without the --to option, list USB drives
I've updated the CL to remove the space in the "] ;".  I'm not sure I understand your "size != 0" comment as if the device is just attached for charging, it won't go through the trouble of becoming a USB storage device.  Will chat in person.

Review URL: http://codereview.chromium.org/2269003
2010-05-27 15:56:42 -07:00
Chris Sosa
d44550272c Cleanup of adding pristine image and fixing of symlinks in developer image.
TEST=Tested with building a new image, looking in the output directory, running
the image and running vi.

Review URL: http://codereview.chromium.org/2075019
2010-05-20 10:14:06 -07:00
Nick Sanders
7c982f7398 Update factory installer, factory test
* Fix build breaks
* Update to work with EFI bios

Review URL: http://codereview.chromium.org/2132008
2010-05-19 22:17:08 -07:00
Chris Masone
99c6a289f4 add the ability to umount automounted devices from within the chroot
Talked to kmixter, and we felt that bindmounting the directory in
which the host os creates mount points for automounted external
devices is the cleanest solution to the inside/outside the chroot problem.
By doing this, image_to_usb can be run from inside the chroot without concern.
That means that (as far as I understand) the factory install flow can all be
done inside the chroot, as well as modding images for test and everything else.

Review URL: http://codereview.chromium.org/1991006
2010-05-11 09:20:00 -07:00
Nick Sanders
7789d34e97 Allow factory install shim to be overlay installed
Make standalone package for factory install, so it can be overlayed on top of an existing image.
Modify mod_image_for_test to do the overlay.

Review URL: http://codereview.chromium.org/1945004
2010-05-05 21:21:15 -07:00
Tom Wai-Hong Tam
bf772cffaa Skip dropping caches in each test and between iterations during factory tests.
Dropping caches (writing back all dirty pages to disk and clearing all the caches) is not necessary for factory tests. It can reduce the latency significantly. The scale is about 27s -> 3s, for running 2 empty tests.

Review URL: http://codereview.chromium.org/1780011
2010-04-29 14:57:37 +08:00
Daniel Erat
dd9818aaad build: Get rid of scary /dev/sdb defaults in scripts.
Choosing a default device is no good; the user should
tell us where the image should be written.

BUG=none
TEST=wrote an image

Review URL: http://codereview.chromium.org/1730012
2010-04-26 09:16:44 -07:00
Daniel Erat
89b029c7c0 build: Re-hide pointless question in image_to_usb.sh --test_image.
Undoes a change from 5c3b457f.  Hardcoding "--yes" in the
call to mod_image_for_test.sh instead of inheriting
image_to_usb.sh's "yes" was intentional.  The user may not
pass --yes to image_to_usb.sh since they want to confirm
that they're writing to the correct device, but they already
told us that they want the image to be modified for test
with --test_image, so there's no reason to ask about it
again.

BUG=none
TEST=ran it

Review URL: http://codereview.chromium.org/1736005
2010-04-22 13:59:07 -07:00
Chris Sosa
6975c665d8 Only cache sudo if outside chroot
Review URL: http://codereview.chromium.org/1709005
2010-04-21 15:39:02 -07:00
Nick Sanders
3c8023380e Allow boot directly into mfg test.
Add feature to mod_image_for_test to patch rootfs.
Change initctl path to get network but no chrome.
./image_to_usb.sh --install_mfg --install_autotest --test_image
which calls ./mod_image_for_test.sh --manuf

Review URL: http://codereview.chromium.org/1542011
2010-04-16 19:53:55 -07:00
Daniel Erat
35aa57a305 build: Suppress stupid question in image_to_usb.sh.
No point in asking the user if they're sure they want
to modify the image for testing when they asked us to
modify it for testing in the first place.

BUG=none
TEST=tried it

Review URL: http://codereview.chromium.org/1520031
2010-04-09 18:51:08 -07:00
Chris Sosa
6c47714d93 Only mod image for test if necessary
Review URL: http://codereview.chromium.org/1606004
2010-04-01 10:51:33 -07:00
Bill Richardson
6dcea16492 Clean up temporary files and directories, add utilities.
Remove the temporary rootfs.image file and others that are left by build_image and related scripts. Also added tool to emit scripts that can pack and unpack the combined disk image.

Review URL: http://codereview.chromium.org/1567013
2010-03-31 19:20:24 -07:00
Bill Richardson
4364a2e679 Switch to GPT-format disk images.
This changes the disk image for both USB keys and hard-drive installs to use
the EFI GUID Partition Tables. This is a prequisite for booting with an EFI
BIOS. This change does not use the EFI Boot protocol; it still boots using
Legacy BIOS. The PMBR contains syslinux' gptmbr.bin, which searches the GPT
for a specified partition's GUID to boot.

I've tested it on my EeePC. The USB image works, chromeos-install works, and
the reimaged hard drive works. I have not yet tested the memento_updater.sh
script, but I wanted to start the review without waiting until it's all perfect.
I will also be refactoring build_gpt.sh and chromeos-install to share common
logic.

It's almost certain that all existing dogfood machines will need to be
reimaged from a USB key. We could probably figure out a way to upgrade
automatically, but not quickly or without risk.

In addition to the GPT formatting, the build_image script has changed to
emit a single usb.bin file. This can be copied directly onto a USB key and
booted. Installation of dev tools needs to happen with build_image, not
image_to_usb. I have not yet looked at the other image_to_* scripts.

Review URL: http://codereview.chromium.org/1100001
2010-03-30 14:17:34 -07:00
Chris Sosa
2a696210ca Add installation of stateful partition to scripts
Review URL: http://codereview.chromium.org/1017001
2010-03-26 17:00:07 -07:00
Nick Sanders
229bdeae7e Update location of autotest files in image_to_usb, fix loopback mounting for stateful partition
Review URL: http://codereview.chromium.org/1125004
2010-03-22 14:45:52 -07:00
Chris Sosa
3d11629b01 Changes to enable dev in stateful partition for usb and startup
Review URL: http://codereview.chromium.org/848002
2010-03-11 15:30:38 -08:00
Chris Sosa
8cf12935c5 Cleanup and add open to push test image to usb
Review URL: http://codereview.chromium.org/668170
2010-03-05 11:22:07 -08:00
Chris Sosa
acada7387b Changes to use default board when set by setup_board
Review URL: http://codereview.chromium.org/656023
2010-02-23 15:20:03 -08:00
robotboy
18ff72b913 Create a fourth partition to put the raw kernel image in.
This is a short term fix for machines that can't boot a kernel from
the root file system of an SDCard.

This issue depends on issue 602027.

Review URL: http://codereview.chromium.org/600074
2010-02-11 17:33:32 -08:00
Chris Sosa
431a7904ef Repatch
Review URL: http://codereview.chromium.org/596051
2010-02-10 17:19:24 -08:00
Eric Li
ce1ce9740a This is a resubmit. The original CL was lost due to local disk crashes.
Review URL: http://codereview.chromium.org/551087
2010-01-20 17:01:44 -08:00
Daniel Erat
afc9c8d0b9 Make image_to_usb.sh warn if given a partition.
Review URL: http://codereview.chromium.org/522014
2009-12-27 17:55:29 -08:00
djmm@google.com
dbeea200b4 Mask error if nothing to DEFAULT_FROM.
Review URL: http://chromereview.prom.corp.google.com/1188077


git-svn-id: svn://chrome-svn/chromeos/trunk@275 06c00378-0e64-4dae-be16-12b19f9950a1
2009-11-18 02:43:30 +00:00
tedbo@google.com
182c45ee72 Enable image_to_usb to be run from outside the scripts directory.
Review URL: http://chromereview.prom.corp.google.com/1180043


git-svn-id: svn://chrome-svn/chromeos/trunk@154 06c00378-0e64-4dae-be16-12b19f9950a1
2009-11-04 03:23:20 +00:00
adlr@google.com
1c98ef4e44 Fix image_to_usb.sh, build_image.sh
image_to_usb.sh didn't handle the case where the devices were being
automounted.

build_image.sh didn't handle the case where the version string > ~14
characters.

Review URL: http://chromereview.prom.corp.google.com/1173161

git-svn-id: svn://chrome-svn/chromeos/trunk@108 06c00378-0e64-4dae-be16-12b19f9950a1
2009-10-28 00:00:13 +00:00
adlr@google.com
9cb9e73b2f Install: read-only USB, resizable sys partitions
USB image:
- have a stateful partition
- use a read-only system partition

Installer:
- copy read-only system partition from USB to hard drive, skip fsck check
- make stateful partition empty

System:
- Change to tolerate empty stateful partition on bootup
- Don't keep so much of /var on stateful partition (var/lib should be in system
image)

Autoupdate:
- Fix a couple checks to allow partitions 3 and 4 to be system partitions
- Fix a misnomer in mk_memento_images.sh

Review URL: http://chromereview.prom.corp.google.com/1175102

git-svn-id: svn://chrome-svn/chromeos/trunk@87 06c00378-0e64-4dae-be16-12b19f9950a1
2009-10-26 18:29:06 +00:00