You are on page 1of 18

10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux


Menu


Menu 

How to Create a New Ext4 File System (Partition) in Linux

Ravi Saive Last Updated: February 12, 2020 Linux Commands 13 Comments

The ext4 or fourth extended filesystem is a widely-used journaling file system for Linux. It was designed
as a progressive revision of the ext3 file system and overcomes a number of limitations in ext3.

It has significant advantages over its predecessor such as improved design, better performance, reliability,
and new features. Although it is best suited for hard drives, it can also be used on removable devices.

This article will show you how to create a new ext4 file system (partition) in Linux. We will first of all look
at how to create a new partition in Linux, format it with the ext4 file system and mount it.

Note: For the purpose of this article:

We will assume that you have added a new hard drive to your Linux machine, in which you will
create the new ext4 partition, and
If you are operating the system as an administrative user, use the sudo command to gain root
privileges to run the commands shown in this article.

Creating a New Partition in Linux


List the partitions using the fdisk -l or parted -l commands to identify the hard drive you want to partition.

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 1/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

# fdisk -l

OR

# parted -l

RedHat RHCSA and RHCE Certification Preparation Guide - Get This Book

List Linux Partitions

dotnettricks.com
OPEN
Learn Angular 11 from Scratch

Looking at the output in the screenshot above, we have two hard disks added on the test system and we
will partition disk /dev/sdb .

Now use parted command to start creating the partition on the selected storage device.


# parted /dev/sdb

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 2/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

Now give the new disk a label using the mklabel command.

(parted) mklabel msdos

Then create a partition using the mkpart command, give it additional parameters like “primary” or
“logical” depending on the partition type that you wish to create. Then select ext4 as the file system type,
set the start and end to establish the size of the partition:

(parted) mkpart                                                            


Partition type? primary/extended? primary

File system type? [ext2]? ext4

Start? 1

End? 20190

Create a New Ext4 Partition

To print the partition table on the device /dev/sdb or detailed information about the new partition, run
the print command.

(parted) print

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 3/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

Print Partition Table

Now exit the program using the quit command.

Formatting New Ext4 Partition


Next, you need to properly format the new partition with the ext4 file system type using the mkfs.ext4 or
mke4fs command as follows.

# mkfs.ext4 /dev/sdb1

OR

# mke4fs -t ext4 /dev/sdb1

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 4/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

Format a New Ext4 Partition

Then label the partition using the e4label command as follows.

# e4label /dev/sdb1 disk2-part1

OR

# e2label /dev/sdb1 disk2-part1

Mounting New Ext4 Parition in File System


Next, create a mount point and mount the newly created ext4 partition file system.

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 5/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

# mkdir /mnt/disk2-part1

# mount /dev/sdb1 //mnt/disk2-part1

Now using the df command, you can list all file systems on your system together with their sizes in a
human readable format (-h) , and their mount points and file system types (-T) :

# df -hT

Show Linux Filesystem with Mount Points

Lastly, add the following entry in your /etc/fstab to enable persistent mounting of the file system, even 
after a reboot.
https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 6/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

/dev/sdb1 /mnt/disk2-part1 ext4 defaults 0 0

You might also like to read these following related articles:

How to Add New Disks Using LVM to an Existing Linux System


How to Add a New Disk to an Existing Linux Server
10 Best File and Disk Encryption Tools for Linux
How to Create a Virtual HardDisk Volume Using a File in Linux

That’s all! In this article, we’ve explained how to create a new partition in Linux, format it with ext4 file
system type and mount it as a filesystem. For more information or to share any queries with us, use the
feedback form below.

 Commandline Tools , Linux Tricks , Partition

 How to Encrypt Drives Using LUKS in Fedora findmnt – Shows Currently Mounted File Systems
Linux in Linux 

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or
doubts? do ask for help in the comments section.

dotnettricks.com
OPEN
Learn Angular 11 from Scratch

If You Appreciate What We Do Here On TecMint, You Should


Consider:

TecMint is the fastest growing and most trusted community site for any kind of
Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to
search or browse the thousands of published articles available FREELY to all.

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 7/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a
token of appreciation.

We are thankful for your never ending support.

Related Posts

15 Practical Examples of ‘echo’ command in Linux

15 Basic ‘ls’ Command Examples in Linux

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 8/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

3 Ways to Find Out Which Process Listening on a Particular Port

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 9/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

16 Top Command Examples in Linux [Monitor Linux Processes]

10 Commands to Collect System and Hardware Info in Linux

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 10/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

10 sFTP Command Examples to Transfer Files on Remote Servers in Linux

13 thoughts on “How to Create a New Ext4 File System


(Partition) in Linux”

Jordi Barcelona
November 6, 2020 at 2:22 pm

Hello, I don’t know how Ravi Saive found out the size of the partition, but I’ve found you can use
percent to size the partition (you can reply 100% to the question End? and it uses the whole free
space available)

Reply

DrSpaced
May 25, 2020 at 8:44 pm

Another thing that is missing is what sector size should be considered (physical or logical). In this 
example, it did not matter because both were the same.
https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 11/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

However, in my case the two are not the same. Which to choose? I would think that it is the logical
sector size, but if we are dealing with /dev/sda (in my case), perhaps this indicates the use of the
physical sector size.

Reply

DrSpaced
May 21, 2020 at 9:00 am

This would be a wonderful tutorial if I knew how you got the size for the new partition. It seems
that you pulled the number 20190 out of thin air! How do I get the right number if I want to use
the whole disk?

Reply

test
September 10, 2021 at 8:52 pm

0% and 100% as start and end work.

Looks like the author copied some really old instructions. mklabel gpt should be your go-to today,
otherwise, you will get errors with disks over 2.5ishTB

Reply

Bree Mattison
May 3, 2020 at 11:22 pm

Is there a way to create 2 ext4 partitions?

Reply

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 12/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

Morgan
April 25, 2020 at 6:04 pm

Thanks for this article. Is there a way of renaming /mnt/disk2-part1 to something else than
“disk2-part1“?

Reply

Ravi Saive
April 27, 2020 at 11:12 am

@Morgan,

This article will help you out to rename your partition – https://www.tecmint.com/change-modify-
linux-disk-partition-label-names/

Reply

Stephen Jones
February 11, 2020 at 7:01 pm

There is a typo in this command:

# e2abel /dev/sdb1 disk2-part1

Should be e2label.

Reply

Ravi Saive
February 12, 2020 at 11:30 am

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 13/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

@Stephen,

Thanks for pointing, corrected the command in the article.

Reply

dragonmouth
June 6, 2019 at 5:20 pm

I prefer to use GParted to do my disk manipulations. With GParted I do not need to learn and
remember cryptic, unintuitive commands. With a GUI application, there is much less chance of
using the wrong option or misspelling a command and completely wiping out the entire disk.

Reply

Aaron Kili
June 7, 2019 at 9:28 pm

@Dragonmouth

Thanks for sharing your thoughts with us.

Reply

chris kane
March 21, 2020 at 5:08 am

Yeah true but there are people using servers that find this beneficial.

Reply

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 14/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

dragonmouth
September 13, 2021 at 6:38 pm

People for whom these instructions would be beneficial do not use servers. OTOH, people who
use or deal with servers have this procedure memorized.

Judging by the questions and comments so far, it seems that the posters have very little idea of
what is being done. By using a GUI tool like GParted, they would SEE what is happening with
the disk they are trying to partition rather than having to imagine it.

I am all for using CLI but when it is actually an improvement on GUI. This is 2021 and, in the 30
years of Linux’s existence, many CLI procedures have been released as GUI tools. For some
reason, Linux tech writers are pushing the command line as if it was The Greatest Thing Since
Sliced Bread. Sure, CLI may be l33t but it certainly IS NOT inviting and encouraging to new
Linux users. How many articles are there extolling the virtues of MS-DOS or even the current
Windows command line?

Reply

Got something to say? Join the discussion.


Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that
all comments are moderated and your email address will NOT be published.

Name *

Email *

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 15/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

Website

Save my name, email, and website in this browser for the next time I comment.

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Post Comment

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

Over 3,500,000+ Readers

A Beginners Guide To Learn Linux for Free [with Examples]

Red Hat RHCSA/RHCE 8 Certification Study Guide [eBooks]

Linux Foundation LFCS and LFCE Certification Study Guide [eBooks]

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 16/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

Best of Fashion
Cilory.com

Learn Linux Commands and Tools

Real Time Interactive IP LAN Monitoring with IPTraf Tool

How to Record and Replay Linux Terminal Sessions using ‘script’ and ‘scriptreplay’ Commands

How to Convert Images to WebP Format in Linux

ifconfig vs ip: What’s Difference and Comparing Network Configuration

How to Copy File Permissions and Ownership to Another File in Linux

Find Top 15 Processes by Memory Usage with ‘top’ in Batch Mode

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 17/18
10/9/21, 5:52 AM How to Create a New Ext4 File System (Partition) in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

Linux Server Monitoring Tools

How to Monitor Performance Of CentOS 8/7 Server Using Netdata

Collectl: An Advanced All-in-One Performance Monitoring Tool for Linux

nload – Monitor Linux Network Bandwidth Usage in Real Time

Monitor Server Resources with Collectd-web and Apache CGI in Linux

Duf – A Better Linux Disk Monitoring Utility

VnStat PHP: A Web Based Interface for Monitoring Network Bandwidth Usage

https://www.tecmint.com/create-new-ext4-file-system-partition-in-linux/ 18/18

You might also like