Two Ways to Format a Drive in Ubuntu 16.04

Ubuntu is a great operating system for people who want an open alternative to Windows or Mac. This guide will help newbies to Linux learn how to format a disk using two different methods.

Easy: Disks

Disks is an integrated tool that is by far the easiest way to format a disk on Ubuntu.

Open Disks and select the disk you wish to format from the list of devices in the left panel. This will show details about the disk in the right panel, including volume partition information.

If your disk has only one partition then you can use the “Format Partition…” option.

Ubuntu 16.04 Disks formating a disk

Otherwise click each partition on the disk and remove them using the “-” button, then add one partition by clicking the “+” button. A window will appear with options:

Ubuntu 16.04 Disks Creating a New Partition

Keep the default values, give your disk a name and click “Create” to finish.

Done! You’ve now formatted your disk.

Advanced: Terminal

Sometimes using Disks doesn’t work as intended, such as the error message below.

Ubuntu unmounting filesystem error

We can use Terminal to format a disk instead of using Disks. To do this safely it will take a few steps. First, open Terminal and use this command to see a list of devices connected to your computer:

sudo fdisk -l

This will give us the device location as /dev/sd** (e.g. sdb1). Make note of this as it will be required for the following steps. If you can’t determine which device is your disk, try disconnecting the disk and run the above command, then reconnect it and run the command a second time to identify which disk was added.

Next, unmount the device:

sudo fuser -km /dev/sd** && umount /dev/sd**

To remove the existing partitions on the disk use the following command to erase the partition table. Note the device location doesn’t include the number, like “/dev/sdb”:

sudo dd if=/dev/zero of=/dev/sd* bs=4k count=4k status=progress

Now we have to add a new partition. Enter the fdisk command:

sudo fdisk /dev/sdb

ress “p” then enter show the existing partitions:

Ubuntu 16.04 fdisk command tool

Press “n” to create a new partition:

Ubuntu 16.04 fdisk command making a new partition

You will be asked to define the partition type, number, and sectors. If you want a simple full-disk format then use the defaults by just pressing “Enter” when each prompt appears.

Finally write the changes to the disk pressing “w” and enter. Alternatively you can quit without applying the changes by using the “q” command.

Finally, format the newly created partition to a format you want. Formats for different target systems:

Ubuntu 16.04 mkfs command format types

Commands for common formats:

sudo mkfs.ext4 /dev/sd** — Standard Linux

sudo mkfs.ntfs /dev/sd** — Windows

sudo mkfs.fat /dev/sd** — Mac and Old Devices


[] How to format a USB or external drive?

[] How to format a USB flash drive?

[] How do you monitor the progress of dd?

[] How to Use Fdisk to Manage Partitions on Linux?

[] Forcing a Device to Unmount in Ubuntu Linux

Leave a Reply

Your email address will not be published. Required fields are marked *