summaryrefslogtreecommitdiffstats
path: root/projectroot/lib/systemd/system/systemd-autoformat@.service
diff options
context:
space:
mode:
Diffstat (limited to 'projectroot/lib/systemd/system/systemd-autoformat@.service')
-rw-r--r--projectroot/lib/systemd/system/systemd-autoformat@.service15
1 files changed, 15 insertions, 0 deletions
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