How to expand the size of the disk ubuntu on amazon web services E2C


After the login on the ubuntu, set the rights for the root user:

> Sudo -s

extend the harddisk hdd linux ubuntu:

command for status hdd

Command:

> lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

Output:

NAME FSTYPE SIZE MOUNTPOINT LABEL

xvda 8G

└─xvda1 ext4 8G / cloudimg-rootfs

Coommand :

> fdisk -l

Output:

Disk /dev/xvda: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Device Boot Start End Blocks Id System

/dev/xvda1 * 16065 16771859 8377897+ 83 Linux

> Create a snap shot in aws

Check the link here:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html

See the status of the linux device:

root@ip-10-0-0-4:~# file -s /dev/xvda1*

/dev/xvda1: Linux rev 1.0 ext4 filesystem data, UUID=d4f2aafc-946a-4514-930d-4c45e676f198, volume name “cloudimg-rootfs” (needs journal recovery) (extents) (large files) (huge files)

Then see all the partitions again:

root@ip-10-0-0-4:~# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

xvda 202:0 0 8G 0 disk

└─xvda1 202:1 0 8G 0 part /

In order to see the usage percentage of the disk run the following command:

root@ip-10-0-0-4:~# df

Filesystem 1K-blocks Used Available Use% Mounted on

udev 502980 12 502968 1% /dev

tmpfs 101632 356 101276 1% /run

/dev/xvda1 8115168 6167760 1512132 81% /

none 4 0 4 0% /sys/fs/cgroup

none 5120 0 5120 0% /run/lock

none 508152 0 508152 0% /run/shm

none 102400 0 102400 0% /run/user

Then change the size of the disk

Then you can see the changed size:

Then in the command prompt you have to see the new size

Then you have to increase the size of the current partition

 


About Ionut Afloarei

Senior .Net Developer with 14+ years of experience in Microsoft Technologies (ASP.net/C#, MVC, MSSQL, Entity Framework, Visual Studio, TFS, IIS, Azure Cloud, Microsfot Dynamics).