Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a script where I make a ext3 filesystem on a disk, the problem is that the script ask user to either say yes or no:

 root@ubuntu:/home/school#  mkfs.ext3 /dev/sdc
 mke2fs 1.42 (29-Nov-2011)
 /dev/sdc is entire device, not just one partition!
 Proceed anyway? (y,n)

I have tried to put -y before mkfs and after sdc but that didnt work. Do anyone have any solutions to do this without user interaction?

share|improve this question
up vote 10 down vote accepted

You should probably not make a filesystem on an entire disk. Instead, you should make it on a partition on the disk (which would be something like /dev/sdc1 rather than /dev/sdc). If you don't already have a partition you can make that first. The partition can (essentially) be the size of the whole disk, if you like. Even when you only want one partition on the disk, you still need to actually make the partition. Many utilities and applications (and people!) will not work, or will behave strangely, if your filesystems are not on partitions.

If you really know what you are doing and you're sure you want to make a filesystem that is not part of any partition, you can do make mkfs.ext3 do this without prompting the user, by using the -F flag. This is almost always preferable to simulating interactive input with a pipe (it's simpler, more self-documenting, and what if something unexpected happens and the question is something else, like the device already being mounted?). On the other hand, in some situations (with some utilities) you may find you have to pipe y or yes to a utility, so it's a good technique to be aware of.

From the description of the -F flag in man mkfs.ext3:

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. In order to force mke2fs to create a filesystem even if the filesystem appears to be in use or is mounted (a truly dangerous thing to do), this option must be specified twice.

So, you can use mkfs.ext3 -F /dev/sdc.

But, to reiterate, you should probably not do this at all because filesystems should almost always be created on a partition.

share|improve this answer
Thanks for help! You are surely right. I made a partition now which i made a filesystem on. – user3185936 Mar 2 '14 at 19:49
By and large, Linux software will handle it fine, but Windows will see it as blank and offer to format it. It also can cause problems installing a boot loader to the disk, and locks you out of resizing and adding another partition later. – psusi Mar 3 '14 at 0:35
@psusi Some time ago, I've had problems in Ubuntu, recognizing and automatically mounting filesystems not containing in partitions, on the desktop. I'm not sure if the problem was with udisks, Nautilus, a combination of the two, or something else. I believe there may also be problems booting to a filesystem that is not on a partition. – Eliah Kagan Mar 3 '14 at 1:26

There is no -y option for mkfs.ext3, you can check by readin its manual page (man mkfs.ext3). However, there is a program called yes that is specifically designed to do what you want:

   yes - output a string repeatedly until killed

So, you could run:

 yes | mkfs.ext3  /dev/sdc

However, bear in mind that you are attempting to create a filesystem on the entire device instead of on a single partition and this is probably not what you want to do. You should first create a partition on the disk and then create a filesystem on that partition.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.