Today I will show you how to format a hard disk using Fdisk. Fdisk comes already installed on most modern Linux distributions by default.
For the purpose of this tutorial I will be using Fdisk on Ubuntu 12.04 to format a 16Gb USB penstick with the ntfs file system.
First we need to see what our 16Gb USB penstick is mounted as so open up a terminal and type:
sudo fdisk -l
and type your password when prompted. You should get a screenshot similar to the one below.
In this case my 16Gb USB penstick is mounted at /dev/sdc1.
sudo fdisk /dev/sdc1
and you should get the command prompt shown below.
Now we need to check the existing partitions on the penstick so type:
to get the screenshot below.
Now we know what is on the drive it is time to delete it so type:
You will then be asked for the partition number (1-4). In my case I have 4 partitions on the disk and I need to delete them all. So I will type 1 and this will erase the 1st partition only. I would then be left with partitions 2 – 4 and to remove these I would repeat the procedure until all the partitions have been erased.
We now need to set up the new partition so in your terminal type:
Because this is the first partition on the drive type:
You will now be asked for a partition number. Choose 1 and then press return. When asked to specify the First Sector choose the default by pressing Return. Again accept the default Last Sector by pressing Return.
Now that the partition parameters have been specified we need to write them to the hard drive and we do that by typing:
All that is left to do is to make the filesystem on the hard drive and to do that we type:
sudo mkfs -t ntfs /dev/sdc1
Next time I will show you how to accomplish the same task using GParted (for those who like a GUI).
About the Author
Hi I am Chris Wakefield the owner of ComTech IT Support. I provide Windows and Linux based IT Support, laptop repairs and computer repairs to both business and personal clients in and around Stirling.
For a list of what I can offer you why not visit my website www.comtech247.net where you will find a list of my services, testimonials, blog and much more.