Amazon EC2 和 EBS 磁盘空间问题
我在协调 EBS 卷上的可用空间时遇到问题。根据AWS控制台,该卷为50GB并附加到一个实例。
如果我通过 ssh 连接到该实例并执行 df -h,我会得到以下输出:
Filesystem Size Used Avail Use% Mounted on /dev/sda1 15G 13G 3.0G 81% / udev 858M 76K 858M 1% /dev none 858M 0 858M 0% /dev/shm none 858M 72K 858M 1% /var/run none 858M 0 858M 0% /var/lock none 858M 0 858M 0% /lib/init/rw
我对 AWS 还很陌生。我将此解释为“已连接一个设备,其容量为 15GB。更重要的是,您的空间快用完了!”
任何人都可以指出控制台中公布的空间与实例上显示的空间之间明显差异的原因吗?
非常感谢
提前
I am having a problem reconciling the space available on my EBS volume. According to the AWS console the volume is 50GB and is attached to an instance.
If I ssh to this instance and do a df -h, I get the following output:
Filesystem Size Used Avail Use% Mounted on /dev/sda1 15G 13G 3.0G 81% / udev 858M 76K 858M 1% /dev none 858M 0 858M 0% /dev/shm none 858M 72K 858M 1% /var/run none 858M 0 858M 0% /var/lock none 858M 0 858M 0% /lib/init/rw
I am pretty new to AWS. I interpret this as "there is a device attached and it has 15GB capacity. Whats more, you're nearly out of space!"
Can anyone point out the cause of the apparent discrepancy between the space advertised in the console and what is displayed on the instance?
Many thanks in advance
S
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
是的,问题很简单。该卷仅与实例关联,但未挂载。
检查 AWS 控制台上安装的驱动器 - 最有可能的是
/dev/sdf
。然后(在 ubuntu 上):
第一行使用
ext3
文件系统类型格式化卷。这是相当标准的——但根据您的使用情况(例如应用程序服务器、数据库服务器……),您也可以选择另一个,例如ext4
或xfs
。第二个命令创建一个安装点,第三个命令将其安装到其中。这意味着新卷实际上将位于
/ebs
。它现在也应该显示在 df 中。最后但并非最不重要的一点是,也许还可以向
/etc/fstab
添加一个条目,以使其能够防止重新启动。Yes, the issue is simple. The volume is only associated with the instance, but not mounted.
Check on the AWS console which drive it is mounted as - most likely
/dev/sdf
.Then (on ubuntu):
The first line formats the volume - using the
ext3
file system type. This is pretty standard -- but depending on your usage (e.g. app server, database server, ...) you could also select another one likeext4
orxfs
.The second command creates a mount point and the third mounts it into it. This means that effectively, the new volume will be at
/ebs
. It should also show up indf
now.Last but not least, maybe also add an entry to
/etc/fstab
to make it reboot-proof.也许原始 15 GB 卷已克隆到 50 GB 卷,但随后未调整大小?
请参阅本教程,了解如何克隆和调整大小:如何在不丢失数据的情况下增加现有 AWS EC2 Linux (Ubuntu) 实例上的磁盘空间
希望有所帮助。
Perhaps the original 15 GB Volume was cloned into a 50 GB volume but then not resized?
Please see this tutorial on how to clone and resize: How to increase disk space on existing AWS EC2 Linux (Ubuntu) Instance without losing data
Hope that helps.
这是简单的方法...
假设您使用的是 Linux AMI,在您的情况下,您有一个简单的方法来增加文件系统的大小:
1) 停止实例
2) 分离根卷
3) 快照卷
4) 使用新大小从快照创建新卷
5) 将新卷附加到实例中原始卷所在的位置
6) 启动实例,停止除ssh之外的所有服务,并将根文件系统设置为只读
7) 扩大文件系统(例如使用 resize2fs)和/或分区(如果需要)
8) 重新启动
作为替代方案,您还可以启动一个新实例并映射实例存储,或者您可以结合前面的两个步骤创建一个新的 ami。
Here is the simple way...
Assuming that you are using a linux AMI, in your case you have an easy method for increasing the size of the file system:
1) Stop the instance
2) Detach the root volume
3) Snapshot the volume
4) Create a new volume from the snapshot using the new size
5) Attach the new volume to the instance on the same place where the original one was
6) Start the instance, stop all services except ssh and set the root filesystem read only
7) Enlarge the filesystem (using for example resize2fs) and or the partition if needed
8) Reboot
As an alternative you can also launch a new instance and map the instance storage or you can create a new ami combining the two previous steps.
仅重新启动实例就解决了我的问题
之前:
现在
Only Rebooting the instance solved my problem
Earlier:
Now
默认情况下,剩余空间安装在 /mnt。
The remaining of your space is mounted by default at /mnt.
请参阅调整正在运行的 EBS 启动 EC2 实例上的根磁盘大小
See Resizing the Root Disk on a Running EBS Boot EC2 Instance
这是因为,“增加EBS卷的大小后,必须使用文件系统特定的命令将文件系统扩展到更大的大小。卷进入优化状态后,您可以立即调整文件系统的大小。” ,不退回实例。
我今天遇到了同样的问题,我能够解决它,
找出你的文件系统的类型,
$ cat /etc/fstab
遵循此 AWS 文档,该文档准确记录了调整 EC2 实例卷大小后扩展 Linux 分区/FS 的步骤。
调整大小后扩展 Linux 文件系统卷
It is because, "After you increase the size of an EBS volume, you must use file system–specific commands to extend the file system to the larger size. You can resize the file system as soon as the volume enters the optimizing state.", without bouncing an instance.
I was just facing the same issue today, I was able to resolve it,
Figure out the type of your file system,
$ cat /etc/fstab
Follow this AWS doc, that precisely documents the steps to extend the linux Partition/FS after resizing a volume of a EC2 instance.
Extending a Linux File System After Resizing a Volume
在 Ubuntu 上,用于扩展文件系统。
要查找块设备:
在我的例子中,类型是 TYPE="ext4"。
要调整磁盘卷大小:
On Ubuntu, for Extend the Filesystem.
To find block device:
In my case type is TYPE="ext4".
To resize the disk volume:
以下是我解决与使用 EBS 磁盘空间增加 EC2 空间相关的问题的方法
使用 EC2 控制台扩展 EBS 卷
打开 EC2 控制台。
在导航窗格中,选择“实例”,然后
然后选择您的实例。
选择“存储”选项卡,然后选择
你的音量。
在“卷”窗格中,选中“卷”复选框
您想要扩展的卷。
从“操作”中,选择“修改音量”。
在卷详细信息下,根据卷类型输入大小和 IOPS。
选择“修改”,然后在对话框中选择“修改”。
在
卷窗格,在卷下查看卷的优化进度
状态。刷新卷窗格以查看进度更新。
现在,EC2 显示磁盘空间的更改,但通过 ssh 登录终端时,更改可能不会反映。
请按照以下步骤解决此问题:
在上面的输出中,根卷 (nvme0n1) 有两个分区(nvme0n1p1 和 nvme0n1p128),而附加卷 (nvme1n1) 没有分区。 30G与ec2控制台中显示的空间相同。
现在,扩展分区。使用growpart命令并指定设备名称和分区号。
分区号是p后面的数字。例如,对于 nvme0n1p1,分区编号为 1。对于 nvme0n1p128,分区编号为 128。
要扩展名为 nvme0n1p1 的分区,请使用以下命令。
验证分区是否已扩展。使用 lsblk 命令。分区大小现在应该等于卷大小。
现在扩展文件系统。
一个。获取需要扩展的文件系统的名称、大小、类型和安装点。使用df -hT命令。
b.扩展文件系统的命令因文件系统类型而异。根据您在上一步中记下的文件系统类型,选择以下正确的命令。
我。 [XFS 文件系统] 使用 xfs_growfs 命令并指定您在上一步中记下的文件系统的安装点。
例如,要扩展安装在 / 上的文件系统,请使用以下命令。
二. [Ext4 文件系统] 使用resize2fs 命令并指定您在上一步中记下的文件系统的名称。
例如,要扩展安装的名为 /dev/nvme0n1p1 的文件系统,请使用以下命令。
c.最后,验证文件系统是否已扩展。使用df -hT命令并确认文件系统大小等于卷大小。
Here is how I resolved the issue relating to increasing the EC2 space with the EBS disk space
Use the EC2 console to expand the EBS volume
Open the EC2 console.
In the navigation pane, choose Instances, and
then select your instance.
Choose the Storage tab, and then select
your volume.
In the Volumes pane, select the check box for the
volume you want to expand.
From Actions, choose Modify volume.
Under Volume details, enter the Size and IOPS based on the volume type.
Choose Modify, and then choose Modify in the dialog box.
In the
Volumes pane, see the volume's optimizing progress under Volume
state. Refresh the Volumes pane to see progress updates.
Now, the EC2 shows the changes in the disk space but when logged into the terminal through the ssh, the changes might not reflect.
Follow these steps to resolve this:
In the above output, the root volume (nvme0n1) has two partitions (nvme0n1p1 and nvme0n1p128), while the additional volume (nvme1n1) has no partitions. The 30G is the same as what the space is showing in the ec2 console.
Now, extend the partition. Use the growpart command and specify the device name and the partition number.
The partition number is the number after the p. For example, for nvme0n1p1, the partition number is 1. For nvme0n1p128, the partition number is 128.
To extend a partition named nvme0n1p1, use the following command.
Verify that the partition has been extended. Use the lsblk command. The partition size should now be equal to the volume size.
Now Extend the file system.
a. Get the name, size, type, and mount point for the file system that you need to extend. Use the df -hT command.
b. The commands to extend the file system differ depending on the file system type. Choose the following correct command based on the file system type that you noted in the previous step.
i. [XFS file system] Use the xfs_growfs command and specify the mount point of the file system that you noted in the previous step.
For example, to extend a file system mounted on /, use the following command.
ii. [Ext4 file system] Use the resize2fs command and specify the name of the file system that you noted in the previous step.
For example, to extend a file system mounted named /dev/nvme0n1p1, use the following command.
c. Finally, verify that the file system has been extended. Use the df -hT command and confirm that the file system size is equal to the volume size.