main/postmarketos-mkinitfs: not able to resize root partition backed by device mapper
Right now i am unsure if this affects any kinds of device mapper partitions or not.
The issue described here is affecting SHIFT6mq (axolotl)
, which has support enabled for dynamic partitions
.
axolotl uses dynamic partitions, which means it has a phyiscal This is a It is possible to resize the logical partitions, remove and create partitions using For example As it is also an postmarketOS can be installed in a logical partition since dynamic partition support has landed. However a lot of usable space will be lost without resizing.
You can delete all partitions and resize / create a new one to be used by postmarketOS. For example to delete all logical partitions (on slot B) and resize the This is also the configuration used with this issue.Click me to show some more background information
super
partition, which contains multiple logical partitions.lpdump
with Android installed on Slot A
and postmarketOS installed on Slot B
.axolotl:/ # lpdump
Slot 0:
Metadata version: 10.0
Metadata size: 716 bytes
Metadata max size: 65536 bytes
Metadata slot count: 3
Header flags: none
Partition table:
------------------------
Name: product_a
Group: axolotl_dynamic_partitions_a
Attributes: readonly
Extents:
0 .. 4225695 linear super 3072
------------------------
Name: system_a
Group: axolotl_dynamic_partitions_a
Attributes: readonly
Extents:
0 .. 1852623 linear super 5288448
------------------------
Name: system_b
Group: axolotl_dynamic_partitions_b
Attributes: readonly
Extents:
0 .. 4227071 linear super 12584448
------------------------
Name: system_ext_a
Group: axolotl_dynamic_partitions_a
Attributes: readonly
Extents:
0 .. 1056959 linear super 4230144
------------------------
Name: vendor_a
Group: axolotl_dynamic_partitions_a
Attributes: readonly
Extents:
0 .. 991999 linear super 7142400
------------------------
Super partition layout:
------------------------
super: 3072 .. 4228768: product_a (4225696 sectors)
super: 4230144 .. 5287104: system_ext_a (1056960 sectors)
super: 5288448 .. 7141072: system_a (1852624 sectors)
super: 7142400 .. 8134400: vendor_a (992000 sectors)
super: 12584448 .. 16811520: system_b (4227072 sectors)
------------------------
Block device table:
------------------------
Partition name: super
First sector: 2048
Size: 12884901888 bytes
Flags: none
------------------------
Group table:
------------------------
Name: default
Maximum size: 0 bytes
Flags: none
------------------------
Name: axolotl_dynamic_partitions_a
Maximum size: 6438256640 bytes
Flags: none
------------------------
Name: axolotl_dynamic_partitions_b
Maximum size: 6438256640 bytes
Flags: none
------------------------
fastbootd
axolotl
's super
partition has a total size of 12884901888
.
To account for overhead and error correction, the total usable size is 12876513280
.A/B device
, it contains two groups, each with the size of 6438256640
(12876513280 / 2 -> 6438256640
).system
partition to the max usable space:
fastboot delete-logical-partition product_b
fastboot delete-logical-partition system_ext_b
fastboot delete-logical-partition vendor_b
fastboot resize-logical-partition system_b 6438256640
When resizing the root partition, init looks up all devices in /dev/mappper
.
Please refer to the code at the time of writing this issue.
When trying to get the physical partition of the mapped device, it assumes that the device exists in /dev
whereas for this case with axolotl
it is actually located in /dev/mapper
/ # find_root_partition
/dev/mapper/system_b2
/ # resize_root_partition
Error: Could not stat device /dev/system_b - No such file or directory.
/ # find /dev -name "*system*"
/dev/mapper/system_b2
/dev/mapper/system_b1
/dev/mapper/system_ext_a
/dev/mapper/system_b
/dev/mapper/system_a
/ # parted -s /dev/mapper/system_b print free
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/system_b: 6438MB
Sector size (logical/physical): 4096B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
36.9kB 8389kB 8352kB Free Space
1 8389kB 256MB 247MB primary ext2 boot
2 256MB 2073MB 1817MB primary ext4
2073MB 6438MB 4365MB Free Space
Bonus: manual steps to resize successfully
pmbootstrap initfs hook_add debug-shell
pmbootstrap flasher flash_kernel
telnet 172.16.42.1
source init_functions.sh
mount_boot_partition /boot
extract_initramfs_extra /boot/initramfs-extra
wait_root_partition
delete_old_install_partition
kpartx -d /dev/mapper/system_b2
parted /dev/mapper/system_b resizepart 2 100%
kpartx -afs /dev/mapper/system_b
parted /dev/mapper/system_b print free
e2fsck -f /dev/mapper/system_b2
resize2fs -f /dev/mapper/system_b2