Atlantic.Net Blog

How to : CentOS 7 – Creating Larger than 2TB Partition with PARTED

Verified and Tested 04/04/21

Introduction

This article will explain how to add two 3TB hard drives to an existing CentOS 7 system using PARTED and place them into a RAID1 software raid mirror.

PARTED, like fdisk, is a utility used to manipulate hard disk partitions. One advantage it has over fdisk is that it can handle provisioning disks whose volumes will span larger than ~1.9 TB in size.

Creating 2TB or Larger Partition with PARTED

We have to partition the drives using PARTED; regular fdisk can’t do it (it doesn’t know how to handle anything over 1.9 TB) and mark the drives as GPT. We then use MDADM to create the software raid mirror.

For the example, the two new 3TB drives will be /dev/sdb and /dev/sdc

Partition disks using PARTED

parted -a optimal /dev/sdb

This will load you into the Parted CLI on /dev/sdb. Run the following commands to make the disk GPT:

mklabel gpt

You should get a warning that says:

Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost.Do you want to continue? Yes/No?

Type Y and then run the following command to make your /dev/sdb disk set to ext4 and a primary disk starting at 0% and fill to 100%:

mkpart primary ext4 0% 100%

To see the partition that you made information, use the following command:

print

Depending on your setup, you will get something similar to the following:

Model: Msft Virtual Disk (scsi) Disk /dev/sdb: 3TB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 3TB 3TB primary raid

To flag your partition as Raid, run the following command:

set 1 raid on

Perform the same procedure above for /dev/sdc.

Tell mdadm to create a RAID device called /dev/md0 by running the following command:

mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm: Note: this array has metadata at the start and may not be suitable as a boot device. If you plan to store '/boot' on this device please ensure that your boot-loader understands md/v1.x metadata, or use --metadata=0.90 Continue creating array?

Read the warning and hit Y and you should get an output like the following:

mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started.

Wait for the system to complete the sync process. Once completed, create a new directory and mount your new MD device.

To view your current partition set up run the following command:

cat /proc/mdstat

You should get an output like the following:

Personalities : [raid1] 
md0 : active raid1 sdc1[1] sdb1[0] 
10475392 blocks super 1.2 [2/2] [UU]

Create a new raid 1 directory by running:

mkdir /raid1

Then mount your Raid to your new raid 1 directory

mount /dev/md0 /raid1/

Next, we need to update fstab and mdadm.conf

With your favorite editor, open /etc/fstab and add the following to the last line of fstab file.

/dev/md0 /raid1 ext4 defaults 0 0

It should look similar to the following once done

#
# /etc/fstab
# Created by anaconda on Fri Jun 20 09:39:24 2014
#
# 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
#
UUID=bfc860b0-9d1c-41e9-984f-83166f20dc03 /                       ext4    defaults        1 1
UUID=e136ebe6-f2b8-4098-bd16-11a1fa6044e2 /boot                   ext4    defaults        1 2
UUID=911f21eb-7500-41cd-9c0d-e2d4ab822b55 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/md0      /raid1     ext4    defaults     0 0

Update madam with the following command:

 mdadm --detail --scan > /etc/mdadm.conf

Congratulations! You’ve created a new RAID1 device using MDADM with GPT partitioning.

Thank you for following along with this how-to! Please check back here for more updates and to learn more about our VPS hosting solutions.

See our VPS hosting price.

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year