Formatting Disks over 2 TiB with parted

Posted on Monday, February 25, 2019

I just added a big hard drive to my ESXi box and I created a virtual drive of about 3.5 TiB for a virtualized machine.   But I had a problem…

When I went to format it… using my typical method of using fdisk to create a partition I noticed a problem…

If I try to create the partion

 > fdisk /dev/vdb

I get the following warning

 Device does not contain a recognized partition table.
The size of this disk is 3.1 TiB (3435973836800 bytes). DOS partition table format can not be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).

If I ignore the warning and partition and format the drive…

 > fdisk /dev/vdb

I only get 2 TiB drive…  I was warned J

So how do I fix this… How do I do it right?
I use gparted!

Formatting it right

So here is how to do it J

Switch to root

 > sudo su -

Start parted

 > parted

Run the following commands from with gparted (replace XXX with your drive)

 > select /dev/sdXXXX

 > mklabel gpt

 > print free

 > mkpart pimary

Then set
    Start?  0
     End?  3.2 TB


Warning: The resulting partition is not properly aligned for best performance.

Let me cancel and run print free again

 > print free

Let me try those numbers

 > mkpart pimary

Then set
File system type?  [ext2]? ext4
Start? 17.4kB
End? 3436GB

Close enough J  Enter Yes


 > unit s
 > print free
 > mkpart pimary ext4 0% 100%
 > print

OK now it’s happy

Exit parted

 > quit

 > ls -alh /dev/sd*

There it is..

Format it

Replace XXX with your drive name

 > mkfs.ext4 /dev/sdXXXX1

Now let me do a quick edit of /etc/fstab and mount it.

 > vi /etc/fstab

And I put the following in it

/dev/sdb1  /test         ext4  rw,suid,dev,exec,noauto,nouser,async  0  0

 > blkid -o list

 > fdisk -l /dev/sdb1

Check it

Let me make a /test folder and mount it.

  > mkdir /test
  > mount /test
  > df -h

Bam!! Wahoo!


[1]        How To Create a Partition Using “parted” Command
                Accessed 02/2019
[2]        Ubuntu, formatting a 3TB drive
                Accessed 02/2019
[2]        GNU Parted: Solving the dreaded "The resulting partition is not properly aligned for best performance"

No comments:

Post a Comment