diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2017-04-13 12:36:01 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-04-27 02:37:39 +0000 |
commit | ae5e437976a00d354dd0cd3b8ac4385a56ab40c3 (patch) | |
tree | 106bd9b0d165e2c6b2e798fdb5ec009970bcca42 | |
parent | e4da33593902b1bc6f5b12037a98696a0bfbab88 (diff) | |
download | talos-openbmc-ae5e437976a00d354dd0cd3b8ac4385a56ab40c3.tar.gz talos-openbmc-ae5e437976a00d354dd0cd3b8ac4385a56ab40c3.zip |
Create SquashFS mount template service
This service will mount a SquashFS image to a read-only partition.
1. Create a read-only UBI volume named pnor-ro-%i with an arbitrary
size of 32MB. The volume will shrink to the size of the squashfs
image, and the current pnor squashfs image is about 20MB.
2. Save the ubivolume id in a unique env variable $volumeid%i.
Unlike ubifs, squashfs requires the volume id instead of the name.
3. Create a read-only ubi block device on the ubi volume, this is
where read-only filesystems can reside.
4. Update the ubi block with the squashfs image.
5. Mount. The contents of the squashfs image will be available
under /media/pnor-ro-%i.
Add a couple fixes to the ubimount service to make it more
readable and match the new squashfsmount service.
Change-Id: I38c6f7a123c1b79fb82905c161f8c2ba796820ca
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
3 files changed, 19 insertions, 4 deletions
diff --git a/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios.bb b/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios.bb index 7398cbdbc..2137de414 100644 --- a/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios.bb +++ b/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios.bb @@ -14,3 +14,4 @@ DBUS_SERVICE_${PN} += "org.openbmc.control.Flash.service" SYSTEMD_SERVICE_${PN} += "obmc-flash-init.service" SYSTEMD_SERVICE_${PN} += "obmc-flash-bios-ubiattach.service" SYSTEMD_SERVICE_${PN} += "obmc-flash-bios-ubimount@.service" +SYSTEMD_SERVICE_${PN} += "obmc-flash-bios-squashfsmount@.service" diff --git a/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-squashfsmount@.service b/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-squashfsmount@.service new file mode 100644 index 000000000..1bf15bfd4 --- /dev/null +++ b/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-squashfsmount@.service @@ -0,0 +1,14 @@ +[Unit] +Description=Mount SquashFS image pnor-ro-%I +Requires=obmc-flash-bios-ubiattach.service +After=obmc-flash-bios-ubiattach.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/sh -c '{sbindir}/ubimkvol /dev/ubi0 -N pnor-ro-%i -s 32MiB --type=static; \ + mkdir /media/pnor-ro-%i; \ + volumeid%i=`ubinfo -d 0 -N pnor-ro-%i | grep "Volume ID" | sed -e "s|Volume ID:||" -e "s/^ *//" | grep -o "^\S*"`; \ + ubiblock --create /dev/ubi0_$volumeid%i; \ + ubiupdatevol /dev/ubi0_$volumeid%i /tmp/images/%i/pnor.xz.squashfs; \ + mount -t squashfs -o ro /dev/ubiblock0_$volumeid%i /media/pnor-ro-%i' diff --git a/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-ubimount@.service b/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-ubimount@.service index 331ed6bc6..5abab7f21 100644 --- a/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-ubimount@.service +++ b/meta-phosphor/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-ubimount@.service @@ -1,11 +1,11 @@ [Unit] -Description=Mount UBIFS volume pnor-rw%I +Description=Mount UBIFS volume pnor-rw-%I Requires=obmc-flash-bios-ubiattach.service After=obmc-flash-bios-ubiattach.service [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/bin/sh -c '{sbindir}ubimkvol /dev/ubi0 -N pnor-rw%i -s 1MiB; \ - mkdir /media/pnor-rw%i; \ - mount -t ubifs ubi0:pnor-rw%i /media/pnor-rw%i' +ExecStart=/bin/sh -c '{sbindir}/ubimkvol /dev/ubi0 -N pnor-rw-%i -s 1MiB; \ + mkdir /media/pnor-rw-%i; \ + mount -t ubifs ubi0:pnor-rw-%i /media/pnor-rw-%i' |