I am trying to create a single partition using parted command in Linux with ext4 file system using below command non interactively

parted /dev/sdc --script -- mkpart primary ext4 0% 100%

Could someone please tell me do I need to run below commands after this or will it be taken care of automatically by parted command itself.

mkfs.ext4 /dev/sdc

According to parted documentation, the mkpart command creates a partition without creating a filesystem on it.

You might or might not need to run partprobe afterwards, depending on the versions of the kernel and parted used. Older versions might need it, newer ones generally won't. However, running it should not be harmful in any case.

But if you want to keep the partition you just created, your mkfs command should then be:

mkfs.ext4 /dev/sdc1      # not /dev/sdc

If you wanted to use the disk in a so-called "superfloppy" configuration, it is certainly possible to just run mkfs on the whole-disk device /dev/sdc and use it like that. But then there would be no point in partitioning it first, as creating the filesystem like that will overwrite the freshly created partition table.

Having a partition table on the disk that is recognizable on most common operating systems makes it safer to move disks between systems: it avoids the possibility that another operating system (I'm looking towards Redmond...) would not recognize the disk as already containing data, and might offer to helpfully format it.

| improve this answer | |
  • Thanks a lot for your clear cut answer..It helps a lot!! – AswinGeorge Aug 9 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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