Fail to register logical partition because it overlaps with the extended partition

Sascha Hauer sha at pengutronix.de
Tue Dec 5 02:34:22 PST 2023


Hi Victor,

On Mon, Dec 04, 2023 at 03:04:37PM +0000, Victor BERTIN wrote:
> Hello All,
> 
> We are using Barebox v2022.12.0 on a MSC SM2S-IMX8MP SoM.
> 
> We witness an error happening when registering the first logical partition of our extended partition :
> ERROR: New partition mmc2.4 (0x46600400-0xc68003ff) on mmc2 overlaps with partition mmc2.3 (0x46600200-0x466005ff), not creating it
> ERROR: mmc2: Failed to register partition 4 on mmc2 (-22)
> 
> However, Linux does not complain and all partitions are properly registered :
> [root at imx8-evo:~]# lsblk
> NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
> mmcblk2      179:0    0 14.6G  0 disk
> |-mmcblk2p1  179:1    0   66M  0 part
> |-mmcblk2p2  179:2    0    1G  0 part /
> |-mmcblk2p3  179:3    0   34M  0 part /rwdisk/systemrw
> |-mmcblk2p4  179:4    0    1K  0 part
> |-mmcblk2p5  179:5    0    2G  0 part /rwdisk/app
> |-mmcblk2p6  179:6    0  130M  0 part /var/log
> `-mmcblk2p7  179:7    0   32M  0 part /rwdisk/conf
> mmcblk2boot0 179:32   0    4M  1 disk
> mmcblk2boot1 179:64   0    4M  1 disk
> 
> Since 84ea37e4580cabc2a49edc4e2c62b45a752771fc, extended partitions
> are registered with a size of 2 sectors. Our extended partition still
> manages to overlap with the first logical partition that it contains.
> A simple trick is to reduce the registration size to 1 sector, however
> we are not sure of the side effects of such change.

I don't think this has any side effects. In the end an extended
partition is just a container for logical partitions and should not be
used directly anyway.

I just realized we do not check if the logical partitions actually fit
into the extended partition. It might be better do handle the logical
partitions as children of the extended partition, but I am currently not
very familiar with the code. Anyway, until we are there feel free to
send a patch changing the size of an extended partition to 1 sector.

> 
> Any idea why such issue could happen ?

I am not sure if Linux checks for overlapping partitions at all. From
looking at the code I'd say no.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list