- –output argument is not actually implemented since I think it does not have too much use. If you want to do test without breaking anything, you can dump the disk image, and operate on dumped image instead.
dd if=/dev/mmcblk0 of=emmc.img or
dd if=/dev/reserved of=reserved.img, then you can use ampart on emmc.img or reserved.img. You can do these test on X86-64 platforms with a corresponding binary of ampart, just git clone ampart and make, and you get a X86 executable
- –clone sets a mode clone mode for ampart, it does not mean “clone a partition”, it means, parse anything defined in [partitions], and do a binary replica of it. This is mainly used for recreate a snapshot, but can also be used for certain devices for mass-production (e.g. If you are a manufacturer)
- – snapshot prints the partition layout at the last two lines and early quit. The first of which can be used by human to record, the last of which can be used by scripts to parse around. e.g. You can take a snapshot of mmcblk0 with
ampart --snapshot /dev/mmcblk0. You’ll get the following two snapshots:
a human-readable one that you can record on paper/PC
bootloader:0B:4M:0 reserved:36M:64M:0 cache:108M:512M:2 env:628M:8M:0 logo:644M:32M:1 recovery:684M:32M:1 rsv:724M:8M:1 tee:740M:8M:1 crypt:756M:32M:1 misc:796M:32M:1 boot:836M:32M:1 system:876M:2G:1 data:2932M:4524M:4
a machine friendly one that a script can read and do fancy stuffs based on this (it can get partition name, offset, size, etc)
bootloader:0:4194304:0 reserved:37748736:67108864:0 cache:113246208:536870912:2 env:658505728:8388608:0 logo:675282944:33554432:1 recovery:717225984:33554432:1 rsv:759169024:8388608:1 tee:775946240:8388608:1 crypt:792723456:33554432:1 misc:834666496:33554432:1 boot:876609536:33554432:1 system:918552576:2147483648:1 data:3074424832:4743757824:4
- Proper usage of clone mode is to apply a snapshot to the disk, it is named “clone mode” because the output partition table will be a 1:1 binary replica of the old partition table (or a manipulated one if you are a script and have modified some arguments):
ampart --clone /dev/mmcblk0 bootloader:0B:4M:0 reserved:36M:64M:0 cache:108M:512M:2 env:628M:8M:0 logo:644M:32M:1 recovery:684M:32M:1 rsv:724M:8M:1 tee:740M:8M:1 crypt:756M:32M:1 misc:796M:32M:1 boot:836M:32M:1 system:876M:2G:1 data:2932M:4524M:4
- To actually duplicate a partition, you need to use update mode as this is the mode where only minor details of the old partition table will be changed. You need to select the old partition you want to duplicate and use special operator to define special behaviour
ampart --update /dev/mmcblk0 ^product%:clonedProduct
The command above selects product partition with a ^product selector, if it’s the last one/15th partition, you can also select it with ^14 or ^-1, and the % special operator duplicates the partition just like the two o in the symbol.
After this operation, /dev/clonedProduct and /dev/product will co-exist and is actually two block-devices, however there actually point to the same underlying part of mmcblk0
Also, I’ve already written everything in ampart’s doc and I think you misunderstood the arguments.
ampart [reserved/emmc] ([partition] ...) ([option [optarg]]...)
--snapshot are in-positional arguments (options) that can be placed anywhere
[reserved/emmc] ([partition[...) are positional arguments, the first of the positional arguments is always parsed as path to emmc/reserved/dump images of them, the second onward are always parsed as partitions.
In your case,
--clone enabled clone mode, but ‘product:4462M:128M:1’ is parsed as the path to emmc/reserved/dumped images, and ampart failed to open it as it does not exist.
--snapshot enabled snapshot, ampart will early-quit after it prints the snapshots. So --clone does not work here, as the partitions arguments won’t be parsed (new partitions will only be parsed after a check of snapshot mode).