Formatting and partitioning a drive under Ubuntu

Today we will take a new drive in Ubuntu, and format and partition it. I will be doing this under a VM, because it is easy to add or delete drives.

Software used:

1. Adding a second drive

I started by adding a second drive to my Ubuntu VM.

2. Format and partitioning

Now that we’ve added the drive, we can boot into Ubuntu.

The following command will list all available drives.

 sudo fdisk -l

If all went well you should see 2 entries:

You should now identify the new drive. In my case it is /dev/sdb

Now, to format the drive:

 sudo cfdisk /dev/sdb

To check the results of our work again type

 sudo fdisk -l

3. Creating the filesystem

We will use the ext4 filesystem (the most common Linux filesystem today; if you want to learn more go here: https://opensource.com/article/17/5/introduction-ext4-filesystem):

On the new drive (/dev/sdb in my case) you should see a partition (/dev/sdb1 in my case). Now we only need to format it. For this you can use the mkfs utility. To see all possible formatting options type

 mkfs

and press tab tab.

In our case we will use:

 sudo mkfs.ext4 /dev/sdb1

And we are done 🙂

Automounting

If you want the new partition to be mounted at boot time, you can follow my tutorial here.

2 comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.