ComTech: IT Support Stirling

Formatting a hard drive in Linux

ComTech: IT Support Stirling

Imagine the situation.  You are using Linux and you want to format a particular hard drive.  What tool would you use?  If you like GUI’s then the best tool to use would be GParted.  But what if you think that GUI’s are not your thing and you want to use the command line?  Then you want fdisk.

Ok here goes, open up a terminal and type su.  When prompted enter your root password.

Type fdisk /dev/device (where device is the ID of your hard drive you want to format eg sda)

Next you want to check for any existing partitions on the drive by pressing p.

You now want to delete any existing partitions by pressing d.

Press n to construct a new partition on the hard drive.

When you get the choice of specifying cyclinders use the default for first and last (unless you have a specific need to change them).

Now we need to write the partition to the disk and we do this by pressing w.

It is now time to make the filesystem on the partition.  First off though you have to choose the file system you want.  At the moment the best one to use in Linux is ext4.  If however you intend to use the hard drive with Windows at some point then use NTFS.

In your terminal type mkfs -t ext4 /dev/device (where device is the ID of your hard drive you want to format eg sda).

All that is left to do is mount the hard drive.  If the hard drive is an external one then it will be automatically mounted when you plug it in.  However if the drive is an internal IDE or SATA drive you will need to enter it into the fstab file which is covered here.

About the Author


Hi I’m Chris Wakefield the owner of ComTech IT Support. I provide Windows, Mac and Linux based IT Support to small businesses in Stirling, Alloa and Falkirk.

Follow @Comtech247 on Twitter






One thought on “Formatting a hard drive in Linux

Leave a comment

Your email address will not be published.


Get every new post delivered to your Inbox

Join other followers

WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera
WP Like Button Plugin by Free WordPress Templates