Skip to content

Commit f4df78c

Browse files
committed
mount-tee-partition: add systemd service to format persist
QTEE requires a valid filesystem on the persist partition mounted at `/var/lib/tee` to store encrypted data. If the persist partition is unformatted, the mount fails and dependent services such as qtee_supplicant cannot function. Add a systemd oneshot service that checks for an existing filesystem on the persist partition and formats it as ext4 when missing. The service runs once during early boot, before var-lib-tee.mount, to ensure a valid filesystem is available at `/var/lib/tee`, and disables itself after successful execution. Signed-off-by: Viswanath Kraleti <viswanath.kraleti@oss.qualcomm.com>
1 parent fc5802d commit f4df78c

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2+
#
3+
# SPDX-License-Identifier: BSD-3-Clause-Clear
4+
5+
[Unit]
6+
Description=Create ext4 filesystem on persist partition if missing
7+
Requires=dev-disk-by\x2dpartlabel-persist.device
8+
After=dev-disk-by\x2dpartlabel-persist.device
9+
ConditionPathExists=/dev/disk/by-partlabel/persist
10+
Before=var-lib-tee.mount
11+
Wants=var-lib-tee.mount
12+
ConditionPathIsMountPoint=!/var/lib/tee
13+
14+
[Service]
15+
Type=oneshot
16+
ExecStart=/bin/sh -c '\
17+
DEV=/dev/disk/by-partlabel/persist; \
18+
if [ -n "$(/sbin/blkid -o value -s TYPE "$DEV" 2>/dev/null || true)" ]; then \
19+
echo "$DEV already has a filesystem, skipping mkfs"; \
20+
exit 0; \
21+
fi; \
22+
/sbin/mkfs.ext4 "$DEV" \
23+
'
24+
ExecStartPost=/bin/systemctl disable format-tee-partition.service
25+
RemainAfterExit=yes
26+
27+
[Install]
28+
WantedBy=local-fs-pre.target

recipes-bsp/partition/mount-tee-partition_1.0.bb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ encryped data and support security functions"
44
LICENSE = "BSD-3-Clause-Clear"
55
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/BSD-3-Clause-Clear;md5=7a434440b651f4a472ca93716d01033a"
66

7-
SRC_URI = "file://var-lib-tee.mount"
7+
SRC_URI = " \
8+
file://var-lib-tee.mount \
9+
file://format-tee-partition.service \
10+
"
811

912
inherit allarch features_check systemd
1013
REQUIRED_DISTRO_FEATURES = "systemd"
@@ -18,8 +21,10 @@ do_compile[noexec] = "1"
1821
do_install() {
1922
install -Dm 0644 ${UNPACKDIR}/var-lib-tee.mount \
2023
${D}${systemd_unitdir}/system/var-lib-tee.mount
24+
install -Dm 0644 ${UNPACKDIR}/format-tee-partition.service \
25+
${D}${systemd_unitdir}/system/format-tee-partition.service
2126
}
2227

2328
PACKAGES = "${PN}"
2429

25-
SYSTEMD_SERVICE:${PN} = "var-lib-tee.mount"
30+
SYSTEMD_SERVICE:${PN} = "var-lib-tee.mount format-tee-partition.service"

0 commit comments

Comments
 (0)