summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Schwebel <r.schwebel@pengutronix.de>2016-06-09 09:15:27 +0200
committerRobert Schwebel <r.schwebel@pengutronix.de>2016-06-10 14:32:28 +0200
commit6363815629a51cfc4b386fa53e2d94670bc968f0 (patch)
tree0002763d17e0230f9965d579899176412fcabfc4
parent4ca0c25096f3a3b6969d44f757500ede747406d6 (diff)
downloadDistroKit-6363815629a51cfc4b386fa53e2d94670bc968f0.tar.gz
DistroKit-6363815629a51cfc4b386fa53e2d94670bc968f0.tar.xz
image: change partitioning, add data partition
We change the partitioning to have one root-A partition of 512 MB and a data partition that fills up the rest of the boot medium. The systemd-autoformat@.service formats the data partition if it isn't already, and the 91-mkfs-ext4 rule automatically mounts it to /mnt/data. Inspired-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
-rw-r--r--configs/ptxconfig16
-rw-r--r--projectroot/etc/fstab20
-rw-r--r--projectroot/lib/systemd/system/systemd-autoformat@.service15
-rw-r--r--projectroot/lib/udev/rules.d/91-mkfs-ext4.rules5
-rw-r--r--rules/datapartition.in5
-rw-r--r--rules/datapartition.make40
6 files changed, 95 insertions, 6 deletions
diff --git a/configs/ptxconfig b/configs/ptxconfig
index c4af853..a5e2b46 100644
--- a/configs/ptxconfig
+++ b/configs/ptxconfig
@@ -2,6 +2,7 @@
# Automatically generated file; DO NOT EDIT.
# PTXdist 2016.05.0
#
+PTXCONF_DATAPARTITION=y
#
# ------------------------------------
@@ -1370,12 +1371,15 @@ PTXCONF_UTIL_LINUX_NG=y
PTXCONF_UTIL_LINUX_NG_LIBBLKID=y
PTXCONF_UTIL_LINUX_NG_LIBUUID=y
PTXCONF_UTIL_LINUX_NG_LIBMOUNT=y
+PTXCONF_UTIL_LINUX_NG_LIBSMARTCOLS=y
+PTXCONF_UTIL_LINUX_NG_LIBFDISK=y
+PTXCONF_UTIL_LINUX_NG_PARTX_TOOLS=y
PTXCONF_UTIL_LINUX_NG_AGETTY=y
# PTXCONF_UTIL_LINUX_NG_COLUMN is not set
# PTXCONF_UTIL_LINUX_NG_LINE is not set
# PTXCONF_UTIL_LINUX_NG_ADDPART is not set
# PTXCONF_UTIL_LINUX_NG_DELPART is not set
-# PTXCONF_UTIL_LINUX_NG_PARTX is not set
+PTXCONF_UTIL_LINUX_NG_PARTX=y
#
# BusyBox' dmesg is selected!
@@ -1385,7 +1389,7 @@ PTXCONF_UTIL_LINUX_NG_AGETTY=y
#
# BusyBox' fdisk is selected!
#
-# PTXCONF_UTIL_LINUX_NG_SFDISK is not set
+PTXCONF_UTIL_LINUX_NG_SFDISK=y
# PTXCONF_UTIL_LINUX_NG_CFDISK is not set
# PTXCONF_UTIL_LINUX_NG_MKSWAP is not set
# PTXCONF_UTIL_LINUX_NG_SWAPON is not set
@@ -1726,10 +1730,10 @@ PTXCONF_E2FSPROGS_INSTALL_FSCK_EXT4=y
# PTXCONF_E2FSPROGS_INSTALL_E2UNDO is not set
# PTXCONF_E2FSPROGS_INSTALL_FILEFRAG is not set
# PTXCONF_E2FSPROGS_INSTALL_LOGSAVE is not set
-# PTXCONF_E2FSPROGS_INSTALL_MKE2FS is not set
-# PTXCONF_E2FSPROGS_INSTALL_MKFS_EXT2 is not set
-# PTXCONF_E2FSPROGS_INSTALL_MKFS_EXT3 is not set
-# PTXCONF_E2FSPROGS_INSTALL_MKFS_EXT4 is not set
+PTXCONF_E2FSPROGS_INSTALL_MKE2FS=y
+PTXCONF_E2FSPROGS_INSTALL_MKFS_EXT2=y
+PTXCONF_E2FSPROGS_INSTALL_MKFS_EXT3=y
+PTXCONF_E2FSPROGS_INSTALL_MKFS_EXT4=y
# PTXCONF_E2FSPROGS_INSTALL_MKFS_EXT4DEV is not set
# PTXCONF_E2FSPROGS_INSTALL_MKLOSTANDFOUND is not set
# PTXCONF_E2FSPROGS_INSTALL_RESIZE2FS is not set
diff --git a/projectroot/etc/fstab b/projectroot/etc/fstab
new file mode 100644
index 0000000..09b1d18
--- /dev/null
+++ b/projectroot/etc/fstab
@@ -0,0 +1,20 @@
+#
+# /etc/fstab
+#
+
+# special filesystems
+proc /proc proc nosuid,nodev,noexec 0 0
+devpts /dev/pts devpts nosuid,noexec,mode=620,gid=112 0 0
+sysfs /sys sysfs nosuid,nodev,noexec 0 0
+debugfs /sys/kernel/debug debugfs noauto 0 0
+
+# ramdisks
+tmpfs /tmp tmpfs nosuid,nodev,mode=1777,size=20% 0 0
+tmpfs /run tmpfs nosuid,nodev,strictatime,mode=0755 0 0
+/run /var/run bind bind 0 0
+tmpfs /var/log tmpfs nosuid,nodev,noexec,mode=0755,size=10% 0 0
+tmpfs /var/lock tmpfs nosuid,nodev,noexec,mode=0755,size=1M 0 0
+tmpfs /var/tmp tmpfs nosuid,nodev,mode=1777,size=20% 0 0
+
+# data partition
+/dev/mmcblk0p3 /mnt/data ext4 defaults,x-systemd.automount 0 2
diff --git a/projectroot/lib/systemd/system/systemd-autoformat@.service b/projectroot/lib/systemd/system/systemd-autoformat@.service
new file mode 100644
index 0000000..7522140
--- /dev/null
+++ b/projectroot/lib/systemd/system/systemd-autoformat@.service
@@ -0,0 +1,15 @@
+[Unit]
+Before=mnt-data.mount systemd-fsck@%i.service
+Description=Create ext4 Data Partition
+ConditionPathExists=/dev/%i
+
+[Service]
+Environment=DATAPARTITION=3
+Type=oneshot
+# resize partition to maximum
+ExecStart=/bin/sh -c 'echo ",+" | sfdisk --force -N$DATAPARTITION /dev/mmcblk0'
+# force kernel to reload the partition size of partition 3
+ExecStart=/usr/sbin/partx -d -n $DATAPARTITION /dev/mmcblk0
+ExecStart=/usr/sbin/partx -a -n $DATAPARTITION /dev/mmcblk0
+# create filesystem (this service is only started if we have none)
+ExecStart=/sbin/mkfs.ext4 /dev/%i
diff --git a/projectroot/lib/udev/rules.d/91-mkfs-ext4.rules b/projectroot/lib/udev/rules.d/91-mkfs-ext4.rules
new file mode 100644
index 0000000..1c1a396
--- /dev/null
+++ b/projectroot/lib/udev/rules.d/91-mkfs-ext4.rules
@@ -0,0 +1,5 @@
+ACTION!="add", GOTO="systemd-autoformat-ext4-devices_end"
+SUBSYSTEM!="block", GOTO="systemd-autoformat-ext4-devices_end"
+ENV{ID_FS_USAGE}!="filesystem", SUBSYSTEMS=="mmc", KERNEL=="mmcblk0p3", ENV{ID_FS_TYPE}!="ext4", ENV{SYSTEMD_WANTS}+="systemd-autoformat@$name.service"
+
+LABEL="systemd-autoformat-ext4-devices_end"
diff --git a/rules/datapartition.in b/rules/datapartition.in
new file mode 100644
index 0000000..4343e7c
--- /dev/null
+++ b/rules/datapartition.in
@@ -0,0 +1,5 @@
+## SECTION=project_specific
+
+config DATAPARTITION
+ tristate
+ default y
diff --git a/rules/datapartition.make b/rules/datapartition.make
new file mode 100644
index 0000000..9cda1b1
--- /dev/null
+++ b/rules/datapartition.make
@@ -0,0 +1,40 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2016 by Robert Schwebel <r.schwebel@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+PACKAGES-$(PTXCONF_DATAPARTITION) += datapartition
+
+DATAPARTITION_VERSION := 1
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/datapartition.targetinstall:
+ @$(call targetinfo)
+
+ @$(call install_init, datapartition)
+ @$(call install_fixup,datapartition,PRIORITY,optional)
+ @$(call install_fixup,datapartition,SECTION,base)
+ @$(call install_fixup,datapartition,AUTHOR,"Robert Schwebel <r.schwebel@pengutronix.de>")
+ @$(call install_fixup,datapartition,DESCRIPTION,missing)
+
+ @$(call install_alternative, datapartition, 0, 0, 0644, \
+ /lib/systemd/system/systemd-autoformat@.service)
+ @$(call install_alternative, datapartition, 0, 0, 0644, \
+ /lib/udev/rules.d/91-mkfs-ext4.rules)
+
+ @$(call install_finish,datapartition)
+
+ @$(call touch)
+
+# vim: syntax=make