首页 > 解决方案 > 在不丢失任何数据的情况下增加 EC2 磁盘存储

问题描述

我有一个正在运行的t2.medium实例,它具有4GB体积RAM和体积。25GBEBS

该实例当前正在运行一个Apache服务器、一个 wordpress 应用程序、一个 mysql 服务器和一个 codeigniter 应用程序。

我不希望任何数据丢失。

如何将音量增加到 100GB?

我在这里找到了一篇文章,但我不确定这样做是否会导致所有数据丢失。

标签: amazon-web-servicesamazon-ec2devops

解决方案


我们可以在不分离卷或重新启动实例的情况下增加 ebs 卷。如果发生不好的事情,最好创建 ebs 卷的快照

用于创建快照

Go to your EBS volume list from your EC2 Dashboard.
Right click the volume.
Click Create Snapshot link.
Add the description value any thing is good here.
Add key : Name and value : snapshot-your-volume.
Click button Create Snapshot.

增加尺寸

Right click on the volume you wish to increase.
Add your desired size; In our example type 40.
Click Modify.
You will get confirmation to extend OS file system.
Click Yes.

修改完卷后,您需要扩展 OS 文件系统才能看到增加的卷大小。

ssh into your instance 
df -h -> will tell you the volume size
lsblk -> display information about the block devices attached to your instance
sudo growpart /dev/xvda 1
df -h -> to verify the size again
sudo resize2fs /dev/xvda1

扩展文件系统的文档


推荐阅读