From 47b085f1dc14f2fc151a9ef2417feb6023719bcc Mon Sep 17 00:00:00 2001 From: Mykyta Dorokhin Date: Tue, 24 Nov 2020 07:31:40 +0200 Subject: mtk: erase user_data partition on mount error. --- .../files/init-readonly-rootfs-overlay-boot.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'recipes-core/initrdscripts') diff --git a/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh b/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh index 9402286..a1c7244 100755 --- a/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh +++ b/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh @@ -272,7 +272,18 @@ mount_and_boot() { log "user_data: $MOUNT $ROOT_RWMOUNTPARAMS $ROOT_RWMOUNT" # Mount read-write file system into initram root file system if ! $MOUNT $ROOT_RWMOUNTPARAMS $ROOT_RWMOUNT ; then - fatal "Could not mount read-write rootfs" + if [ -n "${ROOT_RWDEVICE}" ]; then + # fsck didn't help. Reformat the partition + log "Could not mount read-write rootfs. Erasing ${ROOT_RWDEVICE} partition." + mkfs.ext4 -L user_data -O 64bit ${ROOT_RWDEVICE} + log "mounting user_data: $MOUNT $ROOT_RWMOUNTPARAMS $ROOT_RWMOUNT" + if ! $MOUNT $ROOT_RWMOUNTPARAMS $ROOT_RWMOUNT ; then + fatal "Could not mount read-write rootfs." + fi + log "${ROOT_RWDEVICE} partition has been erased and mounted successfully." + else + fatal "Could not mount read-write rootfs." + fi fi # Reset read-write file system if specified -- cgit v1.2.3