How to Increase Disk Space on an Amazon EC2 Instance
The following procedure shows how to apply available volume modifications from the Amazon EC2 console
- Log into the AWS Management Console
- Navigate to Elastic Block Store > Volumes
- Check the box next to the Volume that needs more space
- Click the Action drop down list and select Modify Volume
- The Modify Volume window displays the volume ID and the volume's current configuration, including type, size, and IOPS. You can change any or all of these settings in a single action. Set new configuration values as follows
- To modify the type, choose a value for Volume Type
- To modify the size, enter an allowed integer value for Size
- If you chose Provisioned IOPS (IO1) as your volume type, enter an allowed integer value for IOPS
- After you have specified all of the modifications to apply, choose Modify, Yes
Important: modifying volume size has no practical effect until you also extend the volume's file system to make use of the new storage capacity
Extending a Linux File System after Resizing the Volume
- Use the df -h command to report the existing disk space usage on the file system
[ec2-user ~]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 8.0G 943M 6.9G 12% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/xvdf 1014M 33M 982M 4% /mnt
Warning: if you can't see /dev/xvdf here and /dev/xvda1 still show old storage capacity, skip step 2 for resize file system on step 3
- Expand the modified partition using growpart (and note the unusual syntax of separating the device name from the partition number)
$sudo growpart /dev/xvdf 1 CHANGED: disk=/dev/xvdf partition=1: start=4096 old: size=16773086,end=16777182 new: size=73396190,end=73400286
Using lsblk output confirms that the partition /dev/xvdf1 now fills the available space on the volume /dev/xvdf:
[ec2-user ~]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT ... xvdf 202:80 0 35G 0 disk └─xvdf1 202:81 0 35G 0 part
- Use a file system-specific command to resize each file system to the new volume capacity
[ec2-user ~]$ sudo resize2fs /dev/xvdf1 resize2fs 1.42.3 (14-May-2012) old_desc_blocks = 1, new_desc_blocks = 3 The filesystem on /dev/xvdf1 is now 9174523 blocks long.
Comments
Post a Comment