There are a lot of pages with instructions to extend a linux partition in AWS EC2 instance or expanding the storage space of an ebs volume on linux. Here is another one.
Here I try to give you step by step instructions, on a Centos 7 machine, to make it easier.
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.
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, which means the EC2 instance is not fully utilizing the available disk space.
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
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 /
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.
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 of the AWS EC2 instance was thus extended to utilize all the non-allocated space in the Linux disk. AWS EC2 instance extend partition problem, SOLVED.
Here I try to give you step by step instructions, on a Centos 7 machine, to make it easier.
What does extending the Linux partition mean?
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, which means the EC2 instance is not fully utilizing the available disk space.
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
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 of the AWS EC2 instance was thus extended to utilize all the non-allocated space in the Linux disk. AWS EC2 instance extend partition problem, SOLVED.
No comments:
Post a Comment