Skip to content

Instantly share code, notes, and snippets.

@btutal
Last active March 25, 2020 08:41
Show Gist options
  • Save btutal/4d5e47346fc24f688e84d9e7aab17d71 to your computer and use it in GitHub Desktop.
Save btutal/4d5e47346fc24f688e84d9e7aab17d71 to your computer and use it in GitHub Desktop.

Revisions

  1. btutal revised this gist Mar 25, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions extend_ebs_volume_on_ubuntu.md
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,7 @@ xvda 202:0 0 100G 0 disk
    └─xvda1 202:1 0 16G 0 part /
    ```
    As you can see size of the root volume reflects the new size, 100GB, the size of the partition reflects the original size, 16 GB, and must be extended before you can extend the file system.

    4. Use command below to extend the partition
    ```
    sudo growpart /dev/xvda 1
  2. btutal revised this gist Mar 25, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion extend_ebs_volume_on_ubuntu.md
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,8 @@ loop2 7:2 0 18M 1 loop /snap/amazon-ssm-agent/1480
    xvda 202:0 0 100G 0 disk
    └─xvda1 202:1 0 16G 0 part /
    ```
    4.As you can see size of the root volume reflects the new size, 100GB, the size of the partition reflects the original size, 16 GB, and must be extended before you can extend the file system.
    As you can see size of the root volume reflects the new size, 100GB, the size of the partition reflects the original size, 16 GB, and must be extended before you can extend the file system.
    4. Use command below to extend the partition
    ```
    sudo growpart /dev/xvda 1
    ```
  3. btutal created this gist Mar 25, 2020.
    54 changes: 54 additions & 0 deletions extend_ebs_volume_on_ubuntu.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    ## Modify Volume on AWS Console
    1. Login to your AWS console
    2. Choose “EC2” from the services list
    3. Click on “Volumes” under ELASTIC BLOCK STORE menu (on the left)
    4. Choose the volume that you want to resize, right click on “Modify Volume
    5. Set the new size for your EBS volume (in this case i extended an 8GB volume to 20GB)
    6. Click on modify.

    Now volume needs to be extend on EC2 instance

    ## Extend the volume on Instance

    1. SSH to the EC2 instance
    2. Type ```lsblk``` to list our block devices
    3. You should be able to see a similar output
    ```
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    loop0 7:0 0 89.1M 1 loop /snap/core/8213
    loop1 7:1 0 89.1M 1 loop /snap/core/8268
    loop2 7:2 0 18M 1 loop /snap/amazon-ssm-agent/1480
    xvda 202:0 0 100G 0 disk
    └─xvda1 202:1 0 16G 0 part /
    ```
    4.As you can see size of the root volume reflects the new size, 100GB, the size of the partition reflects the original size, 16 GB, and must be extended before you can extend the file system.
    ```
    sudo growpart /dev/xvda 1
    ```
    5. Now we can check that the partition reflects the increased volume size (we can check it with the lsblk command we already used):
    ```
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    loop0 7:0 0 89.1M 1 loop /snap/core/8213
    loop1 7:1 0 89.1M 1 loop /snap/core/8268
    loop2 7:2 0 18M 1 loop /snap/amazon-ssm-agent/1480
    xvda 202:0 0 100G 0 disk
    └─xvda1 202:1 0 100G 0 part /
    ```
    6. We need to extend the filesystem itself. If your filesystem is an ext2, ext3, or ext4, type:
    ```
    sudo resize2fs /dev/xvda1
    ```
    7. Finally we can check our extended filesystem by typing:
    ```
    Filesystem Size Used Avail Use% Mounted on
    udev 480M 0 480M 0% /dev
    tmpfs 99M 716K 98M 1% /run
    /dev/xvda1 97G 11G 87G 11% /
    tmpfs 492M 0 492M 0% /dev/shm
    tmpfs 5.0M 0 5.0M 0% /run/lock
    tmpfs 492M 0 492M 0% /sys/fs/cgroup
    /dev/loop0 90M 90M 0 100% /snap/core/8213
    /dev/loop1 90M 90M 0 100% /snap/core/8268
    /dev/loop2 18M 18M 0 100% /snap/amazon-ssm-agent/1480
    tmpfs 99M 0 99M 0% /run/user/1000
    ```