1.When you are resizing the machine or detaching a volume ensure the instance is in stopped state otherwise won't able to detach the machine
After detaching the volume create a new brand ec2 machine
After that you add that volume to newly created machine as secondary volume like below.
Mount the secondary volume to the newly lunched machine.
Mount a volume
[ec2-user@ip-172-31-6-175 ~]$ mkdir oldvolume
[ec2-user@ip-172-31-6-175 ~]$ sudo mount -o nouuid /dev/xvdb1 oldvolume/
[ec2-user@ip-172-31-6-175 ~]$ cd oldvolume/
[ec2-user@ip-172-31-6-175 oldvolume]$ pwd
/home/ec2-user/oldvolume
[ec2-user@ip-172-31-6-175 oldvolume]$
Resize machine
Validate the used size before extending the volume
[ec2-user@ip-172-31-8-239 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 475M 0 475M 0% /dev/shm
tmpfs 190M 444K 190M 1% /run
/dev/xvda1 8.0G 1.6G 6.5G 20% /
tmpfs 475M 0 475M 0% /tmp
/dev/xvda128 10M 1.3M 8.7M 13% /boot/efi
tmpfs 95M 0 95M 0% /run/user/1000
Validate the used lsblk before extending the volume
[ec2-user@ip-172-31-8-239 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 10G 0 disk
├─xvda1 202:1 0 8G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part /boot/efi
[ec2-user@ip-172-31-8-239 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 475M 0 475M 0% /dev/shm
tmpfs 190M 444K 190M 1% /run
/dev/xvda1 8.0G 1.6G 6.5G 20% /
tmpfs 475M 0 475M 0% /tmp
/dev/xvda128 10M 1.3M 8.7M 13% /boot/efi
tmpfs 95M 0 95M 0% /run/user/1000
Start the activity
Step-1: growpart /dev/xvda 1
Step-2: sudo xfs_growfs /
/ means root insted you can use the /dev/xvda1 as well
Sample:
[ec2-user@ip-172-31-8-239 ~]$ growpart /dev/xvda 1
sfdisk: cannot open /dev/xvda: Permission denied
failed [sfd_list:1] sfdisk --list --unit=S /dev/xvda
sfdisk: cannot open /dev/xvda: Permission denied
FAILED: failed: sfdisk --list /dev/xvda
[ec2-user@ip-172-31-8-239 ~]$ sudo growpart /dev/xvda 1
CHANGED: partition=1 start=24576 old: size=16752607 end=16777183 new: size=20946911 end=20971487
[ec2-user@ip-172-31-8-239 ~]$ sudo xfs_growfs /
meta-data=/dev/xvda1 isize=512 agcount=2, agsize=1047040 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1
data = bsize=4096 blocks=2094075, imaxpct=25
= sunit=128 swidth=128 blks
naming =version 2 bsize=16384 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=4096 sunit=4 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2094075 to 2618363
[ec2-user@ip-172-31-8-239 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 475M 0 475M 0% /dev/shm
tmpfs 190M 444K 190M 1% /run
/dev/xvda1 10G 1.6G 8.4G 16% / ----> Finally increased volume
tmpfs 475M 0 475M 0% /tmp
/dev/xvda128 10M 1.3M 8.7M 13% /boot/efi
tmpfs 95M 0 95M 0% /run/user/1000
[ec2-user@ip-172-31-8-239 ~]$
0 Comments