Skip to contentSkip to conversation

odroid-scripts: add support for auto resize on first boot for SYSV

PATCH New Dagg Stompler 3 participants 6 messages Nov 27, 2016 – Nov 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 odroid-scripts: add support for auto resize on first boot for SYSV

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

---
 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
board/hardkernel/odroidc2/genimage.cfg +0 -1
index 15f97d445..16d2786b1 100644
@@ -22,6 +22,5 @@ image sdcard.img {
 	partition rootfs {
 		partition-type = 0x83
 		image = "rootfs.ext4"
-		size = 512M
 	}
 }
package/odroid-scripts/Config.in +2 -0
index c4e09cad7..c40fa76b9 100644
@@ -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.
 
package/odroid-scripts/S03resizing new file +11 -0
new file mode 100644
index 000000000..4a19ce40e
@@ -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 $?
package/odroid-scripts/odroid-scripts.mk +9 -3
index 858ec37fe..8769ec597 100644
@@ -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))
package/odroid-scripts/resize_fs.sh new file +36 -0
new file mode 100644
index 000000000..f39c7f7b8
@@ -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
Signature · 1 line
2.11.0.rc2
#1 lore raw

PATCH 1/1 odroid-scripts: add support for auto resize on first boot for SYSV

Hello,

Quoted 4 lines · Dagg Stompler

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

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

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
author
#2 lore raw

PATCH 1/1 odroid-scripts: add support for auto resize on first boot for SYSV

Greetings Thomas,

Quoted 7 lines

Hello,

Quoted 3 lines · Dagg Stompler

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

Quoted 7 lines
Quoted 1 line

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.

Quoted 9 lines

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH 1/1 odroid-scripts: add support for auto resize on first boot for SYSV

Hello,

Quoted 2 lines · daggs

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.

Quoted 3 lines

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.

Quoted 2 lines

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

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
author
#4 lore raw

PATCH 1/1 odroid-scripts: add support for auto resize on first boot for SYSV

Greetings Thomas,

Quoted 20 lines

Hello,

Quoted 2 lines · daggs

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.

Quoted 3 lines

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.

Quoted 2 lines

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?

Quoted 7 lines

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.

#5 lore raw

PATCH 1/1 odroid-scripts: add support for auto resize on first boot for SYSV

Hi Dagg,

Quoted 6 lines · daggs
Quoted 3 lines

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.

Quoted 1 line

2. pkg name?

part-resize-full maybe?

baruch

Signature · 3 lines
     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 -