Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] odroid-scripts: add support for auto resize on first boot for SYSV
@ 2016-11-27 21:24 Dagg Stompler
  2016-11-27 21:27 ` Thomas Petazzoni
  0 siblings, 1 reply; 6+ messages in thread
From: Dagg Stompler @ 2016-11-27 21:24 UTC (permalink / raw)
  To: buildroot

ported from https://github.com/hardkernel/buildroot, upon first boot,
resize the file system to the max possible remaining size of the flash.

Signed-off-by: Dagg Stompler <daggs@gmx.com>
---
 board/hardkernel/odroidc2/genimage.cfg   |  1 -
 package/odroid-scripts/Config.in         |  2 ++
 package/odroid-scripts/S03resizing       | 11 ++++++++++
 package/odroid-scripts/odroid-scripts.mk | 12 ++++++++---
 package/odroid-scripts/resize_fs.sh      | 36 ++++++++++++++++++++++++++++++++
 5 files changed, 58 insertions(+), 4 deletions(-)
 create mode 100644 package/odroid-scripts/S03resizing
 create mode 100644 package/odroid-scripts/resize_fs.sh

diff --git a/board/hardkernel/odroidc2/genimage.cfg b/board/hardkernel/odroidc2/genimage.cfg
index 15f97d445..16d2786b1 100644
--- a/board/hardkernel/odroidc2/genimage.cfg
+++ b/board/hardkernel/odroidc2/genimage.cfg
@@ -22,6 +22,5 @@ image sdcard.img {
 	partition rootfs {
 		partition-type = 0x83
 		image = "rootfs.ext4"
-		size = 512M
 	}
 }
diff --git a/package/odroid-scripts/Config.in b/package/odroid-scripts/Config.in
index c4e09cad7..c40fa76b9 100644
--- a/package/odroid-scripts/Config.in
+++ b/package/odroid-scripts/Config.in
@@ -3,6 +3,8 @@ config BR2_PACKAGE_ODROID_SCRIPTS
 	depends on BR2_aarch64 || BR2_arm
 	select BR2_PACKAGE_FBSET # runtime
 	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # needed for fbset
+	select BR2_PACKAGE_E2FSPROGS # for resizefs
+	select BR2_PACKAGE_E2FSPROGS_RESIZE2FS # for resizefs
 	help
 	  Install the scripts for the odroidc2 based systems.
 
diff --git a/package/odroid-scripts/S03resizing b/package/odroid-scripts/S03resizing
new file mode 100644
index 000000000..4a19ce40e
--- /dev/null
+++ b/package/odroid-scripts/S03resizing
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+case "$1" in
+	start)
+		if [ -f /usr/sbin/resize_fs.sh ]; then /usr/sbin/resize_fs.sh; fi
+		;;
+	*)
+		;;
+esac
+
+exit $?
diff --git a/package/odroid-scripts/odroid-scripts.mk b/package/odroid-scripts/odroid-scripts.mk
index 858ec37fe..8769ec597 100644
--- a/package/odroid-scripts/odroid-scripts.mk
+++ b/package/odroid-scripts/odroid-scripts.mk
@@ -16,7 +16,11 @@ endef
 endif
 
 define ODROID_SCRIPTS_INSTALL_TARGET_CMDS
-	$(INSTALL) -D -m 0755 $(@D)/c2_init.sh $(TARGET_DIR)/usr/sbin/odroidc2_init_fb.sh
+	$(INSTALL) -D -m 0755 $(@D)/c2_init.sh \
+		$(TARGET_DIR)/usr/sbin/odroidc2_init_fb.sh
+	$(INSTALL) -D -m 0755 package/odroid-scripts/resize_fs.sh \
+		$(TARGET_DIR)/usr/sbin/resize_fs.sh
+	touch $(TARGET_DIR)/.first_boot
 	$(ODROID_SCRIPTS_INSTALL_UDEV_RULES)
 endef
 
@@ -29,8 +33,10 @@ define ODROID_SCRIPTS_INSTALL_INIT_SYSTEMD
 endef
 
 define ODROID_SCRIPTS_INSTALL_INIT_SYSV
-	$(INSTALL) -D -m 0755 package/odroid-scripts/S50odroidc2_fb \
-		$(TARGET_DIR)/etc/init.d/S50odroidc2_fb
+	$(INSTALL) -D -m 0755 package/odroid-scripts/S02odroidc2_fb \
+		$(TARGET_DIR)/etc/init.d/S02odroidc2_fb
+	$(INSTALL) -D -m 0755 package/odroid-scripts/S03resizing \
+		$(TARGET_DIR)/etc/init.d/S03resizing
 endef
 
 $(eval $(generic-package))
diff --git a/package/odroid-scripts/resize_fs.sh b/package/odroid-scripts/resize_fs.sh
new file mode 100644
index 000000000..f39c7f7b8
--- /dev/null
+++ b/package/odroid-scripts/resize_fs.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          resize_fs
+# 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
+
+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/mmcblk0 | grep mmcblk0p2 | awk '{print $2}'`
+	p2_finish=`fdisk -l /dev/mmcblk0 | grep sectors | awk '{printf $5}'`
+
+	fdisk /dev/mmcblk0 <<EOF
+p
+d
+2
+n
+p
+2
+$p2_start
+$p2_finish
+p
+w
+EOF
+	rm -fr /.first_boot
+	sync
+	reboot
+else
+	resize2fs /dev/mmcblk0p2 && rm -fr $0
+fi
-- 
2.11.0.rc2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] odroid-scripts: add support for auto resize on first boot for SYSV
  2016-11-27 21:24 [Buildroot] [PATCH] odroid-scripts: add support for auto resize on first boot for SYSV Dagg Stompler
@ 2016-11-27 21:27 ` Thomas Petazzoni
  2016-11-27 21:36   ` daggs
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2016-11-27 21:27 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 27 Nov 2016 23:24:49 +0200, Dagg Stompler wrote:
> ported from https://github.com/hardkernel/buildroot, upon first boot,
> resize the file system to the max possible remaining size of the flash.
> 
> Signed-off-by: Dagg Stompler <daggs@gmx.com>

This look potentially useful, but I don't see why it should be in an
Odroid-specific package. It is independent of Odroid-specific hardware,
so it should be in a separate package, so that it can be used on other
platforms. Of course, it needs to be made generic enough so that other
platforms can use it.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] odroid-scripts: add support for auto resize on first boot for SYSV
  2016-11-27 21:27 ` Thomas Petazzoni
@ 2016-11-27 21:36   ` daggs
  2016-11-27 21:51     ` Thomas Petazzoni
  0 siblings, 1 reply; 6+ messages in thread
From: daggs @ 2016-11-27 21:36 UTC (permalink / raw)
  To: buildroot

Greetings Thomas,

>
> Hello,
> 
> On Sun, 27 Nov 2016 23:24:49 +0200, Dagg Stompler wrote:
> > ported from https://github.com/hardkernel/buildroot, upon first boot,
> > resize the file system to the max possible remaining size of the flash.
> > 
> > Signed-off-by: Dagg Stompler <daggs@gmx.com>
> 
> This look potentially useful, but I don't see why it should be in an
> Odroid-specific package. It is independent of Odroid-specific hardware,
> so it should be in a separate package, so that it can be used on other
> platforms. Of course, it needs to be made generic enough so that other
> platforms can use it.

two reasons:
 1. this came from a Odroid-specific repo as stated above.
 2. afaics, the only way to make it more generic is to add systemd support and that is something I don't know how to do nor I have time to do so.

moreover, if it can be useful for other platforms, why not have it as part of the generated tree and not have it as a pkg?

Dagg.

> 
> Thanks,
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] odroid-scripts: add support for auto resize on first boot for SYSV
  2016-11-27 21:36   ` daggs
@ 2016-11-27 21:51     ` Thomas Petazzoni
  2016-11-30  8:59       ` daggs
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2016-11-27 21:51 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 27 Nov 2016 22:36:46 +0100, daggs wrote:

> two reasons:
>  1. this came from a Odroid-specific repo as stated above.

Right, but what Buildroot forks are doing is not necessarily the
appropriate way of doing things.

>  2. afaics, the only way to make it more generic is to add systemd
> support and that is something I don't know how to do nor I have time
> to do so.

No, you don't _have_ to add systemd support. It's nice when people do
it, but it's not a strict requirement.

> moreover, if it can be useful for other platforms, why not have it as
> part of the generated tree and not have it as a pkg?

Well, we certainly don't want to have it unconditionally installed, so
it would have to be optional. And a package is nice to isolate this
feature and the related init script in a clean way.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] odroid-scripts: add support for auto resize on first boot for SYSV
  2016-11-27 21:51     ` Thomas Petazzoni
@ 2016-11-30  8:59       ` daggs
  2016-11-30  9:17         ` Baruch Siach
  0 siblings, 1 reply; 6+ messages in thread
From: daggs @ 2016-11-30  8:59 UTC (permalink / raw)
  To: buildroot

Greetings Thomas,

> Hello,
> 
> On Sun, 27 Nov 2016 22:36:46 +0100, daggs wrote:
> 
> > two reasons:
> >  1. this came from a Odroid-specific repo as stated above.
> 
> Right, but what Buildroot forks are doing is not necessarily the
> appropriate way of doing things.
> 
> >  2. afaics, the only way to make it more generic is to add systemd
> > support and that is something I don't know how to do nor I have time
> > to do so.
> 
> No, you don't _have_ to add systemd support. It's nice when people do
> it, but it's not a strict requirement.
> 
> > moreover, if it can be useful for other platforms, why not have it as
> > part of the generated tree and not have it as a pkg?
> 
> Well, we certainly don't want to have it unconditionally installed, so
> it would have to be optional. And a package is nice to isolate this
> feature and the related init script in a clean way.
> 
> Best regards,
> 
> Thomas

two questions:
1. how to define a pkg that has no download url?
2. pkg name?

Dagg.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH] odroid-scripts: add support for auto resize on first boot for SYSV
  2016-11-30  8:59       ` daggs
@ 2016-11-30  9:17         ` Baruch Siach
  0 siblings, 0 replies; 6+ messages in thread
From: Baruch Siach @ 2016-11-30  9:17 UTC (permalink / raw)
  To: buildroot

Hi Dagg,

On Wed, Nov 30, 2016 at 09:59:46AM +0100, daggs wrote:
> > Well, we certainly don't want to have it unconditionally installed, so
> > it would have to be optional. And a package is nice to isolate this
> > feature and the related init script in a clean way.
> 
> two questions:
> 1. how to define a pkg that has no download url?

See the makedevs package as an example.

> 2. pkg name?

part-resize-full maybe?

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-11-30  9:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-27 21:24 [Buildroot] [PATCH] odroid-scripts: add support for auto resize on first boot for SYSV Dagg Stompler
2016-11-27 21:27 ` Thomas Petazzoni
2016-11-27 21:36   ` daggs
2016-11-27 21:51     ` Thomas Petazzoni
2016-11-30  8:59       ` daggs
2016-11-30  9:17         ` Baruch Siach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox