From patchwork Fri Dec 2 10:10:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dagg Stompler X-Patchwork-Id: 701881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tVVKG22zNz9vGJ for ; Fri, 2 Dec 2016 21:10:42 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 51B5483BA8; Fri, 2 Dec 2016 10:10:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iI3XPBMEin-x; Fri, 2 Dec 2016 10:10:37 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 8F5B08380C; Fri, 2 Dec 2016 10:10:37 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id BEF391C0957 for ; Fri, 2 Dec 2016 10:10:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id BB846858C1 for ; Fri, 2 Dec 2016 10:10:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7ZdoW3LURwgi for ; Fri, 2 Dec 2016 10:10:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 6A605858BF for ; Fri, 2 Dec 2016 10:10:35 +0000 (UTC) Received: from NCC-5001-D.Starfleet ([79.177.0.40]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPA (Nemesis) id 0M2tKM-1cW4ru0jw6-00sfjM for ; Fri, 02 Dec 2016 11:10:32 +0100 From: Dagg Stompler To: buildroot@buildroot.org Date: Fri, 2 Dec 2016 12:10:27 +0200 Message-Id: <20161202101028.26736-1-daggs@gmx.com> X-Mailer: git-send-email 2.11.0 X-Provags-ID: V03:K0:u/pdbGg2BXd/2DCAJlAueYyqqTkngbobmC+0M31muKoDpmVvBxp fLefjTx90X04UT1FlNGDibCx0CFRPn+b7ezGOGzOAf5aqHYeLe+VImTG2zmwmxejzh4Dl7g rSITqk1SLYB00XOcKakaru664qf2/Twxzp/D2GAQpeGTUyUJJzafqSvbckRlNrQsP1VJgXJ pmWy1kqaRezLAL5WRKb7w== X-UI-Out-Filterresults: notjunk:1; V01:K0:yw8C7wkFcU0=:VdmBXQcBDFtP+BRk42MKRb TiV5NdpUKqBVOz0G9Z3WwZuxyjBR+pKw0wUf9JMd9QdRK4GrdU00eZ7zA2vsU2HFU5sEvV95a rrUwXjg5nOphxyPbI6YgSiBGxXSiqdLcqutbFdeq7Mql66+8oN8PJqvZpZgbigzOGCXbudVVA GKLe3rzPN65/yGS9JVjKRkzllAR+hON7shFoLeOrE/3BkQqjtIqH0bG2fZ1LQgKLcBY61D5jk peC2nyiJXIb39Ns9MgP4zgyNc0ZU8JbzkpTrQue4nvOmi6Q1ewUi7kbit4tlJMufTnYG5SzlM D3ZmXCH781x34BuFUzpdg/GaU0CchI90hud7mluINXB0tGizm0YHN6rfkzHjx6mOgM/fUsC78 D/ZI6YzOhBj70S4JF8j/TqnLogP/D6lZ26EiebXr+BtpMt29Pj36yDSpOETythQif5ChRwpLp jL7idMApiZrSKehjxpEHV353cyY0NCR7lHu9aEHIOBRI81bcIu3KvsrHHD+DSTCaMuu5lnuYU HGXxRwGXmLhltIWU3FCGJZboRMKCZ1em0WsOasB8CpwMEvg8KEgmFeCwwri1y1Q53fIXD1AFD OZH7ZOf3xDcViGWP/BctqeomqPXZR9FbYKc95qm8EkFyzWUOBce3VXrhmpmwZRLLY691NQcWE xjW1xk0Ap+TfWt4FXdCHGRAvTdgBsJ+lypBOrVQwRYWeOTT33WF/YJll0lvAtqbKywsXeyWQo aK6EQniG7djbUH7bdjUXIfCKe1wm2R8XnSkmiX7e/sZt8Y/9pyfhFoQBpjc= Subject: [Buildroot] [PATCH 1/2] first_boot_rootfs_resizer: New Package. X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" this new package will resize the root fs to the max possible when booting an image for the first time. Signed-off-by: Dagg Stompler --- package/Config.in | 1 + package/first_boot_rootfs_resizer/Config.in | 17 +++++++++ .../first_boot_rootfs_resizer.mk | 23 +++++++++++ package/first_boot_rootfs_resizer/resize_fs.sh | 44 ++++++++++++++++++++++ package/first_boot_rootfs_resizer/resizing | 11 ++++++ 5 files changed, 96 insertions(+) create mode 100644 package/first_boot_rootfs_resizer/Config.in create mode 100644 package/first_boot_rootfs_resizer/first_boot_rootfs_resizer.mk create mode 100644 package/first_boot_rootfs_resizer/resize_fs.sh create mode 100644 package/first_boot_rootfs_resizer/resizing diff --git a/package/Config.in b/package/Config.in index 9ed296f2d..ed414fd3d 100644 --- a/package/Config.in +++ b/package/Config.in @@ -1408,6 +1408,7 @@ menu "Miscellaneous" source "package/collectd/Config.in" source "package/domoticz/Config.in" source "package/empty/Config.in" + source "package/first_boot_rootfs_resizer/Config.in" source "package/gnuradio/Config.in" source "package/googlefontdirectory/Config.in" source "package/gr-osmosdr/Config.in" diff --git a/package/first_boot_rootfs_resizer/Config.in b/package/first_boot_rootfs_resizer/Config.in new file mode 100644 index 000000000..cce62dd39 --- /dev/null +++ b/package/first_boot_rootfs_resizer/Config.in @@ -0,0 +1,17 @@ +config BR2_PACKAGE_FIRST_BOOT_ROOTFS_RESIZER + bool "first_boot_rootfs_resizer" + select BR2_PACKAGE_E2FSPROGS # for resizefs + select BR2_PACKAGE_E2FSPROGS_RESIZE2FS # for resizefs + depends on BR2_USE_WCHAR # util-linux + + help + installs a script that will resize the rootfs to the max possible consecutive size + unused from the end of rootfs. + +config BR2_PACKAGE_FIRST_BOOT_ROOTFS_RESIZER_SYSV_PRIORITY + int "SystemV priority" + depends on BR2_PACKAGE_FIRST_BOOT_ROOTFS_RESIZER + default "0" + + help + set the script's priority (defualt is 00) diff --git a/package/first_boot_rootfs_resizer/first_boot_rootfs_resizer.mk b/package/first_boot_rootfs_resizer/first_boot_rootfs_resizer.mk new file mode 100644 index 000000000..8752831ea --- /dev/null +++ b/package/first_boot_rootfs_resizer/first_boot_rootfs_resizer.mk @@ -0,0 +1,23 @@ +################################################################################ +# +# first_boot_rootfs_resizer +# +################################################################################ + +FIRST_BOOT_ROOTFS_RESIZER_LICENSE = unclear + +FIRST_BOOT_ROOTFS_RESIZER_PRIO = $(shell printf "%02u" $(BR2_PACKAGE_FIRST_BOOT_ROOTFS_RESIZER_SYSV_PRIORITY)) +FIRST_BOOT_ROOTFS_RESIZER_DEPENDENCIES = e2fsprogs + +define FIRST_BOOT_ROOTFS_RESIZER_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 755 package/first_boot_rootfs_resizer/resize_fs.sh \ + $(TARGET_DIR)/usr/sbin/resize_fs.sh + touch $(TARGET_DIR)/.first_boot +endef + +define FIRST_BOOT_ROOTFS_RESIZER_INSTALL_INIT_SYSV + $(INSTALL) -D -m 755 package/first_boot_rootfs_resizer/resizing \ + $(TARGET_DIR)/etc/init.d/S$(FIRST_BOOT_ROOTFS_RESIZER_PRIO)resizing +endef + +$(eval $(generic-package)) diff --git a/package/first_boot_rootfs_resizer/resize_fs.sh b/package/first_boot_rootfs_resizer/resize_fs.sh new file mode 100644 index 000000000..be41753d8 --- /dev/null +++ b/package/first_boot_rootfs_resizer/resize_fs.sh @@ -0,0 +1,44 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: resize_fs.sh +# Required-Start: $remote_fs $all +# Required-Stop: +# Default-Start: 2 3 4 5 S +# Default-Stop: +# Short-Description: First boot system setup +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +ROOT=$(cat /proc/cmdline | tr ' ' '\n' | grep root= | cut -f 2 -d =) +DEV=$(echo ${ROOT} | sed 's/p[0-9]\+$//g') +PART=$(basename ${ROOT}) + +if [ ! -z "${ROOT}" ]; then + echo "unable to locate root= entry in cmdline, resizing aborted" + exit 1 +fi + +if [ -f /.first_boot ]; then + echo "Resizing fs, please wait... upon finish the system will be restarted" + # ok, its the very first boot, we need to resize the disk. + p2_start=`fdisk -l ${DEV} | grep ${PART} | awk '{print $2}'` + p2_finish=`fdisk -l ${DEV} | grep sectors | awk '{printf $5}'` + + fdisk ${DEV} <