How do I script mkfs asking "is entire device, not just one partition! Proceed anyway?"
32,403
Solution 1
From the 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.
So call mkfs.ext4
directly instead of via mkfs
, and add the -F
parameter to ignore this warning.
Solution 2
expect
is what you're looking for. Try something like this:
#!/usr/bin/expect
spawn mkfs -q -t ext4 /dev/sdf
expect "/dev/sdf is entire device, not just one partition!\nProceed anyway? (y,n)"
send -- "y\r"
expect eof
Related videos on Youtube
Comments
-
William Nyqvister over 1 year
I'm trying to create a script that formats an Amazon EC2 EBS volume, so I can mount it.
From the command-line, it looks like this:
> mkfs -q -t ext4 /dev/sdf /dev/sdf is entire device, not just one partition! Proceed anyway? (y,n)
(The command is correct; no need to create a partition table for my purpose)
My problem: because this command is supposed to be run in an automated script, I can't have that question on the terminal; nobody will be answering and the script will hang. How do I avoid this?
I tried:
> echo y | mkfs -q -t ext4 /dev/sdf
but that doesn't do the trick. The -q option makes no difference either.
-
bahamat almost 12 yearsPerhaps you don't feel you need a partition table, but is there any reason why you should not have a partition table?
-
William Nyqvister almost 12 yearsMore things that can go wrong. Note my question is really a shell question, not a partition table question.
-
bahamat almost 12 yearsYou're claim that "more things can go wrong" is completely baseless. It sounds like you're using your fear and misunderstanding to fuel your bad decisions.
-
William Nyqvister almost 12 yearsLook, bahamat, I'm just talking about myself. I know that if I have to do two things instead of one, my likelihood of screwing up goes up. Maybe it's different for you, but none of this is the subject of this question at all anyway. #troll
-
-
William Nyqvister almost 12 yearsWhat does expect do differently than reading from stdin?
-
Matthias Braun about 3 yearsWhy wouldn't it make sense, according to the man page, to create a file system on the unpartitioned device?
-
mekb over 2 yearsif there's another warning it won't send y