This question already has an answer here:

How do you format an external hard drive to ext4 via the command line in ubuntu?

marked as duplicate by muru, kiri, αғsнιη, Eric Carvalho, Charles Green Nov 14 '14 at 0:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


The command is mkfs.ext4, see its man page.

If you are ok with the default settings(1), it's just

mkfs.ext4 /dev/yourpartitionhere


(1) from the man page:

The defaults of the parameters for the newly created filesystem, if not overridden by the options listed below, are controlled by the /etc/mke2fs.conf configuration file. See the mke2fs.conf(5) manual page for more details.

  • Okay thanks. How do you get the device information? Like the command to know if it is /dev/sda or /dev/sdb? – ss_millionaire Nov 13 '14 at 8:03
  • 1
    Never mind i got it..its sudo fdisk -l . Thanks – ss_millionaire Nov 13 '14 at 8:22
  • May also need to use fdisk fist to setup the partitions sudo fdisk /dev/sdx -> d -> n -> 1 -> enter -> enter -> w then the above sudo mkfs.ext4 /dev/sdx1 depending on the partitions, it should be /dev/sdx1 most likely it is not /dev/sdx – NZ Dev Dec 16 '18 at 11:20

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