New issue
Advanced search Search tips

Issue 898946 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 31
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

cros flash: `cgpt` only works inside of the SDK

Project Member Reported by sky@chromium.org, Oct 25

Issue description

On flashing with the image from 72.11189 for caroline I got the following output:

 [######################################################################] 100%
09:08:42: ERROR: Failed copying image to device /dev/sdb
09:08:42: NOTICE: cros flash completed successfully.

The image was in fact good.
 
Components: -Tools>ChromeOS-Toolchain Infra>Client>ChromeOS
Components: -Infra>Client>ChromeOS Infra>Client>ChromeOS>Build
does it happen to you consistently ?  could you rerun with --debug to get more info as to why it failed ?
Here's the output:

14:01:37: DEBUG: Cache dir lookup.
14:01:37: WARNING: The location of Chrome's cache dir has changed. The old path at /secondary/builds/build1/.cros_cache can safely be removed.
14:01:37: DEBUG: Configured cache_dir to '/secondary/builds/build1/src/build/cros_cache'
14:01:37: INFO: Preparing to image the removable device
14:01:37: DEBUG: RunCommand: lsblk --pairs --output NAME,RM,TYPE,SIZE
14:01:38: DEBUG: RunCommand: lsblk --pairs /dev/sdb --output NAME,RM,TYPE,SIZE
Removable device(s) found. Please select/confirm to continue:
  [0]: SanDisk Extreme 58.4G (/dev/sdb)
Please choose an option [0-0]: 0
14:01:39: INFO: Using image /usr/local/google/home/sky/Downloads/chromiumos_test_image.bin
[sudo] password for sky:
 [######################################################################] 100%
14:02:18: DEBUG: RunCommand: sudo 'CROS_CACHEDIR=/secondary/builds/build1/src/build/cros_cache' -- cgpt repair /dev/sdb
sudo: cgpt: command not found
14:02:18: ERROR: Failed copying image to device /dev/sdb
14:02:18: NOTICE: cros flash completed successfully.
sky@sky:/secondary/builds/build1/src$


I'm guessing it's the lack of cgpt. I haven't run ./build/install-build-deps.sh in a while. Was cgpt recently added as a dependency?
Cc: briannorris@chromium.org
Status: Available (was: Untriaged)
Summary: cros flash: `cgpt` only works inside of the SDK (was: cros flash reports conflicting messages)
hmm, cgpt only exists inside of the CrOS SDK

we added this recently:
  https://chromium-review.googlesource.com/1285310

we prob could make this conditional upon cros_build_lib.IsInsideChroot()
I didn't even realize 'cros flash' worked outside the chroot. Sorry :(

It would be nice if the "produce a valid GPT" behavior didn't depend on being in/out of the chroot, but maybe that would OK if we have to.

Can we utilize 'enter_chroot'? The unit tests suggest not, it seems. Are there any other dependencies that are allowed here?
for chrome-sdk flow, people won't have a CrOS checkout let alone even a chroot.  so if we don't have a way of doing this from chromite alone (or some other tool commonly installed in distros), it'll have to be best effort.
Owner: briannorris@chromium.org
Status: Assigned (was: Available)
I'll try to get to this next week (either revert, or confine to chroot-only, probably).

No chance I can rely on {s,}gdisk as a "common tool", can I?
can't rely on gdisk.  something in util-linux would be ok -- fdisk/cfdisk/sfdisk.
Project Member

Comment 10 by bugdroid1@chromium.org, Oct 31

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/chromite/+/6386fdec9f499e98c799a4aa30609e22541c867a

commit 6386fdec9f499e98c799a4aa30609e22541c867a
Author: Brian Norris <briannorris@chromium.org>
Date: Wed Oct 31 03:59:49 2018

cros flash: don't depend on 'cgpt'

While cgpt is a base utility in the CrOS chroot, it is not widely
available on common Linux distributions. 'cros flash' needs to work
outside the chroot for Chromium (browser) development, so let's remove
that dependency.

sfdisk (part of util-linux) has had GPT support since at least version
2.30, but it didn't gain support for fixing resized disks until 2.32
[1]. Anyway, we can do a similar repair by running a basic 'write'
command (echo write | sudo sfdisk <device>). If it fails, we're no worse
off than before -- so just ignore errors, at least until v2.32 is
widespread.

Bonus: recent sfdisk corrects the PMBR size parameters as well, whereas
'cgpt' does not.

[1] See:
    https://github.com/karelzak/util-linux/issues/532

BUG= chromium:898946 
TEST=`cros flash usb:// ...` in and out of chroot; test boot, and verify
     GPT (primary and alternate) look OK (older util-linux won't fix)

Change-Id: I6ef2f3b8510cc521fedf860327f0e12dd3608e8e
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1306377
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[modify] https://crrev.com/6386fdec9f499e98c799a4aa30609e22541c867a/cli/flash.py

Status: Fixed (was: Started)
Should be fixed now. It will still try to do the GPT repair step, but sfdisk should available more widely than cgpt, and even if it fails, we don't complain now. (This fixup step is not absolutely critical, as most software works just fine as long as the primary GPT is mostly correct.)

Do file bugs or reopen if you have more problems! Sorry for the breakage.

Sign in to add a comment