我正在尝试创建一个格式化Amazon EC2 EBS卷的脚本,因此我可以挂载它.
从命令行看,它看起来像这样:
> mkfs -q -t ext4 /dev/sdf /dev/sdf is entire device,not just one partition! Proceed anyway? (y,n)
(命令正确;无需为我的目的创建分区表)
我的问题:因为这个命令应该在一个自动脚本中运行,我不能在终端上有这个问题;没有人会回答,脚本将挂起.我该如何避免这种情况?
我试过了:
> echo y | mkfs -q -t ext4 /dev/sdf
但这并没有成功. -q选项也没有区别.
解决方法
从
manpage:
-F Force mke2fs to create a filesystem,even if the specified device is not a partition on a block special device,or if other parameters do not make sense.
因此,直接调用mkfs.ext4而不是通过mkfs,并添加-F参数以忽略此警告.