[PATCH v3 lkp-tests] fix: btrfs-progs is not installed when os_mount=initramfs

[why] mkfs.btrfs "command not found" when os_mount=initramfs [how] it will user mkfs.ext4 because mkfs.ext4 is common, other mkfs.*** is not considered [how] mkfs.btrfs and mkfs.ext4 is no exist, it will return Signed-off-by: Hu XueJiao <huxuejiao1@huawei.com> --- lib/bootstrap.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bootstrap.sh b/lib/bootstrap.sh index a7776d68..9744cb84 100755 --- a/lib/bootstrap.sh +++ b/lib/bootstrap.sh @@ -456,7 +456,12 @@ mount_rootfs() ROOTFS_DIR=/opt/rootfs mkdir -p $ROOTFS_DIR mount $rootfs_partition $ROOTFS_DIR || { - mkfs.btrfs -f $rootfs_partition + if has_cmd mkfs.btrfs; then + mkfs.btrfs -f $rootfs_partition + else + mkfs.ext4 -F $rootfs_partition || return + fi + mount $rootfs_partition $ROOTFS_DIR } mkdir -p $ROOTFS_DIR/tmp -- 2.23.0

On Thu, Oct 29, 2020 at 08:39:21PM +0800, Hu Xuejiao wrote:
[why] mkfs.btrfs "command not found" when os_mount=initramfs
[how] it will user mkfs.ext4 because mkfs.ext4 is common, other mkfs.*** is not considered
[how] mkfs.btrfs and mkfs.ext4 is no exist, it will return
Signed-off-by: Hu XueJiao <huxuejiao1@huawei.com> --- lib/bootstrap.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/bootstrap.sh b/lib/bootstrap.sh index a7776d68..9744cb84 100755 --- a/lib/bootstrap.sh +++ b/lib/bootstrap.sh @@ -456,7 +456,12 @@ mount_rootfs() ROOTFS_DIR=/opt/rootfs mkdir -p $ROOTFS_DIR mount $rootfs_partition $ROOTFS_DIR || { - mkfs.btrfs -f $rootfs_partition + if has_cmd mkfs.btrfs; then + mkfs.btrfs -f $rootfs_partition + else + mkfs.ext4 -F $rootfs_partition || return
should't return , if mount success will mkdir -p /opt/rootfs/tmp if mount failed also need create /opt/rootfs/tmp and CACHE_DIR if return the CACHE_DIR will "" this function should create a dir Thanks, Shenwei
+ fi + mount $rootfs_partition $ROOTFS_DIR } mkdir -p $ROOTFS_DIR/tmp -- 2.23.0

On Thu, Oct 29, 2020 at 08:39:21PM +0800, Hu Xuejiao wrote:
[why] mkfs.btrfs "command not found" when os_mount=initramfs
[how] it will user mkfs.ext4 because mkfs.ext4 is common, other mkfs.*** is not considered
[how] mkfs.btrfs and mkfs.ext4 is no exist, it will return
Signed-off-by: Hu XueJiao <huxuejiao1@huawei.com> --- lib/bootstrap.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/bootstrap.sh b/lib/bootstrap.sh index a7776d68..9744cb84 100755 --- a/lib/bootstrap.sh +++ b/lib/bootstrap.sh @@ -456,7 +456,12 @@ mount_rootfs() ROOTFS_DIR=/opt/rootfs mkdir -p $ROOTFS_DIR mount $rootfs_partition $ROOTFS_DIR || { - mkfs.btrfs -f $rootfs_partition + if has_cmd mkfs.btrfs; then + mkfs.btrfs -f $rootfs_partition
What if mkfs.btrfs failed, should it return as below? Thanks, Xijian
+ else + mkfs.ext4 -F $rootfs_partition || return + fi + mount $rootfs_partition $ROOTFS_DIR } mkdir -p $ROOTFS_DIR/tmp -- 2.23.0
participants (3)
-
Hu Xuejiao
-
Xiao Shenwei
-
Xu Xijian