Skip to content

Instantly share code, notes, and snippets.

@drewyangdev
Last active July 8, 2022 19:22
Show Gist options
  • Save drewyangdev/99b991c80a57931e18c85126ef186704 to your computer and use it in GitHub Desktop.
Save drewyangdev/99b991c80a57931e18c85126ef186704 to your computer and use it in GitHub Desktop.
Deal with EC2 GPT volumes that can resize to more than 2TB
#!/bin/bash
## Use lsblk check device, usually e.g "/dev/xvdf", "/dev/nvme1n1"
## Partition will be "/dev/xvdf1", "/dev/nvme1n1p1"
## e.g sudo bash linux_gpt_volume.sh "/dev/nvme1n1" "/dev/nvme1n1p1" "/mnt/gpt-volume"
export DEVICE=$1
export PARTITION=$2
export MOUNT_DIR=$3
parted $DEVICE --script mklabel gpt
parted $DEVICE --script mkpart primary 2048s 100%
mkfs -t ext4 $PARTITION
mkdir -p $MOUNT_DIR
mount $PARTITION $MOUNT_DIR
df -Th
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment