Formatting a USB external hard drive, could be a very easy task when done with proper tools. However, sometimes there are drives which, for whatever reason will not format. For this reason I have decided to divide this guide into two parts. The first part of this guide applies to any type of drive, not only USB external drives. For this first part I will be using a utility called GParted, which in my opinion is the easiest and most practical method to format a hard drive in Linux. The second part could also apply to both external and internal disks, however, it is geared more towards problematic USB external hard drives. It will be unpractical to use it normally due to the amount of steps involved.
Partitioning and Formatting Most Drives
This first section should work for most drives out there, including USB external hard disks and disks that are connected straight to the computer via IDE or SATA interfaces. In this section we are going to be using GParted. GParted is a free utility designed to partition and format drives in a wide variety of filesystems, some of which include, ext2, ext3, ext4, NTFS, fat32, fat16, etc. GParted is a Linux program; you can download it and install it on your favorite Linux distribution. For those of you who do not have a computer with Linux, you can download the GParted LiveCD, which will let you format the drive without having to run it from a Linux installation. If for some reason GParted refuses to partition and format the drive; scroll down to the next section “Problematic Drives”
1) On the top right, select the drive you wish to partition and format from the drop down menu.
2) On the top menu click on “Partition” and then “New“.
3) On the “Create new Partition” window, select “Primary Partition“.
4) Then select the type of filesystem you wish to have. In the picture below I have selected the fat32 filesystem. However, even though Linux understands fat32, it is not its native filesystem. A ext2, ext3 or ext4 filesystem will be more appropriate and won’t be subjected to the limitations of fat32. One drawback of choosing Linux filesystems is that they are not readable by Windows; not that it really matters that much, since you will still be able to clone any filesystem, but sometimes you want to use the hard drive to store other files beside your Clonezilla images.
5) Click on “Add” button to save changes.
6) Finally, on the main screen, click on the green checkmark to apply changes and start the process.
The process will take a few minutes, depending on the size of the hard drive.
I recently bought a 2TB external hard drive I was planning to use with Clonezilla Live. However, for some reason I just could not get it to work reliably with any Linux LiveCD. The LiveCD would recognize the hard drive half of the time. Sometimes the LiveCD would detect the drive and sometimes it would not. Ubuntu would let me format the drive but then “lshw” would not detect nor list it. I even tried GParted, which totally failed creating any new partitions on the drive. Finally, I discovered a solution to my problem: the command “fdisk“. If you are in a similar situation here’s what you need to do:
To identify your hard drive, issue the following command in your shell prompt:
sudo fdisk -l
Look for the device file name identifying your drive’s partition. For this example lets say we identified it as /dev/sdb1; this means that your drive will be /dev/sdb.
Delete Original Partition
We have identified our drive for this example as being /dev/sdb, yours could be /dev/sdd, /dev/sde, etc. Make sure you identify it correctly because after this you will lose all the data in your drive. Issue the following command at your shell prompt (Again, remember that you will lose all the data in the drive after this, so make sure you have any files you wish to save backed up):
sudo fdisk /dev/sdb
at the “Command (m for help)” prompt, delete the current partition by typing “d“, then, save changes by typing “w“.
Create New Partition
To create new partition, issue again the following command at the shell prompt:
sudo fdisk /dev/sdb
At the “Command (m for help)” prompt, type “n” to create a new partition, then type “p” to make it a primary partition. Next, type the number “1” to indicate a that this is the first primary partition on the drive. Then type “t” to specify partition type; here you are going to be asked a hexadecimal number that indicates whether the partition is fat32, ext3, ext4, etc, for example if we want an ext3 partition we would enter “83“. You can get a complete list of identifiers by typing “L” at the “Command (m for help)” prompt. The following table lists some of the most common ones:
82 Linux swap / So 83 Linux (ext2, ext3, ext4, etc.) 85 Linux extended c7 Syrinx 6 FAT16 b FAT32 7 HPFS/NTFS 8e Linux LVM a5 FreeBSD a6 OpenBSD a9 NetBSD af HFS / HFS+
Once done choosing the partition type, enter “w” to save changes and you are done creating your partition table, now you need to format it.
Format New Partition
In our example, we created a partition table for Linux; now we are going to format this partition as Ext3. To format the newly created partition, issue the following command in the terminal prompt:
sudo mkfs.ext3 /dev/sdb
Replace “ext3” with ext2 or ext4 if you wish to format in these filesystems.
For fat32, issue the following command instead:
sudo mkfs.vfat /dev/sdb
The time this process will take to complete will depend on the size of your drive, it is usually a few minutes.
Freeing Reserved Space
Whenever a drive is formatted in Linux, it reserves about 5% of the total space on the drive for the operating system to continue using the hard drive to operate, even if it get full. This is totally unnecessary for a USB external hard drive if you are only going be using it to store data and not to run an operating system.
To get rid of this reserved space, identify your partition using the command
sudo fdisk -l
For our example we are going to assume we identified the partition in our drive as /dev/sdb1. Run the following command to eliminate the reserved space:
sudo tune2fs -m 0 /dev/sdb1
This will set the reserved space from taking-up 5% of the drive to 0%. Take a look at this “before and after” graph: