≡ Menu

How to Create Partition on Linux for >2TB Size using Parted GPT

Question: I have a disk that is greater than 2TB size. I cannot create a partition on this >2TB disk using fdisk. Can you explain me with an example on how to create a partition on a disk that is larger than 2TB using parted and GPT format?

Answer: If you are using fdisk to create partition on a >2TB disk, you’ll get the following warning message.

# fdisk /dev/sdb
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: The size of this disk is 5.9 TB (5908688535552 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).

Creating 2TB partition using Fdisk

The size of the disk in this example is roughly 6 TB. You can still create a partition in this disk for 2TB using fdisk as shown below.

# fdisk /dev/sdb1
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-718357, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349):
Using default value 267349

As you see above, even though there are 718357 cylinders available on this disk (this is for total of roughly 6TB), the last cylinder value it shows is only 267349 (which is roughly close to 2TB in this example).

So, fdisk has created a partition of 2 TB as shown below (even though the disk size is around 6 TB).

Command (m for help): p

Disk /dev/sdb: 5908.7 GB, 5908688535552 bytes
255 heads, 63 sectors/track, 718357 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3dffd626

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      267349  2147480811   83  Linux

Set Partition Table to GPT using Parted mklabel

In our case, we need to create a partition >2TB. So, we should use parted command.

Before creating the partition command, we should set the disk label to GPT.

GPT stands for GUID partition table format (GPT).

Use parted’s mklabel command to set disk label to GPT as shown below.

# parted /dev/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) print
Error: /dev/sdb: unrecognised disk label

(parted) mklabel gpt

(parted) print
Model: Unknown (unknown)
Disk /dev/sdb: 5909GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

Create >2TB Partition using Parted mkpart

Use parted’s mkpart command as shown below to create partition that is greater than 2TB. In this example, we are creating a partition that is roughly of 6TB in size.

# parted /dev/sdb

(parted) mkpart primary 0GB 5909GB

(parted) print
Model: Unknown (unknown)
Disk /dev/sdb: 5909GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  5909GB  5909GB               primary

To understand how to use parted command effectively, refer to: 9 Linux Parted Command Examples.

Just for curiosity, let us see how this >2TB partition is displayed in fdisk. As you see below, it still shows the size as roughly 2TB (under the Blocks columns). However there is a + at the end indicating that this is greater than 2TB. The System column displays “GPT”.

# fdisk /dev/sdb

Command (m for help): print

Disk /dev/sdb: 5908.7 GB, 5908688535552 bytes
255 heads, 63 sectors/track, 718357 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      267350  2147483647+  ee  GPT

Format and Mount the Partition

Use mkfs to format the partition. This will take some time depending the size of the partition. You’ll see that it is “Writing inode tables” and the counter will keep increasing. In this example, it roughly took around 15 minutes to complete the mkfs.

# mkfs /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
360644608 inodes, 1442550528 blocks
72127526 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
44024 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848, 512000000, 550731776, 644972544

Writing inode tables:  3955/44024
Writing inode tables:  5022/44024
Writing inode tables:  7218/44024
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Finally, mount this >2TB partition.

# mkdir /data

# mount /dev/sdb1 /data

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             127G  1.6G  119G   2% /
/dev/sdb1             5.3T   59M  5.1T   1% /data
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • israel Katz August 1, 2012, 9:11 am

    I want to install Lamp on my computer. Intel i7 running on MINT 12.04 (Ubuntu 12.04).
    Something is going wrong with the elements compability. Maybe I did installed and uninstalled those elements to many times. Do I have to reformat my disk? And start everything from scatch?

  • Ethan August 1, 2012, 10:02 am

    It is usefull a reminder. clearly expressed.

  • Frank Han August 1, 2012, 10:56 am

    I think it should be GPT instead of GTP.

  • Jalal Hajigholamali August 1, 2012, 11:08 am

    Hi,

    Thanks a lot, very useful article..
    thanks again

  • Matti Pentti August 1, 2012, 11:48 am

    Hi, remember to align partitions according to the block-sizes of the underlaying (or should I say, the upper level) blocksystem’s: ie. common filesystem block-size (512 bytes), HW RAID vdisk block-size (ie. 64kb) and possibly the popular optimal blocksizes of SSDs (4kb). If partitions are misaligned to the hardware/other blocksystems, there will be unnessessary IO operations as the requested block may span over to the neighbouring block, needing to read the adjacent block too.

    To use the sectors as units instead of blocks:
    fdisk -u s /dev/sda
    then start the first partition from sector 1024, 2048 (1 MB with 512 bytes / sec ) or 4096 etc.

    parted has an align-check command :
    (parted) align-check minimal 1
    1 aligned

    and with EXT4 check the man-page for stripe-width parameter.

    When you draw a picture or visualize the blocksystem’s on top of each other, the picture says more than thousand words.

    Can you write an article about partition alignment too, thanks!

  • Ramesh Natarajan August 2, 2012, 12:53 am

    @Frank,

    Thanks for pointing out the typo. It is fixed now.

  • kanth August 2, 2012, 3:16 am

    Very nice article..

  • Sum Yung Gai August 3, 2012, 10:22 am

    Another way to accomplish the same ultimate effect is to use LVM. To do this, go ahead and make three 2TB partitions with fdisk, and set their types to physical volume. Then, do your pvcreate on all three partitions, stick all of them in a volume group with vgcreate, and then make your logical volume with lvcreate.

    Finally, mkfs on this logical volume, and have fun. 🙂

  • Benedict Verhegghe August 3, 2012, 1:06 pm

    Or you can just add the whole disk as a physical volume to an LVM volume group. And then just create logical volumes. These are very easy to resize (even while the file system is mounted).

  • kanth August 29, 2012, 11:04 pm

    Hi Ramesh Natarajan,

    I Have external hard disk 4 tb with full with some data, i want to mount that hard disk in linux system i run this command ‘parted /dev/sdc print ‘ it doesn’t show any thing .please give some advice how to mount that disk

    # fdisk -l
    Disk /dev/sdc: 4000.7 GB, 4000786149376 bytes
    256 heads, 63 sectors/track, 60562 cylinders
    Units = cylinders of 16128 * 4096 = 66060288 bytes

    Device Boot Start End Blocks Id System
    /dev/sdc1 1 266306 4294967292 ee EFI GPT

    # parted /dev/sdc print
    Warning: Device /dev/sdc has a logical sector size of 4096. Not all parts of
    GNU Parted support this at the moment, and the working code is HIGHLY
    EXPERIMENTAL.

    Error: Unable to open /dev/sdc – unrecognised disk label.
    Information: Don’t forget to update /etc/fstab, if necessary.

  • Faisal Qutab September 4, 2012, 2:53 am

    Thanks … very useful info

  • ru November 26, 2012, 6:57 am

    what you refer to as “format” is filesystem creation. formatting is something else, but often confused with filesystem creation.

  • pdi March 14, 2013, 6:30 pm

    Thanks !
    This was really helpful and clearly explaned.

    I love you linux guys (I really do), it is wonderful to see everybody helping each others. That does not happen in windoze world.

  • Azad October 21, 2013, 7:11 am

    Good Stuff.. Useful article

  • Trond November 21, 2013, 3:20 am

    Thanks a bunch for this! Great site.

  • Ep April 3, 2014, 7:14 pm

    Thanks for the info in a concise, clear and logical presentation.

  • Tosh October 21, 2014, 8:58 am

    Thanks for posting this article. It helped me a lot!!

  • Miksa February 2, 2015, 5:57 pm

    A minor correction. As I understand it, GPT disks don’t have partition types anymore, they are all “primary”. Command ‘mkpart primary’ doesn’t create a primary partition like it does on msdos disks, it just creates a partition called primary. You can just as well use command

    (parted) mkpart Parted-FUN! 21476MB 4000787MB
    (parted) print
    Model: ATA ST4000DM000-1F21 (scsi)
    Disk /dev/sdf: 4000787MB
    Sector size (logical/physical): 512B/4096B
    Partition Table: gpt

    Number Start End Size File system Name Flags
    1 1.05MB 17181MB 17180MB ext4 raid-var
    2 17181MB 21476MB 4295MB raid-swap
    3 21476MB 4000786MB 3979310MB Parted-FUN!

    This may cause confusion if you try creating logical partitions, I know it did for me.

    (parted) mkpart extended 21476MB 4000787MB
    (parted) mkpart logical 21476MB 1000787MB
    Warning: You requested a partition from 21476MB to 1000787MB.
    The closest location we can manage is 4000786MB to 4000786MB.
    Is this still acceptable to you?
    Yes/No? Yes
    (parted) print
    Model: ATA ST4000DM000-1F21 (scsi)
    Disk /dev/sdf: 4000787MB
    Sector size (logical/physical): 512B/4096B
    Partition Table: gpt

    Number Start End Size File system Name Flags
    1 1.05MB 17181MB 17180MB ext4 raid-var
    2 17181MB 21476MB 4295MB raid-swap
    3 21476MB 4000786MB 3979310MB extended
    4 4000786MB 4000786MB 0.00MB logical

    You can’t create a partition called “logical” inside a partition called “extended”.

  • Shahil April 22, 2015, 7:16 am

    I want to format a disk using parted and make the LVM can you please help

  • Olie June 26, 2015, 7:22 pm

    I’ve successfully mkpart, but why when mkfs got this error ?
    # mkfs /dev/sdb1
    mke2fs 1.39 (29-May-2006)
    /dev/sdb1 is apparently in use by the system; will not make a filesystem here!

    What is the pre-requisite before using parted / GPT command ?