Add a New Disk Larger Than 2TB to An Existing Linux

I am using fdisk and parted utilities to do this configuration.

First list the current partition details using fdisk command as shown.

# fdisk -l
List Linux Partition Table
List Linux Partition Table

For the purpose of this article, I am attaching a hard disk of 20GB capacity, which can be followed for disk larger than 2TB as well. Once you added a disk, verify the partition table using same fdisk command as shown.

# fdisk -l
List New Partition Table
List New Partition Table

Tip: If you are adding a physical hard disk, you may find that partitions already created. In such cases, you can use fdsik to delete the same before using parted.

# fdisk /dev/xvdd

Use d switch for the command to delete the partition and w to write the changes and quit.

Delete Linux Partition
Delete Linux Partition

Important: You need to be careful while deleting the partition. This will erase the data on the disk.

Now its time to partition a new hard disk using parted command.

# parted /dev/xvdd print free
Model: VMware, VMware Virtual S (scsi)
Disk /dev/xvdd: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 5001MB 5000MB primary ext2
5001MB 9233MB 4232MB Free Space
2 9233MB 12.9GB 3652MB primary
# parted /dev/xvdd

Set the partition table format to GPT

(parted) mklabel gpt

Create the Primary partition and assign the disk capacity, here I am using 20GB (in your case it would be 2TB).

(parted) mkpart primary 0GB 20GB
Create Partition using Parted
Create Partition using Parted

Just for curiosity, let’s see how this new partition is listed in fdisk.

# fdisk /dev/xvdd
Verify Partition DetailsVerify Partition Details

Now format and then mount the partition and add the same in /etc/fstab which controls the file systems to be mounted when the system boots.

# mkfs.ext4 /dev/xvdd1
Format Linux Partition
Format Linux Partition

Once partition has been formatted, now it’s time mount the partition under /data1.

# mount /dev/xvdd1 /data1

For permanent mounting add the entry in /etc/fstab file.

/dev/xvdd1     /data1      ext4      defaults  0   0

Important: Kernel should support GPT in order to partition using GPT format. By default RHEL/CentOS have Kernel with GPT support, but for Debian/Ubuntu you need to recompile the kernel after changing the config.


Leave a Reply

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