Joh*_*nst 10 linux bash amazon-ec2
我正在尝试创建一个格式化 Amazon EC2 EBS 卷的脚本,以便我可以挂载它。
从命令行看,它看起来像这样:
> mkfs -q -t ext4 /dev/sdf
/dev/sdf is entire device, not just one partition!
Proceed anyway? (y,n)
Run Code Online (Sandbox Code Playgroud)
(命令是正确的;不需要为我的目的创建分区表)
我的问题:因为这个命令应该在一个自动化脚本中运行,所以我不能在终端上问这个问题;没有人会接听,脚本将挂起。我如何避免这种情况?
我试过:
> echo y | mkfs -q -t ext4 /dev/sdf
Run Code Online (Sandbox Code Playgroud)
但这并不能解决问题。-q 选项也没有区别。
mgo*_*ven 16
从联机帮助页:
-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.
Run Code Online (Sandbox Code Playgroud)
所以mkfs.ext4
直接调用而不是 via mkfs
,并添加-F
参数以忽略此警告。