summaryrefslogtreecommitdiff
path: root/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
diff options
context:
space:
mode:
authorIsaac Kurth <isaac.kurth@ibm.com>2021-06-25 19:33:46 +0300
committerPatrick Williams <patrick@stwcx.xyz>2021-07-21 17:21:38 +0300
commit315698e53dfa383697599803d074b981946b0bfd (patch)
tree781d495a541025b1ad2405c9cae6426d9f09afd3 /meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
parente11f5e254ccae62d15a1ad5e1b7ff03feb71a515 (diff)
downloadopenbmc-315698e53dfa383697599803d074b981946b0bfd.tar.xz
mmc-init: Add factory reset based on rwreset
To enable factory resets, the mmc-init.sh script checks on reboot if the environment variable rwreset is set to "true". If it is, the rw parts of the file system that users may have modified are reformatted to remove all user changes and rwreset is set to "false". Tested: Add a file to /var and use fw_setenv to set rwreset to true. Reboot the machine and verify that the added file is gone and rwreset is set to false. Signed-off-by: Isaac Kurth <isaac.kurth@ibm.com> Change-Id: I2d8b4f4eaf8ff6df092893760aaae9db2ce3917b
Diffstat (limited to 'meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh')
-rw-r--r--meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
index 3fad5e6fa..575b7605a 100644
--- a/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
+++ b/meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh
@@ -49,6 +49,18 @@ if ! mount /dev/disk/by-partlabel/"$(get_root)" $rodir -t ext4 -o ro; then
fi
rwfsdev="/dev/disk/by-partlabel/rwfs"
+mkdir -p /var/lock
+if test $(fw_printenv -n rwreset) = "true"; then
+ echo "Factory reset requested."
+ if ! mkfs.ext4 -F "${rwfsdev}"; then
+ echo "Reformat for factory reset failed."
+ /bin/sh
+ else
+ fw_setenv rwreset
+ echo "Formatting of rwfs is complete."
+ fi
+fi
+
fsck.ext4 -p "${rwfsdev}"
if ! mount "${rwfsdev}" $rodir/var -t ext4 -o rw; then
/bin/sh