Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jsamuel1/0fccea56fd96c07000ad9de784ab1ab3 to your computer and use it in GitHub Desktop.

Select an option

Save jsamuel1/0fccea56fd96c07000ad9de784ab1ab3 to your computer and use it in GitHub Desktop.

Revisions

  1. jsamuel1 revised this gist Dec 24, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion resize.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash

    # Specify the desired volume size in GiB as a command line argument. If not specified, default to 20 GiB.
    SIZE=${1:-20}
    SIZE=${1:-60}

    # Get the ID of the environment host Amazon EC2 instance.
    INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
  2. @wongcyrus wongcyrus revised this gist May 9, 2022. No changes.
  3. @wongcyrus wongcyrus renamed this gist May 9, 2022. 1 changed file with 1 addition and 1 deletion.
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    curl -s https://gist.github.com/wongcyrus/a4e726b961260395efa7811cab0b4516/raw/6a045f51acb2338bb2149024a28621db2abfcaab/resize.sh | bash 60
    curl -s https://gist.github.com/wongcyrus/a4e726b961260395efa7811cab0b4516/raw/6a045f51acb2338bb2149024a28621db2abfcaab/resize.sh | bash /dev/stdin 60
  4. @wongcyrus wongcyrus revised this gist May 9, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions cloud9 resize command with volume size
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    curl -s https://gist.github.com/wongcyrus/a4e726b961260395efa7811cab0b4516/raw/6a045f51acb2338bb2149024a28621db2abfcaab/resize.sh | bash 60
  5. @wongcyrus wongcyrus revised this gist Mar 14, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion resize.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash

    # Specify the desired volume size in GiB as a command line argument. If not specified, default to 20 GiB.
    SIZE=${1:-40}
    SIZE=${1:-20}

    # Get the ID of the environment host Amazon EC2 instance.
    INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
  6. @wongcyrus wongcyrus revised this gist Jan 25, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion resize.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash

    # Specify the desired volume size in GiB as a command line argument. If not specified, default to 20 GiB.
    SIZE=${1:-20}
    SIZE=${1:-40}

    # Get the ID of the environment host Amazon EC2 instance.
    INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
  7. @wongcyrus wongcyrus revised this gist Nov 9, 2021. No changes.
  8. @wongcyrus wongcyrus revised this gist Sep 3, 2021. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions resize.sh
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,14 @@ SIZE=${1:-20}

    # Get the ID of the environment host Amazon EC2 instance.
    INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
    REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1/')

    # Get the ID of the Amazon EBS volume associated with the instance.
    VOLUMEID=$(aws ec2 describe-instances \
    --instance-id $INSTANCEID \
    --query "Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId" \
    --output text)
    --output text \
    --region $REGION)

    # Resize the EBS volume.
    aws ec2 modify-volume --volume-id $VOLUMEID --size $SIZE
    @@ -26,13 +28,13 @@ sleep 1
    done

    #Check if we're on an NVMe filesystem
    if [ $(readlink -f /dev/xvda) = "/dev/xvda" ]
    if [[ -e "/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
    # Check if we're on AL2
    STR=$(cat /etc/os-release)
    SUB="VERSION_ID=\"2\""
    if [[ "$STR" == *"$SUB"* ]]
  9. @wongcyrus wongcyrus revised this gist Jun 30, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion resize.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash

    # Specify the desired volume size in GiB as a command-line argument. If not specified, default to 20 GiB.
    # Specify the desired volume size in GiB as a command line argument. If not specified, default to 20 GiB.
    SIZE=${1:-20}

    # Get the ID of the environment host Amazon EC2 instance.
  10. @wongcyrus wongcyrus revised this gist Dec 4, 2020. 1 changed file with 21 additions and 4 deletions.
    25 changes: 21 additions & 4 deletions resize.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    SIZE=${1:-20}

    # Get the ID of the environment host Amazon EC2 instance.
    INSTANCEID=$(curl http://169.254.169.254/latest/meta-data//instance-id)
    INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id)

    # Get the ID of the Amazon EBS volume associated with the instance.
    VOLUMEID=$(aws ec2 describe-instances \
    @@ -25,18 +25,35 @@ while [ \
    sleep 1
    done

    #Check if we're on an NVMe filesystem
    if [ $(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.
    sudo resize2fs /dev/xvda1
    # 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.
    sudo resize2fs /dev/nvme0n1p1
    # 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
  11. @wongcyrus wongcyrus revised this gist May 28, 2020. 1 changed file with 27 additions and 12 deletions.
    39 changes: 27 additions & 12 deletions resize.sh
    Original file line number Diff line number Diff line change
    @@ -3,25 +3,40 @@
    # Specify the desired volume size in GiB as a command-line argument. If not specified, default to 20 GiB.
    SIZE=${1:-20}

    # Install the jq command-line JSON processor.
    sudo yum -y install jq

    # Get the ID of the envrionment host Amazon EC2 instance.
    # Get the ID of the environment host Amazon EC2 instance.
    INSTANCEID=$(curl http://169.254.169.254/latest/meta-data//instance-id)

    # Get the ID of the Amazon EBS volume associated with the instance.
    VOLUMEID=$(aws ec2 describe-instances --instance-id $INSTANCEID | jq -r .Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId)
    VOLUMEID=$(aws ec2 describe-instances \
    --instance-id $INSTANCEID \
    --query "Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId" \
    --output text)

    # Resize the EBS volume.
    aws ec2 modify-volume --volume-id $VOLUMEID --size $SIZE

    # Wait for the resize to finish.
    while [ "$(aws ec2 describe-volumes-modifications --volume-id $VOLUMEID --filters Name=modification-state,Values="optimizing","completed" | jq '.VolumesModifications | length')" != "1" ]; do
    sleep 1
    while [ \
    "$(aws ec2 describe-volumes-modifications \
    --volume-id $VOLUMEID \
    --filters Name=modification-state,Values="optimizing","completed" \
    --query "length(VolumesModifications)"\
    --output text)" != "1" ]; do
    sleep 1
    done

    # 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.
    sudo resize2fs /dev/xvda1
    if [ $(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.
    sudo resize2fs /dev/xvda1

    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.
    sudo resize2fs /dev/nvme0n1p1
    fi
  12. @wongcyrus wongcyrus created this gist Nov 27, 2019.
    27 changes: 27 additions & 0 deletions resize.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/bin/bash

    # Specify the desired volume size in GiB as a command-line argument. If not specified, default to 20 GiB.
    SIZE=${1:-20}

    # Install the jq command-line JSON processor.
    sudo yum -y install jq

    # Get the ID of the envrionment host Amazon EC2 instance.
    INSTANCEID=$(curl http://169.254.169.254/latest/meta-data//instance-id)

    # Get the ID of the Amazon EBS volume associated with the instance.
    VOLUMEID=$(aws ec2 describe-instances --instance-id $INSTANCEID | jq -r .Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId)

    # Resize the EBS volume.
    aws ec2 modify-volume --volume-id $VOLUMEID --size $SIZE

    # Wait for the resize to finish.
    while [ "$(aws ec2 describe-volumes-modifications --volume-id $VOLUMEID --filters Name=modification-state,Values="optimizing","completed" | jq '.VolumesModifications | length')" != "1" ]; do
    sleep 1
    done

    # 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.
    sudo resize2fs /dev/xvda1