These are the commands you need to format your drive into ExtFS:
diskutil eraseDisk [filesystem] [name to use] [disk identifier]
diskutil eraseVolume [filesystem] [name to use] /Volumes/[volume name]
EraseDisk is to create a single partition on a device, and eraseVolume is in case you have several partitions on a device and want to format just one.
[filesystem] may be replaced with UFSD_EXTFS for Ext2 or UFSD_EXTFS3 for Ext3. You can also see the complete list of available file system options if you run this command:
[name to use] is for the new partition name.
[disk identifier] looks like this “disk1” and you can look it up in disk information or if you run this command:
[volume name] is a current volume name.
As an example, this is a proper way to use a command to format disk:
diskutil eraseDisk UFSD_EXTFS3 mydisk disk2