Skip to content

Instantly share code, notes, and snippets.

@hayamiz
Created February 20, 2025 06:23
Show Gist options
  • Save hayamiz/c5683110078d7801d68d07f65595900c to your computer and use it in GitHub Desktop.
Save hayamiz/c5683110078d7801d68d07f65595900c to your computer and use it in GitHub Desktop.
#!/bin/bash
#Check if we're on an NVMe filesystem
if [ -b "/dev/xvda" ] && [ $(readlink -f /dev/xvda) = "/dev/xvda" ]
then
# Rewrite the partition table so that the partition takes up all the space that it can.
sudo growpart /dev/xvda 1
# Expand the size of the file system.
# Check if we are on AL2
STR=$(cat /etc/os-release)
SUB="VERSION_ID=\"2\""
if [[ "$STR" == *"$SUB"* ]]
then
sudo xfs_growfs -d /
else
sudo resize2fs /dev/xvda1
fi
else
# Rewrite the partition table so that the partition takes up all the space that it can.
sudo growpart /dev/nvme0n1 1
# Expand the size of the file system.
# Check if we're on AL2
STR=$(cat /etc/os-release)
SUB="VERSION_ID=\"2\""
if [[ "$STR" == *"$SUB"* ]]
then
sudo xfs_growfs -d /
else
sudo resize2fs /dev/nvme0n1p1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment