How to create a new Ext4 file system partition in Linux

The ext4 journaling file system or fourth extended filesystem is a journaling file system for Linux, developed as the successor to ext3.

Some of its features includes Large file system, Extents, Backward compatibility, Persistent pre-allocation, Delayed allocation, Unlimited numbers of subdirectories, Journal checksums and the list goes on and on...

On this guide we'll go through the process of creating a new partition with the assumption that you've added a new hard drive (whether physical or virtual)  and that you have root (or a user with sudo access) access to the system.

Now to the fun part

Create a new partition in Linux:

Let's first list the existing partitions to identify the hard drive we want to partition, for this we'll use fdisk -l:

$ fdisk -l

 

fdisk -l

Here we can identify 2 drives, the main one which is 30gb (dev/vda) and the additional one which is 50gb (/dev/vdb) which is the one we want to format.

Now let's go ahead and create a partition on this /dev/vdb drive using fdisk by running:

$ fdisk /dev/vdb

 

fdisk /dev/vdb

Once inside fdisk we can view available options or command by hitting m, in this case we'll go ahead and hit n to create a new partition:

fdisk create new partition

Please note that we left everything as default, which makes this partition primary, partition number is 1 and whatever sectors it provides as default, this results in a new partition which in this case is 50gb.

We now need to write these changes by hitting w:

fdisk write changes

We can verify that the new partition has been created by running fdisk -l again:

$ fdisk -l

 

fdisk verify partition was created

It should show at the very end, in this case it's /dev/vdb1.

Formatting the new Ext4 partition:

Now that the new partition exists we need to format it in ext4 so that we can actually use it, for that we'll use the mkfs.ext4 command:

$ mkfs.ext4 /dev/vdb1

 

mkfs.ext4-dev-vdb1

 

Mounting the newly formatted partition:

Now that the partition has been formatted we need to mount it somewhere, for that we'll create a folder, we'll call it /mnt/owend-networks-mount:

$ mkdir /mnt/mynewmount

 

We then need to mount the partition, we do that by using the mount command:

$ mount /dev/vdb1 /mnt/mynewmount
 

And we then use the df command to list all file systems, including the one we just created and mounted, we'll use the -h so we get a human readable format and their mount points and types with the -T option:

$ df -hT

 

df -hT

 

And that's it, we now have a new partition that we can use, whatever I save under /mnt/mynewmount will be saved to that new drive (or vdrive) we added.

Now, something important, in order to make sure this new drive is automatically mounted once we reboot we need to edit our /etc/fstab file with the following:

/dev/vdb1    /mnt/mynewmount  ext4   defaults    0   0

 

I hope you found this guide useful; if you ever need a CloudVPS or Shared Web Hosting please check out our plans here: https://owned-networks.net

  • ext4, linux, file system, partition
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

ownCloud Auto Install Script on Debian 7

Here is an easy way to install ownCloud on Debian 7 with a script, but first, for those who...

NGINX – Allow access only to certain IPs

Nginx has a nice module that not many people know about, it basically enables us...

How to configure NTP client in CentOS

What's NTP? NTP stands for Network Time Protocol, and it is an Internet protocol used to...

Initial Server Setup on CentOS 6

Here are some recommendations to setup your VPS or server when you first get it, some of these...

How To Install nginx on CentOS

What is NGINX? Nginx (pronounced "engine-x") is an open source reverse proxy server for HTTP,...