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

When mkfs.btrfs "command not found", it will user mkfs.ext4. beacuse mkfs.ext4 is common, other mkfs.*** is not considered. 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..e384a933 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 command -v mkfs.btrfs > /dev/null; 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 04:47:11PM +0800, Hu Xuejiao wrote:
When mkfs.btrfs "command not found", it will user mkfs.ext4. beacuse ^ beacuse=>because mkfs.ext4 is common, other mkfs.*** is not considered.
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..e384a933 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 command -v mkfs.btrfs > /dev/null; 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 04:47:11PM +0800, Hu Xuejiao wrote:
When mkfs.btrfs "command not found", it will user mkfs.ext4. beacuse mkfs.ext4 is common, other mkfs.*** is not considered.
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..e384a933 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 command -v mkfs.btrfs > /dev/null; then
use &> instead of > in case of non-0 messages Thanks Luan Shengde
+ 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

Title use: (fix) => fix: is better [why] When mkfs.btrfs "command not found" [how] It will use mkfs.ext4. beacuse mkfs.ext4 is common, other mkfs.*** is not considered Thanks, Zahngyu

On Thu, Oct 29, 2020 at 05:03:59PM +0800, Zhang Yu wrote:
Title use: (fix) => fix: is better
如果是bug fix, area: fix ... Thanks, Yale
[why] When mkfs.btrfs "command not found"
[how] It will use mkfs.ext4. beacuse mkfs.ext4 is common, other mkfs.*** is not considered
Thanks, Zahngyu

On Thu, Oct 29, 2020 at 04:47:11PM +0800, Hu Xuejiao wrote:
mount $rootfs_partition $ROOTFS_DIR || { - mkfs.btrfs -f $rootfs_partition
if btrfs else ext4, why mount 2 times ? if you think this root_partition has been mkfs to btrfs, how to consider the date inside it? suggest mkfs first, then mount. Thanks, dewan
+ if command -v mkfs.btrfs > /dev/null; 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 05:16:44PM +0800, Zhang Dewan wrote:
On Thu, Oct 29, 2020 at 04:47:11PM +0800, Hu Xuejiao wrote:
mount $rootfs_partition $ROOTFS_DIR || { - mkfs.btrfs -f $rootfs_partition
if btrfs else ext4, why mount 2 times ?
if you think this root_partition has been mkfs to btrfs, how to consider the date inside it? suggest mkfs first, then mount.
right, these date on disk should be clean first, so, how about format before mount. Thanks, Shenwei
Thanks, dewan
+ if command -v mkfs.btrfs > /dev/null; 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
participants (6)
-
Hu Xuejiao
-
Luan Shengde
-
Xiao Shenwei
-
Zhang Dewan
-
Zhang Yale
-
Zhang Yu