Storage

How to create a partition size larger than 2 TB on linux

disk larger than 2tbHard disks larger than 2 TB are now common. However, fdisk cannot manage partitions on disks larger than 2 TB because it supports only the now-outdated MBR partitioning format. We need a tool supporting the Globally Unique Identifier (GUID) Partition Table (GPT), which supports disks larger than 2 TB. Many partitioning tools now support GPT. One I recommend trying is gdisk. It works much like fdisk, but can partition disks larger than 2 TB and create up to 128 partitions. Install and use gdisk

  1. Install the EPEL repository first. Find the download URL at RPM repository of RPM add-on packages for Red Hat Enterprise Linux and CentOS.

  2. Install gdisk with: [[email protected] ~]# yum install gdisk

  3. Run gdisk to partition the disk. The example below uses sdb.

    [[email protected] ~]# gdisk  /dev/sdb
    GPT fdisk (gdisk) version 0.8.4
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
  4. Press o to create a GUID partition table.

    Command (? for help): ?
    b       back up GPT data to a file
    c       change a partition's name
    d       delete a partition
    i       show detailed information on a partition
    l       list known partition types
    n       add a new partition
    o       create a new empty GUID partition table (GPT)
    p       print the partition table
    q       quit without saving changes
    r       recovery and transformation options (experts only)
    s       sort partitions
    t       change a partition's type code
    v       verify disk
    w       write table to disk and exit
    x       extra functionality (experts only)
    ?       print this menu
    
    Command (? for help): o
    This option deletes all partitions and creates a new protective MBR.
    Proceed? (Y/N): y
  5. Press n to create a partition, followed by 1, then Enter twice to use all space. Press Enter if using Linux; for other uses, press L to view partition types. This example creates only one partition:

    Command (? for help): n
    Partition number (1-128, default 1): 1
    First sector (34-19393401950, default = 2048) or {+-}size{KMGTP}:
    Last sector (2048-19393401950, default = 19393401950) or {+-}size{KMGTP}:
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): L
    0700 Microsoft basic data  0c01 Microsoft reserved    2700 Windows RE
    4200 Windows LDM data      4201 Windows LDM metadata  7501 IBM GPFS
    7f00 ChromeOS kernel       7f01 ChromeOS root         7f02 ChromeOS reserved
    8200 Linux swap            8300 Linux filesystem      8301 Linux reserved
    8e00 Linux LVM             a500 FreeBSD disklabel     a501 FreeBSD boot
    a502 FreeBSD swap          a503 FreeBSD UFS           a504 FreeBSD ZFS
    a505 FreeBSD Vinum/RAID    a800 Apple UFS             a901 NetBSD swap
    a902 NetBSD FFS            a903 NetBSD LFS            a904 NetBSD concatenated
    a905 NetBSD encrypted      a906 NetBSD RAID           ab00 Apple boot
    af00 Apple HFS/HFS+        af01 Apple RAID            af02 Apple RAID offline
    af03 Apple label           af04 AppleTV recovery      af05 Apple Core Storage
    be00 Solaris boot          bf00 Solaris root          bf01 Solaris /usr & Mac Z
    bf02 Solaris swap          bf03 Solaris backup        bf04 Solaris /var
    bf05 Solaris /home         bf06 Solaris alternate se  bf07 Solaris Reserved 1
    bf08 Solaris Reserved 2    bf09 Solaris Reserved 3    bf0a Solaris Reserved 4
    bf0b Solaris Reserved 5    c001 HP-UX data            c002 HP-UX service
    ef00 EFI System            ef01 MBR partition scheme  ef02 BIOS boot partition
    fd00 Linux RAID
    Hex code or GUID (L to show codes, Enter = 8300): 8300
    Changed type of partition to 'Linux filesystem'
  6. Press p to inspect the partition you created.

    Command (? for help): p
    Disk /dev/sdb: 19393401984 sectors, 9.0 TiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): E7327A36-2410-419C-96F1-4874EE7CAEED
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 19393401950
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 2014 sectors (1007.0 KiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1            2048     19393401950   9.0 TiB     8300  Linux filesystem
  7. Press w to save.

    Command (? for help): w
    
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
    PARTITIONS!!
    
    Do you want to proceed? (Y/N): y
    OK; writing new GUID partition table (GPT) to /dev/emcpowera.
    The operation has completed successfully.
  8. Check the partition table again with:

    [[email protected] ~]# gdisk -l /dev/sdb
    GPT fdisk (gdisk) version 0.8.4
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
    Disk /dev/sdb: 19393401984 sectors, 9.0 TiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): E7327A36-2410-419C-96F1-4874EE7CAEED
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 19393401950
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 2014 sectors (1007.0 KiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1            2048     19393401950   9.0 TiB     8300  Linux filesystem

    You can see that one partition has been added. You can now format it with the filesystem you want.

EOF.← Back to articles