Home aws, linux how to resizing your linux aws vps
awslinux

how to resizing your linux aws vps

This is tutorial to resizing your linux drive on aws virtual private server

Please reconsider that, I will not responsible if something wrong happens to your server

  • First, got to aws console, pick Elastic Block Store > Volume
  • Pick the Volume that you want to resizing
  • Action > Modify Volume, change your Volume Size (sizing it to your needs only)
  • Goto to ssh
  • Check your drive using this Command
sudo file -s /dev/xvd*
  • it will shows your linux ext4 file system data, for me it is /dev/xvda1
  • check your size using lsblk
  • there will be xvda 9G (for example), and xvda1 (8gb)
  • 9G mean the new size, 8G mean the old size
  • Change your partition using growpart command
sudo growpart /dev/xvda 1
  • it will shows info like this

CHANGED: partition=1 start=2048 old: size=16775135 end=16777183 new: size=18872287,end=18874335

  • check again your block using “lsblk”
  • then resize the partition using resize2fs command
sudo resize2fs /dev/xvda1

finally check your partition using df -h command

ubuntu@ip-XXX-xx-xx-xxx:~$ sudo file -s /dev/xvd*
/dev/xvda: DOS/MBR boot sector
/dev/xvda1: Linux rev 1.0 ext4 filesystem data, UUID=651cda91-e465-4685-b697-67aa07181279, volume name "cloudimg-rootfs" (needs journal recovery) (extents) (64bit) (large files) (huge files)

ubuntu@ip-XXX-xx-xx-xxx:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 18M 1 loop /snap/amazon-ssm-agent/1480
loop1 7:1 0 89.1M 1 loop /snap/core/8268
loop2 7:2 0 89M 1 loop /snap/core/7713
xvda 202:0 0 9G 0 disk
└─xvda1 202:1 0 8G 0 part /

ubuntu@ip-XXX-xx-xx-xxx:~$ sudo growpart /dev/xvda 1
CHANGED: partition=1 start=2048 old: size=16775135 end=16777183 new: size=18872287,end=18874335

ubuntu@ip-XXX-xx-xx-xxx:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 18M 1 loop /snap/amazon-ssm-agent/1480
loop1 7:1 0 89.1M 1 loop /snap/core/8268
loop2 7:2 0 89M 1 loop /snap/core/7713
xvda 202:0 0 9G 0 disk
└─xvda1 202:1 0 9G 0 part /

ubuntu@ip-XXX-xx-xx-xxx:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 480M 0 480M 0% /dev
tmpfs 99M 756K 98M 1% /run
/dev/xvda1 7.7G 2.7G 5.0G 35% /
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 18M 18M 0 100% /snap/amazon-ssm-agent/1480
/dev/loop1 90M 90M 0 100% /snap/core/8268
/dev/loop2 90M 90M 0 100% /snap/core/7713
tmpfs 99M 0 99M 0% /run/user/1000

ubuntu@ip-XXX-xx-xx-xxx:~$ sudo resize2fs /dev/xvda1
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/xvda1 is now 2359035 (4k) blocks long.

ubuntu@ip-XXX-xx-xx-xxx:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 480M 0 480M 0% /dev
tmpfs 99M 756K 98M 1% /run
/dev/xvda1 8.7G 2.7G 6.0G 31% /
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 18M 18M 0 100% /snap/amazon-ssm-agent/1480
/dev/loop1 90M 90M 0 100% /snap/core/8268
/dev/loop2 90M 90M 0 100% /snap/core/7713
tmpfs 99M 0 99M 0% /run/user/1000

Author

Ronny

Leave a Reply