To increase the size of an EBS volume attached to a Linux EC2 instance,
follow these detailed steps:
Step 1: Modify the EBS Volume
- Open the AWS
Management Console and navigate to the EC2
Dashboard.
- Select
"Volumes" under the "Elastic Block
Store" section.
- Choose the
volume you want to resize, then click on "Actions" and select
"Modify Volume".
- Enter the new
size for the volume and click "Modify". Confirm the changes.
Step 2: Verify the Volume State
- Check the
volume state to ensure it is in the "optimizing" or
"completed" state before proceeding.
Step 3: Connect to Your EC2 Instance
- SSH into your
EC2 instance using your preferred method.
Step
4: Identify the Volume
1.
List block devices:
2. sudo lsblk
· lsblk:
Lists information about all available or specified block devices. This helps
you see the current and new sizes of your volumes.
Step
5: Resize the Partition (if necessary)
1.
Check if the volume has a partition:
2. sudo lsblk
·
lsblk:
Again, this command is used to list block devices and their partitions.
3.
Resize the partition:
4. sudo growpart /dev/xvda
1
·
growpart: This
command is used to extend a partition. Here, /dev/xvda is
the device name, and 1 is the partition
number. This command resizes the first partition on the specified device.
Step
6: Extend the File System
1.
For ext4 file system:
2. sudo resize2fs
/dev/xvda1
·
resize2fs: This
command resizes an ext2/ext3/ext4 file system. Here, /dev/xvda1 is
the partition you want to resize.
3.
For XFS file system:
4. sudo xfs_growfs -d /
·
xfs_growfs: This
command resizes an XFS file system. The -d option
specifies that the data section of the file system should be grown. The / indicates
the root file system.
Step
7: Verify the Changes
1.
Check the new size:
2. df -h
·
df -h: This
command reports file system disk space usage. The -h option
makes the output human-readable, showing sizes in KB, MB, or GB.
These commands help you manage and resize your EBS volumes and file systems effectively.
These steps should help you successfully increase the size of your EBS
volume and extend the file system on your Linux EC2 instance. If you encounter
any issues or need further assistance, feel free to ask!
Have a Database-ious Day!
No comments