Add disk to AWS EC2 Linux instance and format as GPT
In AWS:
My assumption is that you have a running instance and are adding a new disk to the running instance.
- Add a new volume and attach it to the EC2 instance.
On the Linux Box:
- lsblk
- This will tell you your new disk ... note /dev/xvdf below
You can find out how your disk is formatted with the command:
gdisk -l /dev/xvdf
So far, no format ... no MBR and no GPT.
Next, we format the disk as GPT format (my disk was 2TB, adjust accordingly)
- parted /dev/xvdf
- (parted) mklabel gpt
- (parted) unit TB
- (parted) mkpart primary 0.00TB 2.00TB
- (parted) print .... shows you what you're about to save
- (parted) quit .... saves and quits
Now, when you do the lsblk command you'll see /dev/xvdf1 which is a gpt partition:
From here, we make our filesystem (I went with ext4 ... you could just as easily make it xfs):
- mkfs.ext4 /dev/xvdf1
We make the directory we're going to mount to:
- mkdir /data
Now, we need the UUID that goes into /etc/fstab for automount:
Now, we edit /etc/fstab with the above UUID:
UUID=99507991-b65f-4199-8ea6-fa7f1bf7856c /data ext4 defaults,nofail 0 2
Let's mount it:
- mount -a
Finally, let's double check that the disk is really GPT:
And, we see that GPT is "present". Whoo hoo!!