[Buildroot] [PATCH 4/4] board/raspberrypi: auto-expand rootfs on first boot

Benoît Thébaudeau benoit.thebaudeau.dev at gmail.com
Mon Aug 31 19:05:42 UTC 2015


Dear Floris Bos,

On Mon, Aug 31, 2015 at 3:25 PM, Floris Bos <bos at je-eigen-domein.nl> wrote:
> On 08/22/2015 10:01 PM, Benoît Thébaudeau wrote:
>> Add init scripts to auto-expand the persistent rootfs on the first boot
>> to fill the medium.
>
>
> Had a look at your script, but think it has more dependencies than strictly
> necessary.

Certainly. I've not tried to optimize dependencies in this patch.

>>   diff --git
>> a/board/raspberrypi/rootfs-overlay/etc/init.d/S22expand-rootpart
>> b/board/raspberrypi/rootfs-overlay/etc/init.d/S22expand-rootpart
>> new file mode 100755
>> index 0000000..7f19e7a
>> --- /dev/null
>> +++ b/board/raspberrypi/rootfs-overlay/etc/init.d/S22expand-rootpart
>> @@ -0,0 +1,36 @@
>> +#!/bin/sh
>> +
>> +case "$1" in
>> +       start)
>> +               echo -n "Expanding the root partition: "
>> +               BLOCK_DEV="/dev/mmcblk0"
>> +               PART_NUM="2"
>> +               PART_START="$(parted -ms "${BLOCK_DEV}" unit s p
>> 2>/dev/null | \
>> +                       grep "^${PART_NUM}:" | cut -d : -f 2 | sed
>> 's/s$//')"
>> +               if [ -z "${PART_START}" ]; then
>> +                       echo "failed"
>
>
> Note that the existing start sector can also be found in
> /sys/class/block/mmcblk0p2/start
> So can remove the parted dependency.

Yes, but we would have to check how portable this is among all Linux
versions if we want to move that to fs/ext2/ or packages/.

[...]

>> diff --git a/configs/raspberrypi2_defconfig
>> b/configs/raspberrypi2_defconfig
>> index 73dc290..2e064e0 100644
>> --- a/configs/raspberrypi2_defconfig
>> +++ b/configs/raspberrypi2_defconfig
>> @@ -3,6 +3,7 @@ BR2_cortex_a7=y
>>   BR2_ARM_EABIHF=y
>>   BR2_ARM_FPU_NEON_VFPV4=y
>>   +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
>
>
> Why is glibc required?
> Isn't it possible to just set the right options (like wchar, largefile) for
> uclibc?

Maybe. It was for e2fsprogs or parted. I will check that.

>>   BR2_TOOLCHAIN_BUILDROOT_CXX=y
>>     BR2_TARGET_GENERIC_GETTY_PORT="tty1"
>> @@ -27,6 +28,13 @@ BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2709-rpi-2-b"
>>   BR2_PACKAGE_RPI_FIRMWARE=y
>>   # BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
>>   +BR2_PACKAGE_E2FSPROGS=y
>> +BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
>> +BR2_PACKAGE_PARTED=y
>> +BR2_PACKAGE_UTIL_LINUX_BINARIES=y
>> +
>> +BR2_ROOTFS_OVERLAY="board/raspberrypi2/rootfs-overlay"
>> +BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi2/post-build.sh"
>
>
> Why is UTIL_LINUX_BINARIES necessary?
> If for fdisk,

Yes.

> doesn't busybox provides this as well?

Yes, it does, and it's selected in the default Busybox configuration
provided by Buildroot and used on RPi. But I've not checked whether it
is compatible with the one from util-linux regarding the command line
interactions. I will check this.

Best regards,
Benoît


More information about the buildroot mailing list