Programming and Scripting :: creating an partition / formatting hd



Can anyone tell me what is the *format* command in the terminal if i want to format a drive?

and also. how can i create partitions in my harddrive from my terminal?

any help is appreciated.

thanks.

You need to be superuser or "root" user in order to format or manage partitions:

sudo su


To edit partitions for a drive:

cfdisk /dev/hda

(where hda = primary master IDE drive, hdb=primary slave, hdc=secondary master, etc)

To format partition 1 for this drive with linux EXT2 filesystem:

mkfs -t ext2 /dev/hda1


Or to format a Linux swap partition for #2:

mkswap /dev/hda2


original here.