简体   繁体   English

如何在AWS上的EC2实例中添加卷?

[英]How to add volume to a ec2 instance on aws?

Created an ec2 instance with default Root Volume Type . 使用默认的Root Volume Type创建了一个ec2实例。 That's just 8 GB. 只有8 GB。

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.9G     0  7.9G   0% /dev
tmpfs           1.6G   25M  1.6G   2% /run
/dev/xvda1      7.7G  7.3G  439M  95% /
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/1000
tmpfs           1.6G     0  1.6G   0% /run/user/113

Now the instace is full used like above. 现在,像上面那样充分使用了instace。 Want to add volume size, created an EBS volume, how to attach it to the instance without deleting the original data? 要添加卷大小,创建EBS卷,如何将其附加到实例而不删除原始数据吗?

Option 1. Add another volume. 选项1.添加另一个卷。 Go to AWS Console -> EC2 -> Elastic Block Store -> Volumes. 转到AWS控制台-> EC2->弹性块存储->卷。 Create a volume, attach it to your instance. 创建一个卷,将其附加到您的实例。 From that point on you should see the new volume from your instance with lsblk . 从那时起,您应该使用lsblk查看实例中的新卷。 Make a file system with mk2fs or whatever and mount with mount . 使用mk2fs或其他文件制作文件系统,并使用mount进行mount

Option 2. Extend your current volume. 选项2。扩展当前音量。 Stop the instance, make a volume snapshot, create a new volume of the required size from that snapshot, detach old volume from the instance, attach the new volume. 停止实例,制作卷快照,从该快照创建所需大小的新卷,从实例中分离旧卷,然后附加新卷。 Make sure you're creating volume in the same availability zone that your EC2 instance is in. Start your instance. 确保在与EC2实例所在的同一可用区中创建卷。启动实例。 In most cases that's enough. 在大多数情况下,这就足够了。 If you file system was not resized automatically, use resize2fs to do it manually. 如果您没有自动调整文件系统的大小,请使用resize2fs手动进行调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM