[Android Q&A, Help & Troubleshooting] wgnv5921:
Hello,

I'm trying to reconstruct/repack the original super partition using lpmake after unpacking the original super partition using lpunpack.

This is what I have done.

First, I dumped the super partition using dd via adb shell to a file called super.img.

Second, I ran lpdump on slot 0. It gave me the following,

# lpdump ../super.img -s 0
Slot 0:
Metadata version: 10.0
Metadata size: 540 bytes
Metadata max size: 65536 bytes
Metadata slot count: 2
Header flags: none
Partition table:
------------------------
Name: system
Group: qti_dynamic_partitions
Attributes: readonly
Extents:
0 .. 2082975 linear super 2048
2082976 .. 2083047 linear super 5025000
------------------------
Name: vendor
Group: qti_dynamic_partitions
Attributes: readonly
Extents:
0 .. 553583 linear super 2085024
------------------------
Name: product
Group: qti_dynamic_partitions
Attributes: readonly
Extents:
0 .. 2386391 linear super 2638608
------------------------
Super partition layout:
------------------------
super: 2048 .. 2085024: system (2082976 sectors)
super: 2085024 .. 2638608: vendor (553584 sectors)
super: 2638608 .. 5025000: product (2386392 sectors)
super: 5025000 .. 5025072: system (72 sectors)
------------------------
Block device table:
------------------------
Partition name: super
First sector: 2048
Size: 2684354560 bytes
Flags: none
------------------------
Group table:
------------------------
Name: default
Maximum size: 0 bytes
Flags: none
------------------------
Name: qti_dynamic_partitions
Maximum size: 2680160256 bytes
Flags: none
------------------------

I noted that the first partition entitled "system" has two extents.

Third, I ran lpunpack (with no arguments) on the super partition image file. It produced three image files - system.img, vendor.img and product.img. And I also ran some dd commands to split the system.img file up as per the extents noted in the lpdump.

dd if=../stock-image-dd-by-me/super/system.img of=system_0.raw.img bs=512 count=2082976
dd ibs=512 skip=2082976 if=../stock-image-dd-by-me/super/system.img of=system_1.raw.img bs=512 count=72

Fourth, I tried to re-assemble these image files using lpmake. I used the following command,

lpmake \
--block-size=4096 \
--super-name super \
--metadata-size 65536 \
--metadata-slots 2 \
--group=qti_dynamic_partitions:$(( `stat -c '%n %s' ../stock-image-dd-by-me/super/system.img | awk '{ print $2 }'` + `stat -c '%n %s' ../stock-image-dd-by-me/super/vendor.img | awk '{ print $2 }'` + `stat -c '%n %s' ../stock-image-dd-by-me/super/product.img | awk '{ print $2 }'` )) \
--device=super:2684354560:512:0 \
--output=./super.sparse.img \
--partition=system:readonly:`stat -c '%n %s' system_0.raw.img | awk '{ print $2 }'`:qti_dynamic_partitions \
--image=system=system_0.sparse.img \
--partition=vendor:readonly:`stat -c '%n %s' ../stock-image-dd-by-me/super/vendor.img | awk '{ print $2 }'`:qti_dynamic_partitions \
--image=vendor=vendor.sparse.img \
--partition=product:readonly:`stat -c '%n %s' ../stock-image-dd-by-me/super/product.img | awk '{ print $2 }'`:qti_dynamic_partitions \
--image=product=product.sparse.img \
--partition=systeX:readonly:`stat -c '%n %s' system_1.raw.img | awk '{ print $2 }'`:qti_dynamic_partitions \
--image=system=system_1.sparse.img \
--sparse

And a lpdump of the image generated by the above command is,

# lpdump super.raw.img
Slot 0:
Metadata version: 10.0
Metadata size: 592 bytes
Metadata max size: 65536 bytes
Metadata slot count: 2
Header flags: none
Partition table:
------------------------
Name: system
Group: qti_dynamic_partitions
Attributes: readonly
Extents:
0 .. 2082975 linear super 536
------------------------
Name: vendor
Group: qti_dynamic_partitions
Attributes: readonly
Extents:
0 .. 553583 linear super 2083512
------------------------
Name: product
Group: qti_dynamic_partitions
Attributes: readonly
Extents:
0 .. 2386391 linear super 2637096
------------------------
Name: systeX
Group: qti_dynamic_partitions
Attributes: readonly
Extents:
0 .. 71 linear super 5023488
------------------------
Super partition layout:
------------------------
super: 536 .. 2083512: system (2082976 sectors)
super: 2083512 .. 2637096: vendor (553584 sectors)
super: 2637096 .. 5023488: product (2386392 sectors)
super: 5023488 .. 5023560: systeX (72 sectors)
------------------------
Block device table:
------------------------
Partition name: super
First sector: 536
Size: 2684354560 bytes
Flags: none
------------------------
Group table:
------------------------
Name: default
Maximum size: 0 bytes
Flags: none
------------------------
Name: qti_dynamic_partitions
Maximum size: 2571788288 bytes
Flags: none
------------------------

I know the "systeX" partition is incorrect and should not be there. I'm only temporarily creating it so that I know my size calculations for the missing second extent are correct.

Anyway, this is where I am stuck.

I need help with-

1. Creating a partition with multiple extents using lpmake (or such other more appropriate tools); and

2. Offsetting the first partition by 2048 using lpmake (or such other more appropriate tools).

Many thanks in advance!