From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: [PATCH 16/16] meta: Add enable-fsck helper recipe
Date: Tue, 11 Sep 2018 14:05:56 +0200 [thread overview]
Message-ID: <ef2a00c4f99a6de8bfc9d365144154ef67f28853.1536667556.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1536667556.git.jan.kiszka@siemens.com>
In-Reply-To: <cover.1536667556.git.jan.kiszka@siemens.com>
From: Jan Kiszka <jan.kiszka@siemens.com>
This is a run-once systemd service that enables checks for all regular
filesystems on the target. We do this on the live system rather during
build because we only have the full information required for
populating the initramfs with the right tools available then - at least
as long as we do not want to patch much more.
Enable this feature in the demo local.conf by default because we have
read/write filesystems here.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
meta-isar/conf/local.conf.sample | 2 +-
meta/recipes-support/enable-fsck/enable-fsck.bb | 25 ++++++++++++++++++++++
.../enable-fsck/files/enable-fsck.service | 23 ++++++++++++++++++++
.../enable-fsck/files/enable-fsck.sh | 16 ++++++++++++++
meta/recipes-support/enable-fsck/files/postinst | 3 +++
5 files changed, 68 insertions(+), 1 deletion(-)
create mode 100644 meta/recipes-support/enable-fsck/enable-fsck.bb
create mode 100644 meta/recipes-support/enable-fsck/files/enable-fsck.service
create mode 100644 meta/recipes-support/enable-fsck/files/enable-fsck.sh
create mode 100644 meta/recipes-support/enable-fsck/files/postinst
diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 769d853..92588fe 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -159,7 +159,7 @@ CONF_VERSION = "1"
#
# The default list of extra packages to be installed.
-IMAGE_INSTALL = "example-hello example-raw example-module"
+IMAGE_INSTALL = "example-hello example-raw example-module enable-fsck"
#
# Enable cross-compilation support
diff --git a/meta/recipes-support/enable-fsck/enable-fsck.bb b/meta/recipes-support/enable-fsck/enable-fsck.bb
new file mode 100644
index 0000000..0413f79
--- /dev/null
+++ b/meta/recipes-support/enable-fsck/enable-fsck.bb
@@ -0,0 +1,25 @@
+# Resize last partition to full medium size on fist boot
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2018
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg-raw
+
+DESCRIPTION = "This service enables fsck on first boot"
+
+DEBIAN_DEPENDS = "systemd, sed, mount, initramfs-tools"
+
+SRC_URI = " \
+ file://enable-fsck.service \
+ file://enable-fsck.sh \
+ file://postinst"
+
+do_install() {
+ install -d -m 755 ${D}/lib/systemd/system
+ install -m 644 ${WORKDIR}/enable-fsck.service ${D}/lib/systemd/system/
+
+ install -d -m 755 ${D}/usr/share/enable-fsck
+ install -m 755 ${WORKDIR}/enable-fsck.sh ${D}/usr/share/enable-fsck/
+}
diff --git a/meta/recipes-support/enable-fsck/files/enable-fsck.service b/meta/recipes-support/enable-fsck/files/enable-fsck.service
new file mode 100644
index 0000000..846497d
--- /dev/null
+++ b/meta/recipes-support/enable-fsck/files/enable-fsck.service
@@ -0,0 +1,23 @@
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2018
+#
+# SPDX-License-Identifier: MIT
+
+[Unit]
+Description=Enable fsck for mounted devices
+DefaultDependencies=no
+Conflicts=shutdown.target
+After=systemd-remount-fs.service
+Before=sysinit.target shutdown.target
+ConditionPathIsReadWrite=/etc
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/share/enable-fsck/enable-fsck.sh
+ExecStartPost=-/bin/systemctl disable enable-fsck.service
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=sysinit.target
diff --git a/meta/recipes-support/enable-fsck/files/enable-fsck.sh b/meta/recipes-support/enable-fsck/files/enable-fsck.sh
new file mode 100644
index 0000000..b3dce44
--- /dev/null
+++ b/meta/recipes-support/enable-fsck/files/enable-fsck.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Update rootfs device in fstab, enable checks for all regular filesystems
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2018
+#
+# SPDX-License-Identifier: MIT
+
+set -e
+
+ROOT_DEV=$(/bin/findmnt -n -o SOURCE /)
+sed -i -e 's|^/dev/root\([ ]\+.*[ ]\+\)0[ ]\+0|'$ROOT_DEV'\10 1|' \
+ -e 's|^\(/dev/.*[ ]\+\)0[ ]\+0|\10 2|' /etc/fstab
+
+update-initramfs -u
diff --git a/meta/recipes-support/enable-fsck/files/postinst b/meta/recipes-support/enable-fsck/files/postinst
new file mode 100644
index 0000000..1c4c3bd
--- /dev/null
+++ b/meta/recipes-support/enable-fsck/files/postinst
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+systemctl enable enable-fsck.service
--
2.16.4
next prev parent reply other threads:[~2018-09-11 12:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-11 12:05 [PATCH 00/16] Cleanups, linux-custom fix, auto-expansion helper Jan Kiszka
2018-09-11 12:05 ` [PATCH 01/16] meta-isar: Adjust kernel params in sdimage-efi.wks Jan Kiszka
2018-09-11 12:05 ` [PATCH 02/16] meta-isar: Reduce grub timeout to 3 seconds Jan Kiszka
2018-09-11 12:05 ` [PATCH 03/16] meta-isar: Fix bananapi root disk specification Jan Kiszka
2018-09-12 8:57 ` Henning Schild
2018-09-12 8:59 ` Henning Schild
2018-09-11 12:05 ` [PATCH 04/16] meta-isar: Remove "=" after wic parameters Jan Kiszka
2018-09-11 12:05 ` [PATCH 05/16] u-boot-script: Become independent of target /etc/fstab Jan Kiszka
2018-09-11 12:05 ` [PATCH 06/16] isar-image-base: Disable rootfs check by default Jan Kiszka
2018-09-11 12:05 ` [PATCH 07/16] isar-image-base: Use generic parameters for rootfs entry in fstab Jan Kiszka
2018-09-11 12:05 ` [PATCH 08/16] meta: Remove ROOTFS_TYPE Jan Kiszka
2018-09-11 12:05 ` [PATCH 09/16] start_vm: Rename QEMU_ROOTFS_DEV to QEMU_DISK_ARGS Jan Kiszka
2018-09-11 12:05 ` [PATCH 10/16] start_vm: Rename ROOTFS_DEV to QEMU_ROOTFS_DEV Jan Kiszka
2018-09-11 12:05 ` [PATCH 11/16] RECIPE-API-CHANGELOG: Add ROOTFS_DEV/TYPE removal Jan Kiszka
2018-09-11 12:05 ` [PATCH 12/16] meta: Add expand-on-first-boot support package Jan Kiszka
2018-09-12 13:46 ` Henning Schild
2018-09-13 8:33 ` Jan Kiszka
2018-09-13 9:30 ` Henning Schild
2018-09-13 13:17 ` Jan Kiszka
2018-09-11 12:05 ` [PATCH 13/16] image: Limit ROOTFS_EXTRA to non-wic image type Jan Kiszka
2018-09-11 12:05 ` [PATCH 14/16] linux-custom: Simplify and clarify KERNEL_NAME-to-recipe matching Jan Kiszka
2018-09-11 12:05 ` [PATCH 15/16] meta-isar: Move init preinstallation into distro conf Jan Kiszka
2018-09-11 12:05 ` Jan Kiszka [this message]
2018-09-25 11:27 ` [PATCH 00/16] Cleanups, linux-custom fix, auto-expansion helper Maxim Yu. Osipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef2a00c4f99a6de8bfc9d365144154ef67f28853.1536667556.git.jan.kiszka@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox