fdisk Command: How to Create Disk Partitions (MBR) in Linux

In this lesson we’re going to discuss managing Master Boot Record (MBR) disk partitions (fdisk Command) on a Linux systems hard drive.

Introduction

Now the MBR partition formats been around for quite a while since the early 1980s and is still used a lot on Linux systems.

Therefore, you need to be familiar with managing these types of partitions.

But be aware that there are many newer disk partitioning schemes available that are much more robust and much more flexible than the old MBR partitioning scheme is.

But for the time being there’s a lot of systems that still use MBR, so you need to be familiar with it.

Manage MBR partitions on a Linux system

Now you manage MBR partitions on a Linux system using the fdisk Command.

There are other utilities you could use but fdisk is the one that is common across all Linux distributions.

You can use fdisk to view disk partitions, you can use it to create new partitions, or you can use it to delete partitions from the shell prompt.

Now do be aware that in order to run at this you do have to be logged in to the system as a root user because it does require root level access to the system.

The syntax for using fdisk command is shown here.

First we run fdisk and then we specify the name of the hard disk device that we want to manage partitions on.

fdisk [options] device_name

To list the partition table of all devices pass the -l option to the fdisk command.

# fdisk -l

To list the partition table of a specific device, run the fdisk command with the -l option, followed by the device name.

# fdisk -l /dev/sdc
Disk /dev/sdc: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf75cb881

Device     Boot Start     End Sectors Size Id Type
/dev/sdc1        2048 4196351 4194304   2G 83 Linux

Familiar with the device naming syntax

Now notice in this diagram that, We have three hard disks within this Linux system, and you need to be familiar with the device naming syntax in order to use fdisk correctly.

Device Naming Syntax
Device Naming Syntax
  • The first hard disk in the system is sda.
  • The second hard disk in the system is sdb.
  • And the third hard disk in the system is sdc.

Notice that all of these hard disks are addressed using a file in the /dev directory.

So, if I wanted to manage the partitions on second hard disk in the system then I would use the following command.

# fdisk /dev/sdb

Now you might be wondering How the system decides which hard disk is sda which one is sdb and which one is sdc.

And it’s all based on which connector the particular hard disk is connected to on your hard disk controller.

device naming allocation as per port
device naming allocation as per port

For example, on a system that uses SATA hard disk drives then the connector is connected to the lowest numbered SATA connector for example say to SATA0 is going to be sda.

The hard disk connected to the next higher numbered SATA connector such as SATA1 is going to be sdb.

And the hard disk connected to the next highest numbered SATA connector such as SATA2 is going to be sdc and so on.

How to create a partition in Linux

So, at this point you need to enter commands to tell fdisk what exactly it is you want to do with the partitions on the hard disk.

I want to create a partition in the third hard disk connected to my system, so to do this I have to run the following command.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x37845dec.

Command (m for help):

And as you can see here once fdisk is running you’re provided with a command prompt and at this command prompt you enter the various fdisk commands that manipulate the partitions on the disk.

Print fdisk Help menu

Before you go any further it’s really a good idea at this point to enter the m command as shown here because when you do it will display a list of all the different commands you can use with fdisk Command.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x37845dec.

Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


Command (m for help): 

For example, you can use n to create a new partition, you can use p just to view partitions, you can use t to change a partition type, and notice right here you also have the option with d to delete an existing partition.

You should be very careful before you use the Delete action by the way, because if you delete a partition with fdisk then you’re going to lose all the data that was on that partition and once those changes are committed to disk there’s no going back the changes aren’t reversible.

So, before you delete a partition make sure that doesn’t have any data on it that you want to save and if it does back it up first or you’re going to be really sad.

Print the Partition Table

Now before you do anything with fdisk it’s really a good idea just to see what’s already on the disk to see if there are already any existing partitions and the way you do that is by entering p at the command prompt for Print.

It will just print out a list of all the different partitions currently on the drive.

This will help you determine first of all if there’s sufficient space on the drive to even create a new partition and if so then what numbers can needs to be assigned to that new partition when you create it on the disk.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x95dd75cf.

Command (m for help): p
Disk /dev/sdc: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x95dd75cf

As you can see here in the output of this p command there are no partitions.

How to create a new partition in Linux

So, we can go ahead and just add new partitions to this disk without worrying about managing any existing partitions. With that in mind let’s talk about then creating a new partition.

To do that you use the n command at the fdisk prompt.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xbb0d51b8.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)

Partition Types

Now when you do this, you’ll have to specify whether or not you want to create a Primary partition or whether you want to create an Extended partition.

Here’s a key thing that you have to remember when you’re dealing with MBR partitions and that is the fact that, any hard disk in your system the use of MBR partitions can only have four partitions maximum defined in this partition table and that can be a limitation.

Now if you intend to just create four partitions or less maybe two then it’s not a big deal you can just use Primary partitions.

However, if you need more than four partitions on the disk then we’ve got a problem and by the way on a Linux system it’s very common to need more than four partitions on the hard disk drive.

In this situation what you do is include at least one Extended partition in your four partitions.

Now Extended partitions are great.

Using an extended partition, you can create many Logical partitions within that Extended partition.

Notice right here that it says that an Extended partition is really just a container for Logical partitions.

So, let’s take a look at an example.

Let’s suppose that we need six partitions on the hard drive in this Linux system.

Well we already know that we can only have a maximum of four.

So, we already know that one of those four partitions must be an Extended partition.

To do this what we could do is create first three regular partitions (Primary Partitions) and then we could take the rest of the disk space and define this as an Extended partition instead of a regular partition.

And this is cool because what we then do is then create lots of Logical partitions inside of this Extended partition.

Disk Partition Structure
Disk Partition Structure

So, we have three Primary Partitions and three Logical Partitions within the one Extended Partition.

So, In effect what we have then is six partitions on the disk when we’re technically only allowed to have four.

Note: Now please be aware that you can only have one Extended partition per disk.

Recommended Tips:

So, the general rule of thumb is that:

  • Create your Primary partitions first, however many it is you want to create one, two or three.
  • Then you create your Extended partition using the remaining space on the drive.
  • And then define all of the Logical partitions that you want to use within that one extended partition.

How to create a Primary partition

To create a Primary partition, you enter a p after entering in, if you wanted to create an Extended partition you would enter e instead of p.

In this example, we used p to create a primary partition.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xbb0d51b8.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p

Assign a number to the partition

And then you have to specify what number you want to assign to that partition.

And by default, what it’s going to do is take a look at the existing partitions on the disk and then it will suggest using a number one higher than the number assigned to the last partition.

So, In the example that you see here there are no partitions on the disk therefore the default number that’s going to be assigned is 1.

Now you could use a different partition number if you wanted to.

I rarely do, I usually just use the default because it works out beautifully.

fdisk knows what the next partition number probably should be.

So, in this case I just hit enter to use the default value of 1.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xbb0d51b8.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):  

Set the Partition Size

And then the next thing we have to do specify how big we want the partition to be and this is done by

specifying the beginning and ending sectors that we want to use for the partition on the disk.

Specify the First Sector value

First, we have to specify the first sector that we want to begin with on the partition.

So, by default, what fdisk is going to do is specify the first available sector where partition could begin.

Note: You don’t have to use it if you don’t want to but to use space effectively it’s a good idea to do it.

Now in this situation there are no partitions defined so it’s going to suggest you use the first available sector which is 2048 and that will place our beginning sector right down around here.

So, in this case I just hit enter to use the first sector value of 2048.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xbb0d51b8.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):  
First sector (2048-6291455, default 2048): 

Specify the Last Sector value

Then you have to specify what the last sector will be and notice that there are several different options that you can use for specifying the last sector.

You could either specify the last sector you want to use and if you’re good at Math you can calculate it out that’s fine.

Or you can specify a total number of sectors that you want to use and let fdisk determine what the actual ending sector number should be.

Or what I usually do is just specify size how big do I want the partition to being specified in Kilo Bytes (KB), Megabytes (MB), Gigabytes (GB), Terabytes (TB) and so on.

Notice over here that I said I just want this partition to be 2 Gigabytes in size.

So, fdisks then calculated where the ending sector should be right there and set it up for me and when I’m done I’ve got a new 2GB partition on the hard disk drive.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf75cb881.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-6291455, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-6291455, default 6291455): +2G

Created a new partition 1 of type 'Linux' and of size 2 GiB.

Here are the letters you can use when sizing a partition.

  • Kilobytes (KB) – K
  • Megabytes (MB) – M
  • Gigabytes (GB) – G
  • Terabytes (TB) – T

When sizing the partition, you have to follow the syntax given below.

+size{K,M,G,T,P}

As you may have noticed in the above example, while setting the 2GB size for the partition, I mentioned the size something like this: +2G

Print the Partition Table

Now after you create a new partition it’s a really good idea to run the p command again so you can see all the partitions on the disk.

Command (m for help): p
Disk /dev/sdc: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf75cb881

Device     Boot Start     End Sectors Size Id Type
/dev/sdc1        2048 4196351 4194304   2G 83 Linux

As you can see here, we created the first partition on the /dev/sdc hard disk drive.

Here you can also see some important information’s like:

  • Starting sectors – 2048
  • Ending sectors – 4196351
  • Total number of sectors – 4194304
  • Size – 2G
  • Partition type – 83 (It’s an Standard Partition)

Now notice over here that once we create a partition that we use a different device file to refer to that partition instead of referring to it as /dev/sdc which points to the hard disk itself.

We point to the First partition on that hard drive which has its own device file and which is /dev/sdc1.

This indicates the First partition on the third hard drive in the system.

Commit the Partition to Disk

Now it’s important to note at this point that the partition actually hasn’t been written to disk yet.

All the changes that we’re making to the disk partitioning is only saved in memory it hasn’t actually been committed to the disk yet.

And this is really nice because it allows you to play with the partitions before you actually make the changes.

And if you go through a whole partitioning scheme and realize boy I really don’t like this I want to start over all you have to do is enter q at the fdisk command prompt and none of the changes that you specified will be written to disk.

Everything will be back the way it was before you started using the fdisk Command and when you’re running fdisk I always tell students q is your best friend.

Now before you commit the partition to disk you may need to change the partition type.

How to change the partition type in Linux

When we created that partition just a second ago it was created as a Standard Linux partition and that’s the default behavior for fdisk.

Usually this is probably what you want to do because you want to store data on that partition.

But what would you do if you wanted to create not a data partition but instead you wanted to create a swap partition that will be used for virtual memory. Well to do this you have to use a different type of partition.

This is done by entering t at the command prompt and then entering the ID number of the partition type that you want to use.

Now if you don’t know what the ID number of the partition type you want to use is, you can enter the l (Lowercase L) command and it’ll bring up a list of all the possible partition types.

1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden or  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi ea  Rufus alignment
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         eb  BeOS fs        
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ee  GPT            
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f1  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f4  SpeedStor      
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      f2  DOS secondary  
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fb  VMware VMFS    
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fc  VMware VMKCORE 
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fd  Linux raid auto
1c  Hidden W95 FAT3 75  PC/IX           bc  Acronis FAT32 L fe  LANstep        
1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot    ff  BBT         

For example, If we wanted to create a swap partition instead of a data partition we would change its type to 82.

Right here notice that a Standard Linux partition is type 83 that’s the type of partition you store data.

In partition type 82 is used to create a swap partition.

So, at this point we have defined our new partitioning scheme and we’re ready to commit those partitions to disk.

To do this you use the w command.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf75cb881.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-6291455, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-6291455, default 6291455): +2G

Created a new partition 1 of type 'Linux' and of size 2 GiB.

Command (m for help): p
Disk /dev/sdc: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf75cb881

Device     Boot Start     End Sectors Size Id Type
/dev/sdc1        2048 4196351 4194304   2G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Now once you enter w things are a little more serious because it will make the changes to the partitioning and if you decided to delete a partition that partition gets deleted and if you decided to create a new partition it gets created.

So be very careful before you use the w command.

Remember you can always enter q to back out without applying the changes if you’re not happy.

Update new partition to kernel

Now after you’ve written your partitions to disk be aware that you may actually need to reboot the system before the Linux kernel will recognize the partition changes you made with fdisk Command.

Now that is actually kind of a pain because a lot of times you don’t want to take the system down just to allow the kernel to see a new partition.

That’s particularly true on a server system where there may be active connections going on with network clients and you don’t want to take that server out of commission even it’s only for a few minutes to reboot.

Therefore, what you can do is run the partprobe command.

The partprobe command will force the kernel to see the new partition table without rebooting the system.

# partprobe -s
/dev/sda: msdos partitions 1 2 3
/dev/sdb: msdos partitions
/dev/sdc: msdos partitions 1

The -s option causes partprobe to show a summary of what it finds.

So, as you can see here it found the new partition that was just created on /dev/sdc.

We have now successfully created a new partition.

Now before storing data in this partition, we need to format and mount it.

Formatting the partition in Linux

You can format any partition using the mkfs command.

So, type the following command to format the partition.

In this example, I am formatting this partition with the ext4 file system.

# mkfs.ext4 /dev/sdc1
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 524288 4k blocks and 131072 inodes
Filesystem UUID: 530cf469-c497-440f-b5fd-7883f7c43d24
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

Mount the partition

Now you can mount this partition using the mount command.

Suggested Read: How to Mount and Unmount File Systems in Linux

Temporarily mount the File System

Here I am mounting this partition in the /mydata directory.

# mount /dev/sdc1 /mydata/

To check whether the partition is mounted, run the following command.

# mount
/dev/sda3 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda1 on /boot type ext4 (rw,relatime,seclabel)
/dev/sdc1 on /mydata type ext4 (rw,relatime,seclabel)

This method will temporarily mount your partition.

Permanently mount the File System

To mount this partition permanently, you must enter this partition in the /etc/fstab file.

# nano /etc/fstab

# /etc/fstab
# Created by anaconda on Sun Jan 24 10:20:39 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=b119d862-07b7-4842-a6ea-cd2da64f8eae /                       xfs     defaults        0 0
UUID=e9f23f2d-118e-4a5e-94ab-b08afb78a3be /boot                   ext4    defaults        1 2
UUID=d3e3cc9a-6c24-4d58-9d33-4aeaa2eef5d1 swap                    swap    defaults        0 0
/dev/sdc1	                          /mydata	          ext4	  defaults	  0 0

Before concluding this article, Let us create an Extended and Logical partition.

As you can see, There is already a Primary Partition in the /dev/sdc hard drive.

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sdc: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf75cb881

Device     Boot Start     End Sectors Size Id Type
/dev/sdc1        2048 2099199 2097152   1G 83 Linux

Now we will create an Extended and Logical partition in this hard drive.

### Create a Extended Partition

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): e
Partition number (2-4, default 2): 
First sector (2099200-6291455, default 2099200): 
Last sector, +sectors or +size{K,M,G,T,P} (2099200-6291455, default 6291455): +1G

Created a new partition 2 of type 'Extended' and of size 1 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[[email protected] ~]# partprobe /dev/sdc   # Update the partition to kernel

### Create a Logical Partition

[[email protected] ~]# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): l

Adding logical partition 5
First sector (2101248-4196351, default 2101248): 
Last sector, +sectors or +size{K,M,G,T,P} (2101248-4196351, default 4196351): +500M

Created a new partition 5 of type 'Linux' and of size 500 MiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[[email protected] ~]# partprobe /dev/sdc   # Update the partition to kernel

### Formatting the Logical Partition

# mkfs.ext4 /dev/sdc5
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 512000 1k blocks and 128016 inodes
Filesystem UUID: e3d43794-9339-45e5-9a1b-8d3140c3dc82
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done 

### Print the Partition Table

# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sdc: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf75cb881

Device     Boot   Start     End Sectors  Size Id Type
/dev/sdc1          2048 2099199 2097152    1G 83 Linux
/dev/sdc2       2099200 4196351 2097152    1G  5 Extended
/dev/sdc5       2101248 3125247 1024000  500M 83 Linux

Now you can store data by mounting this Logical partition.

# mount /dev/sdc5 /mydata/

You can visit at following websites to get more information on fdisk command.

Conclusion

I hope that now you have a good understanding of How to create a Disk Partitions in Linux and you have some ideas for how you can use fdisk command within your workflow.

If anyone does have any questions about what we covered in this guide then feel free to ask in the comment section below and I will do my best to answer those.

Leave a Comment