factory: Support partx for partition manipulation. |
||||
Issue descriptionChrome Version: (copy from chrome://version) OS: (e.g. Win7, OSX 10.9.5, etc...) What steps will reproduce the problem? What is the expected result? What happens instead? The usages of cgpt and parted is scattered in the source. Let's try to give an integrated class for all the usages.
,
Feb 15 2017
I already had some CLs in local, an interface to query partition info. It basically a wrapper to cgpt or partx (depends on which util exists in the envronment) After doing some manual tests, I found that partx cannot read the GPT of the file, which generated from the function "ConvertChromeOSImageToMiniOmahaFormat" in py/umpire/commands/update.py (Looks like partx cannot recognize the label, so does parted, and parted can print more information(start,size,...) then error at reading label name.) So, should we still need to change these cgpt usages in this file? If the cgpt exists in the system, then no problem. If it doesn't, it will fail since the interface will try to use partx to read partition offset and size.
,
Feb 15 2017
> partx cannot read the GPT of the file, which generated from the function "ConvertChromeOSImageToMiniOmahaFormat" I don't understand. ConvertChromeOSImageToMiniOmahaFormat does not use label (is it?) And, partx recognizes label as NAME in my test (both block file and image files are fine).
,
Feb 16 2017
> I don't understand. ConvertChromeOSImageToMiniOmahaFormat does not use label (is it?)
Yes, it doesn't.
I put the file (generated from update_unittest.py) in attached.
> the output of `cgpt show -i 4 tmp.file` (`-i 4` is the given partition index in the unit tests)
start size part contents
210 16 4 Label: "KERN-B"
Type: ChromeOS kernel
UUID: C4DCA93D-6DDB-804C-BA65-E13E250BB37A
Attr: priority=0 tries=0 successful=0
the output of `partx -r -g -n 4 -o SIZE -b tmp.file`
partx: /tmp/tmp.file: failed to read partition table
> the output of `parted -l tmp.file` (print error at the last)
Model: ATA MTFDDAK1T0MBF-1A (scsi)
Disk /dev/sda: 1024GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 258MB 256MB fat32 EFI System Partition boot
3 258MB 770MB 512MB ext2 boot
4 770MB 1024GB 1023GB
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/dhcp--100--102--7--168--vg-swap_1: 68.6GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Number Start End Size File system Flags
1 0.00B 68.6GB 68.6GB linux-swap(v1)
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/dhcp--100--102--7--168--vg-usr+local+google: 871GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Number Start End Size File system Flags
1 0.00B 871GB 871GB ext4
> the output of
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/dhcp--100--102--7--168--vg-root: 60.0GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Number Start End Size File system Flags
1 0.00B 60.0GB 60.0GB ext4
Error: /dev/mapper/sda4_crypt: unrecognised disk label
> the output of `parted tmp.file print all` (give some warning that the file is corrupted.
Warning: /usr/local/google/home/yllin/projs/cros/internal_repo/chroot/tmp/tmp.file contains GPT signatures, indicating that it has a GPT table. However, it does not have a valid fake msdos partition table, as it should. Perhaps it was
corrupted -- possibly by a program that doesn't understand GPT partition tables. Or perhaps you deleted the GPT table, and are now using an msdos partition table. Is this a GPT partition table?
parted: invalid token: all
Yes/No? yes
Model: (file)
Disk /usr/local/google/home/yllin/projs/cros/internal_repo/chroot/tmp/tmp.file: 149kB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 82.9kB 65.5kB STATE msftdata
2 82.9kB 91.1kB 8192B KERN-A
3 91.1kB 108kB 16.4kB ROOT-A
4 108kB 116kB 8192B KERN-B
5 116kB 132kB 16.4kB ROOT-B
,
Feb 16 2017
> I put the file (generated from update_unittest.py) in attached. So the problem is in unittest, not in the code itself. We are ok to use cgpt in unittest (see the discussion in original CL) > the output of `parted -l tmp.file` (print error at the last) Wrong usage. -l indicates parted to read all block devices on your machine, not the given file. > However, it does not have a valid fake msdos partition table, as it should. Can be solved by adding "cgpt boot -p tmp.file" when creating the file. > partx: /tmp/tmp.file: failed to read partition table I can run partx on a standard chromiumos image (partx chromiumos_test_image.bin) so there's probably something else wrong - either we didn't create the file using CGPT in a way that partx is happy, or partx has some limitation. Comparing strace shows that partx is trying to read wrong sector (#31) and found \0*512, while on chromiumos image it happily tries first GPT table sector (#2=1024). Maybe revise how we create the unittest file by following chromiumos disk image creation script, or trace partx C to find out what goes wrong.
,
Feb 16 2017
> So the problem is in unittest, not in the code itself. > We are ok to use cgpt in unittest (see the discussion in original CL) Ok, I see. > Wrong usage. -l indicates parted to read all block devices on your machine, not the given file. Thanks for your hint! Another question: py/gooftool/common.py: There are many cgpt usages here, such as GetCgptAttributes,SetCgptAttributes, or modify partition flags, some of them can't be done with partx. So, should we replace these cgpt queries to the queries to the new interface, and leave the modification usage as it was?
,
Feb 16 2017
I think we don't need to change gooftool since it's very chromeos specific that cgpt should be available. Let's focus on programs outside gooftool.
,
Feb 17 2017
Add Factory to Components
,
Feb 17 2017
,
Feb 17 2017
BTW, I've searched partx source. The GPT probing in partx has a restriction .minsz = 1024 * 1440 + 1, /* ignore floppies */ So you should change unit test to be larger than the size and then you can use partx on it.
,
Feb 22 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/factory/+/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252 commit e8f107f5d36cf84c3fdc19fdf530f14d66f3f252 Author: Yilun Lin <yllin@google.com> Date: Wed Feb 22 11:29:27 2017 utils: Add PartitionManager. A wrapper for cgpt and partx for query partition info. Support partx query in testUpdateFSIFromChromeOSImage. BUG= chromium:691486 TEST=make test Change-Id: I1a7f71746c59eec10399d397753da5f316a96d06 Reviewed-on: https://chromium-review.googlesource.com/441569 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/test/pytests/partition_table.py [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/test/pytests/bad_blocks.py [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/umpire/commands/update_unittest.py [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/umpire/commands/update.py [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/utils/sys_utils.py
,
Feb 22 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/factory/+/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252 commit e8f107f5d36cf84c3fdc19fdf530f14d66f3f252 Author: Yilun Lin <yllin@google.com> Date: Wed Feb 22 11:29:27 2017 utils: Add PartitionManager. A wrapper for cgpt and partx for query partition info. Support partx query in testUpdateFSIFromChromeOSImage. BUG= chromium:691486 TEST=make test Change-Id: I1a7f71746c59eec10399d397753da5f316a96d06 Reviewed-on: https://chromium-review.googlesource.com/441569 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/test/pytests/partition_table.py [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/test/pytests/bad_blocks.py [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/umpire/commands/update_unittest.py [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/umpire/commands/update.py [modify] https://crrev.com/e8f107f5d36cf84c3fdc19fdf530f14d66f3f252/py/utils/sys_utils.py
,
Feb 24 2017
|
||||
►
Sign in to add a comment |
||||
Comment 1 Deleted