From: Daniel Golle Date: Mon, 15 Jan 2024 17:47:46 +0000 (+0000) Subject: libfstools: force mkfs when formatting overlay X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=2171f62615569bace6e53617480d8f233f8f3b94;p=project%2Ffstools.git libfstools: force mkfs when formatting overlay As the rootfs_overlay volume is dynamically allocated on platforms which allow for that, the start of the volume can end up being at the location of previously stored data. This can happen when writing an SD card image to an SD card previously used for something else. sysupgrade should always wipe preexisting data, but I haven't checked if all platform implementations actually always do so). As mkfs is cautious not to accidentally overwrite existing data, this can result in the system to hang on boot, waiting for confirmation on the serial console: mount_root: overlay filesystem in /dev/fitrw has not been formatted yet /dev/fitrw contains `ISO-8859 text, with very long lines (65536), with no line terminators' data Proceed anyway? (y,N) Use the FORCE option (-F for mkfs.ext4, -f for mkfs.f2fs) to make sure the volume is always formatted irrespective of its previous content. Signed-off-by: Daniel Golle --- diff --git a/libfstools/common.c b/libfstools/common.c index e5b7bc3..6c513f0 100644 --- a/libfstools/common.c +++ b/libfstools/common.c @@ -164,9 +164,9 @@ int block_volume_format(struct volume *v, uint64_t offset, const char *bdev) do_format: ULOG_INFO("overlay filesystem in %s has not been formatted yet\n", v->blk); if (use_f2fs(v, offset, bdev)) - snprintf(str, sizeof(str), "mkfs.f2fs -q -l rootfs_data %s", v->blk); + snprintf(str, sizeof(str), "mkfs.f2fs -q -f -l rootfs_data %s", v->blk); else - snprintf(str, sizeof(str), "mkfs.ext4 -q -L rootfs_data %s", v->blk); + snprintf(str, sizeof(str), "mkfs.ext4 -q -F -L rootfs_data %s", v->blk); ret = system(str); break;