How to extend the volume size on ec2 instance aws

    Posted in Amazon Cloud Services, Linux Servers on Oct 30, 2018

    linux-dedicated-seerver.jpg

    1. Confirm the kernel.

      # uname -r

    2.6.32-431.29.2.el6.x86_64

    1. Confirm the initial allocated size

      # df -h

      Filesystem Size Used Avail Use% Mounted on

      /dev/xvda1 7.9G 797M 6.7G 11% /

      tmpfs 498M 0 498M 0% /dev/shm

      # lsblk

      NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 15G 0 disk └─xvda1 202:1 0 8G 0 part /

    2. Install EPEL6 Repo

      # wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
      # rpm -ivh epel-release-6-8.noarch.rpm
    3. Install the dracut & cloud-utils growpart modules-growroot

      # yum install -y dracut-modules-growroot cloud-utils-growpart
    4. The initrd needs to be rebuilt after installing the dracut-modules-growroot.

      (i) Create a backup copy of the current initramfs:

      # cp -p /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak

      (ii) Create the initramfs for the current kernel:

      # dracut -f
    5. Result after reboot

      # reboot
      # lsblk

      NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 15G 0 disk └─xvda1 202:1 0 15G 0 part /

      # resize2fs /dev/xvda1

      resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/xvda1 is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/xvda1 to 3931652 (4k) blocks. The filesystem on /dev/xvda1 is now 3931652 blocks long.

      # df -h

      Filesystem Size Used Avail Use% Mounted on /dev/xvda1 15G 932M 14G 7% / tmpfs 498M 0 498M 0% /dev/shm