From 6363815629a51cfc4b386fa53e2d94670bc968f0 Mon Sep 17 00:00:00 2001 From: Robert Schwebel Date: Thu, 9 Jun 2016 09:15:27 +0200 Subject: 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 Signed-off-by: Robert Schwebel --- projectroot/etc/fstab | 20 ++++++++++++++++++++ .../lib/systemd/system/systemd-autoformat@.service | 15 +++++++++++++++ projectroot/lib/udev/rules.d/91-mkfs-ext4.rules | 5 +++++ 3 files changed, 40 insertions(+) create mode 100644 projectroot/etc/fstab create mode 100644 projectroot/lib/systemd/system/systemd-autoformat@.service create mode 100644 projectroot/lib/udev/rules.d/91-mkfs-ext4.rules (limited to 'projectroot') 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" -- cgit v1.2.3