need mkfs command to be interactive in RHEL 7

Latest response

Hi Everyone,

 

We need to have the mkfs command to be more interactive upon execution. As of today, If a user specifies the device name incorrectly, mkfs would not validates the input given and executes successfully without asking for any prompt to the user.

 

For example,

 

Our harddisk device name is /dev/sda and assume that we have partitions numbered from 1 to 5.

 

If we create a new partition named "/dev/sda6" and run "mkfs.ext3 /dev/sda" by mistake, the system would not ask any confirmation from the user and as a result of this my entire system would be compromised.

 

Therefore, we would like to have the "mkfs" command to asks for a confirmation prompt like "Do you really want to continue? (yes/no)" to the user in order to avoid any human error.

 

Please let me know the feedback and kindly ignore if we have this option already in our current versions of RHEL.

 

Thanks and Regards,

Venuraja 

Responses

mkfs.ext3 does this today already:

# mkfs.ext3 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n)

Not exactly. On a RHEL 6.0 box there is no interactivity, nor on a RHEL5.6 box. Only in certain cases, like yours (using entire device) or if the device is not a block special device (i.e. a raw file created using dd).

 

However if you snag a partition, and simply execute mkfs.ext3 on that partition, you are NOT prompted.

A "user" executing mkfs needs to have root permissions ergo, it is a "user" which should think before he types.

 

I get a real Windows-like feeling asking for confirmation before every potentially dangerous command is executed.

 

A user with root permissions should always double check his / her input before hitting the enter button.

Anyone with being given root access to a system should be expected to have the skills to use it safely.   If you start adding safety checks to mkfs, where you do stop - there are so many command which can destroy data / systems.

 

Also, one of my past companies, insisted on aliasing rm to "rm -i", so you were prompted for the removal, based on the idea that the check would make you think, after a week of saying "Yes I really wanted to delete this file" people stopped looking and confirmed without looking, so it has not effect at all.

 

Very true. As soon as someone has root access to a machine, you better trust that they know what they are doing. And as an administrator, you must always be wary of what you are doing. Interactivity is great but if the admin is not taking the time to use the interactivity for what it's useful for, it is a waste.