From 315698e53dfa383697599803d074b981946b0bfd Mon Sep 17 00:00:00 2001 From: Isaac Kurth Date: Fri, 25 Jun 2021 11:33:46 -0500 Subject: 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 Change-Id: I2d8b4f4eaf8ff6df092893760aaae9db2ce3917b --- .../initrdscripts/phosphor-mmc-init/mmc-init.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'meta-phosphor/recipes-phosphor/initrdscripts/phosphor-mmc-init/mmc-init.sh') 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 -- cgit v1.2.3