Tuesday, July 11, 2017

How do I Extend a Linux partition in AWS EC2


Extending our Linux partition (in AWS EC2) is the resizing of your partition to use the whole disk.

Our running instance size was a Centos with 25GB hard disk space. Now, Amazon has told us that "This instance is scheduled for retirement" and we want to migrate to another instance. We found that we needed a little more space and wanted to extend the linux partition. So, when we created an image, we chose to provide for 50GB in storage.

So, we took a snapshot of the image and launched an instance from the image.

When creating the instance, the size was defined as 50GB. Then, the instance is started. 


The used hard disk space


Before we resized the Linux root partition, of the AWS EC2 instance, we needed to find out the status of the storage now. The df -h command will show us the storage space in the running instance. As seen below, it shows only 25GB.

al@ip-192-230-185-43:~/> df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvde1       25G   17G  7.3G  71% /
none            1.8G     0  1.8G   0% /dev/shm


The available and non-allocated space


We need to utilize the non-allocated space in our Centos Linux system. To find out if there is really 50GB of space in the storage, we issue the lsblk command

al@ip-192-230-185-43:~/> lsblk
NAME  MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvde1 202:65   0  50G  0 disk /


Extend the hard disk space


Great! The next step would be to resize the Linux partition (of the AWS EC2 instance) so that it uses the non-allocated space. Issue the resize2fs command which extends the drive to occupy the whole available hard disk.

al@ip-192-230-185-43:~/> resize2fs /dev/xvde1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/xvde1 is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 4
Performing an on-line resize of /dev/xvde1 to 13107200 (4k) blocks.
The filesystem on /dev/xvde1 is now 13107200 blocks long.


Find out if resizing (resize2fs) worked


The command df -h is issued again to see if the "Size" has changed. We found out that it had changed from the 25GB before to 50GB, which was the extended size.

al@ip-192-230-185-43:~/> df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvde1       50G   17G   32G  35% /
none            1.8G     0  1.8G   0% /dev/shm

The root partition was thus extended to utilize all the non-allocated space in the Linux disk, of your AWS EC2 instance.

Locking Unlocking Aadhar Biometrics, Lock Unlock

Recently, there was a news item, which claimed that we can lock and unlock our Aadhar biometric details from being requested for biometric ...

Copyrighted.com Registered & Protected DWYE-NHTO-NBNH-7FFM