Skip to content

losetup: support building rootfs images with 4096 byte sector sizes

Administrator requested to merge sector-size into master

Adds an optional deviceinfo variable, deviceinfo_rootfs_image_sector_size, which specifies the logical sector size of the device's storage.

Some devices made after 2016 with UFS storage uses 4096 byte sectors instead of the normal 512 bytes. The partition table in our rootfs must match, otherwise the root filesystem won't mount on the device.

This change passes the sector size to losetup when creating the image if the deviceinfo specifies it, so the image will have the correct sector size.

If the deviceinfo doesn't specify the new option, the behaviour is the same as previous versions of pmbootstrap.

Note that the sector size option only works on Linux 4.14 and above, so pmbootstrap should be run on a >4.14 computer when installing to devices with non-standard sector size.

To find if a device needs this parameter, run fdisk -l on the device. If the output shows

Note: sector size is 4096 (not 512)

then add deviceinfo_rootfs_image_sector_size="4096" to the deviceinfo.

This is needed by the Pixel 3 XL (google-crosshatch) port.

See #1696 (closed).


@ollieparanoid: I copied your sample code, but moved the int() conversion to later since I think int("") throws an error.

I tested making a build for a device without the param (huawei-angler) and the partitions have the right size when I did a fdisk -l on it.

I then tested making a build for the Google Pixel 3 with the parameter set to 4096, and the resulting image has correct partitions when I do a fdisk -l -b 4096 on it, as it should be.

There's a few other devices known to use 4096 byte sectors: for example, this might help the Google Pixel (first generation) port.

Also trying to condense the explanation of the param so it fits on the deviceinfo page. Maybe I'll just link to this pull request...

Edited by Administrator

Merge request reports

Loading