From: Floris Bos <bos@je-eigen-domein.nl>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 4/4] board/raspberrypi: auto-expand rootfs on first boot
Date: Mon, 31 Aug 2015 15:25:46 +0200 [thread overview]
Message-ID: <55E455DA.9050403@je-eigen-domein.nl> (raw)
In-Reply-To: <1440273688-92868-4-git-send-email-benoit@wsystem.com>
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.
>
> 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.
> + else
> + fdisk "${BLOCK_DEV}" <<-EOF &>/dev/null
> + d
> + $PART_NUM
> + n
> + p
> + $PART_NUM
> + $PART_START
> +
> + w
> + EOF
> + echo "done"
> + fi
> + rm -f /etc/init.d/S22expand-rootpart
> + if [ "${PART_START}" ]; then
> + reboot -f
> + while true; do :; done
> + fi
> + exit 2
> + ;;
> + *)
> + echo "Usage: $0 start" >&2
> + exit 1
> + ;;
> +esac
> diff --git a/board/raspberrypi/rootfs-overlay/etc/init.d/S23expand-rootfs b/board/raspberrypi/rootfs-overlay/etc/init.d/S23expand-rootfs
> new file mode 100755
> index 0000000..7b3f286
> --- /dev/null
> +++ b/board/raspberrypi/rootfs-overlay/etc/init.d/S23expand-rootfs
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +
> +case "$1" in
> + start)
> + echo -n "Expanding the root FS: "
> + resize2fs /dev/mmcblk0p2 &>/dev/null
> + ret=$?
> + [ ${ret} -eq 0 ] && echo "done" || echo "failed"
> + rm -f /etc/init.d/S23expand-rootfs
> + exit ${ret}
> + ;;
> + *)
> + echo "Usage: $0 start" >&2
> + exit 1
> + ;;
> +esac
> 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?
> 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, doesn't busybox provides this as well?
Yours sincerely,
Floris Bos
next prev parent reply other threads:[~2015-08-31 13:25 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-19 22:23 [Buildroot] rpi: image generation Benoît Thébaudeau
2015-08-20 7:59 ` Thomas Petazzoni
2015-08-20 14:30 ` Vivien Didelot
2015-08-22 20:01 ` [Buildroot] [PATCH 1/4] configs/raspberrypi: use EABIhf Benoît Thébaudeau
2015-08-22 20:01 ` [Buildroot] [PATCH 2/4] board/raspberrypi: prepare the image files for the target Benoît Thébaudeau
2015-10-17 11:45 ` Yann E. MORIN
2015-10-17 13:52 ` Benoît Thébaudeau
2015-08-22 20:01 ` [Buildroot] [PATCH 3/4] board/raspberrypi: generate a medium image Benoît Thébaudeau
2015-08-22 20:01 ` [Buildroot] [PATCH 4/4] board/raspberrypi: auto-expand rootfs on first boot Benoît Thébaudeau
2015-08-27 9:02 ` Benoît Thébaudeau
2015-08-27 21:22 ` Jérôme Pouiller
2015-08-28 10:36 ` Benoît Thébaudeau
2015-08-28 11:15 ` Benoît Thébaudeau
[not found] ` <4057940.fE2DsQZqLb@sagittea>
2015-08-31 9:11 ` Benoît Thébaudeau
2015-08-31 12:17 ` Floris Bos
2015-08-31 18:53 ` Benoît Thébaudeau
2015-08-31 13:25 ` Floris Bos [this message]
2015-08-31 19:05 ` Benoît Thébaudeau
2015-10-12 21:59 ` [Buildroot] [PATCH 1/4] configs/raspberrypi: use EABIhf Thomas Petazzoni
2015-10-12 23:17 ` Benoît Thébaudeau
2015-10-13 7:06 ` Arnout Vandecappelle
2015-10-15 20:11 ` Peter Korsgaard
2015-10-15 21:12 ` Peter Korsgaard
2015-10-25 15:19 ` [Buildroot] [PATCH] arch/arm: use EABIhf by default with VFP Benoît Thébaudeau
2015-10-25 18:53 ` Peter Korsgaard
2015-10-26 0:32 ` Thomas Petazzoni
2015-10-26 7:47 ` Peter Korsgaard
2015-10-26 8:25 ` Thomas Petazzoni
2015-10-26 8:51 ` Peter Korsgaard
2015-10-25 18:55 ` Peter Korsgaard
2015-10-25 20:27 ` Benoît Thébaudeau
2015-10-25 20:40 ` Peter Korsgaard
2015-10-25 20:52 ` Benoît Thébaudeau
2015-10-25 21:30 ` Yann E. MORIN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55E455DA.9050403@je-eigen-domein.nl \
--to=bos@je-eigen-domein.nl \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox