Creating RevPi image from Stretch lite

Topics about the Software of Revolution Pi
Post Reply
EcoMan
Posts: 19
Joined: 10 Mar 2020, 10:15

Creating RevPi image from Stretch lite

Post by EcoMan »

Hi,

When using ImageBakery to customize an image from a Raspbian Stretch Lite image, after burning the customized image im getting kernel errors and the console cant be reached because the root account is locked.

My base image: 2019-04-08-raspbian-stretch-lite.img
Steps:
1. copied the base image to a working RPi (running clean stretch-lite).
2. Copied the Image bakery repo.
3. Ran the customize_image.sh script.
4. Burned the resulting image onto a RevPI.

Is there anything I'm missing here ? Is there maybe a guide as to how to manually install the needed packages & kernel on the stretch-lite?

Thanks.
User avatar
lukas
Expert
Posts: 186
Joined: 13 Feb 2017, 10:29

Re: Creating RevPi image from Stretch lite

Post by lukas »

Short answer:

The most likely cause is a bug in the libfdisk1 package. You can work around the bug by downloading a fixed version of libfdisk1 from our apt repository and installing it on the machine on which you're invoking customize_image.sh:
https://packages.revolutionpi.de/pool/m ... _armhf.deb
Alternatively, if the machine is a RevPi product (such that /etc/apt/sources.list.d/revpi.list is present), invoke "sudo apt-get update && sudo apt-get upgrade" to install the fixed version along with any other available updates. Yet another alternative is to run customize_image.sh on a 64-bit machine (such as a x86-64 Linux box).

Long answer:

At the end of customize_image.sh, the image is shrunk by invoking sfdisk. That command is linked against libfdisk.so.1, which contains a bug in Raspbian stretch wherein the 32-bit disk identifier cannot be parsed if the most significant bit is set. The disk identifier of 2019-04-08-raspbian-stretch-lite.img is 0xc1dc39e5, so the most significant bit is set. Because the disk identifier cannot be parsed, sfdisk writes a new random disk identifier to the boot sector of the image. You can tell that the bug has occurred by comparing the two disk identifiers in the customize_image.sh output:

Code: Select all

Disk /dev/loop0: 1.7 GiB, 1803550720 bytes, 3522560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc1dc39e5
[...]
>>> Created a new DOS disklabel with disk identifier 0xf8881cbd.
The wrong disk identifier prevents the machine from booting because it is used in /etc/fstab to mount the /boot partition:

Code: Select all

proc            /proc           proc    defaults          0       0
PARTUUID=c1dc39e5-01  /boot           vfat    defaults          0       2
PARTUUID=c1dc39e5-02  /               ext4    defaults,noatime  0       1
The bug was fixed in February 2019 with commit 834b3d07e498. The first release of the libfdisk1 package containing this commit is v2.34, which will be in Raspbian bullseye. We've compiled a custom version of the libfdisk1 package which contains the commit but is otherwise identical to the one shipped with Raspbian stretch (2.29.2-1+deb9u1). The package is automatically installed on a customized image because customize_image.sh invokes apt-get upgrade. The package is necessary because on the first boot, revpi-factory-reset invokes sfdisk to grow the image to the eMMC size.
EcoMan
Posts: 19
Joined: 10 Mar 2020, 10:15

Re: Creating RevPi image from Stretch lite

Post by EcoMan »

Great, thank you very much for the detailed answer!
KoenW
Posts: 24
Joined: 12 May 2019, 16:15
Location: Sydney
Contact:

Re: Creating RevPi image from Stretch lite

Post by KoenW »

Hi Ecoman,

Can I ask you how small you managed to make your RevPi image ?

Regards
Koen
Post Reply