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>
diff --git a/common/recipes-phosphor/flash/obmc-flash-bios.bb b/common/recipes-phosphor/flash/obmc-flash-bios.bb
index 7398cbd..2137de4 100644
--- a/common/recipes-phosphor/flash/obmc-flash-bios.bb
+++ b/common/recipes-phosphor/flash/obmc-flash-bios.bb
@@ -14,3 +14,4 @@
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/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-squashfsmount@.service b/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-squashfsmount@.service
new file mode 100644
index 0000000..1bf15bf
--- /dev/null
+++ b/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/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-ubimount@.service b/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-ubimount@.service
index 331ed6b..5abab7f 100644
--- a/common/recipes-phosphor/flash/obmc-flash-bios/obmc-flash-bios-ubimount@.service
+++ b/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'