Extend EBS Volume (Hard Drive Size) in AWS.

Posted By: Matpal Media - 7:08 PM
1. First of all create snapshot of the existing volume. In case of anything, you can rollback the changes.


2. Then extend the size of the volume by modify volume. For example if your default volume size is 10GB, you upgrade this to 60GB. However, this is just the disc size upgrade. Your OS file system still doesn't know that you have added extra space.

3. SSH Your linux console. And check what is your file system of Linux OS.

Execute the command 

file -s /dev/xvd*

# file -s /dev/xvd*

/dev/xvda:  x86 boot sector; partition 1: ID=0xee, active, starthead 0, 
startsector 1, 20971519 sectors, code offset 0x63 /dev/xvda1: data /dev/xvda2: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)


This shows our OS has XFS file system ( Like Redhat or Centos).

4. Check your Linux partition. That will tell you how much disc space you have.

Execute the command 

lsblk

# lsblk

NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

xvda    202:0    0  60G  0 disk

|-xvda1 202:1    0   1M  0 part

`-xvda2 202:2    0  10G  0 part /


5.  Use the df -h command to report the existing disk space usage on the file system. This shows that only 10GB is used by OS.

Execute the command 

df -h


# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/xvda2       10G  9.1G  958M  91% /

devtmpfs        467M     0  467M   0% /dev

tmpfs           496M     0  496M   0% /dev/shm

tmpfs           496M   57M  440M  12% /run

tmpfs           496M     0  496M   0% /sys/fs/cgroup

tmpfs           100M     0  100M   0% /run/user/1002


6. Grow the Filesystem for OS.

Execute the command

growpart /dev/xvda 2


# growpart /dev/xvda 2

CHANGED: disk=/dev/xvda partition=2: start=4096 old: size=20967390,end=20971486 
new: size=125824990,end=125829086


7.Use a file system-specific command to resize each file system to the new volume capacity.(This is for Redhat).

Execute the command*

xfs_growfs -d /mnt 

#You might have to install xfsprogs 

yum install xfsprogs



 

# xfs_growfs -d /mnt

meta-data=/dev/xvda2             isize=512    agcount=7, agsize=393216 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0 spinodes=0

data     =                       bsize=4096   blocks=2620923, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal               bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

data blocks changed from 2620923 to 15728123

8. Now verify your filesystem.


# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/xvda2       60G  9.1G   51G  16% /

devtmpfs        467M     0  467M   0% /dev

tmpfs           496M     0  496M   0% /dev/shm

tmpfs           496M   57M  440M  12% /run

tmpfs           496M     0  496M   0% /sys/fs/cgroup

tmpfs           100M     0  100M   0% /run/user/1002

You can refer the details from here -
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.