Amazon 上的 EC2 实例,我收到“磁盘上没有剩余空间”的消息

发布于 2024-11-09 18:55:34 字数 328 浏览 0 评论 0原文

我已安装 Amazon EC2 fedora 实例并将文件从一个位置复制到另一个位置。 但我收到的是“磁盘上没有剩余空间”。

我做了df -f

输出:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              15G   15G     0 100% /
none                  312M     0  312M   0% /dev/shm

我想增加亚马逊上 ec2 实例的空间。有人可以帮我吗?

I have installed Amazon EC2 fedora instance and copying the files from one location to another.
But I am greeted with " No space left on the disk".

I did df -f.

with output:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              15G   15G     0 100% /
none                  312M     0  312M   0% /dev/shm

I want to increase the space for ec2 instance on amazon. Can someone help me with it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

少女七分熟 2024-11-16 18:55:34

这是一个更简单的方法。 (我的 m2.2xlarge 实例是使用 RedHat Linux 6.2 创建的,我发现它只有 850gb 中的 6gb 可用空间):

  1. 通过 ssh,检查 root 下的空间:$df -h
已使用的文件系统大小 Avail Use% Mounted on
/dev/xvde1 6G 6G 0G 100% /
无 17G 0 17G 0% /dev/shm
  1. 从 aws 控制台,停止实例
  2. 从 aws 控制台,分离卷(但请注意附件信息下的挂载点,例如 /dev/sda1
  3. 从 aws 控制台,拍摄卷的快照
  4. 从 aws 控制台,使用快照创建一个新卷(使用所有剩余的
    实例类型的空间,例如在我的 m2.2xlarge 情况下为 825GB)
  5. 从 aws 控制台,将新卷附加到原始挂载点 /dev/sda1
  6. 从 aws 控制台,重新启动实例并通过 ssh 返回到实例
  7. 从 ssh,运行 resize2fs在根文件系统上(请参阅步骤 1 中的 df -h 输出)[可能不需要]

$resize2fs /dev/xvde1

  1. 等几分钟,可能去看看你的朋友是谁
    停止
  2. 观察新的海绵状安装:$ df -h
已使用的文件系统大小 Avail Use% Mounted on
/dev/xvde1 813G 3.7G 801G 1% /
无 17G 0 17G 0% /dev/shm

Here's an even easier method. (My m2.2xlarge instance was created with RedHat Linux 6.2, I discovered it had a paltry 6gb available of it's 850gb):

  1. Via ssh, check space under root: $df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvde1              6G    6G    0G   100% /
none                   17G     0   17G   0% /dev/shm
  1. From aws console, stop the instance
  2. From aws console, detach the volume (though note the mount point under attachment info, eg /dev/sda1)
  3. From aws console, take a snapshot of the volume
  4. From aws console, create a new volume using the snapshot (using all the remaining
    space for the instance type, eg 825gb in my m2.2xlarge case)
  5. From aws console, attach the new volume to original mount point /dev/sda1
  6. From aws console, restart the instance and ssh back in to the instance
  7. From ssh, run resize2fs on the root Filesystem (see df -h output in step 1) [potentially not needed]

$resize2fs /dev/xvde1

  1. wait for a few minutes, possibly go and watch your buddy who is
    stopping all the root services etc like a boss : )
  2. observe the new cavernous mount: $df -h
Filesystem            Size  Used   Avail Use%   Mounted on
/dev/xvde1            813G  3.7G    801G   1%     /
none                   17G     0     17G   0%     /dev/shm
嘿嘿嘿 2024-11-16 18:55:34

修改卷大小。从 AWS 控制台,您可以修改卷的大小。

  1. 从 AWS 控制台,打开“ELASTIC BLOCK STORE/Volume”,
  2. 选择您的卷并修改卷(通过“操作”按钮)
  3. 更改大小(例如 8 到 20gib)
  4. 单击“修改”。
  5. 从 EC2 仪表板重新启动。
  6. 检查大小由 df -h 更改

Modify volume size. From AWS Console, you can modify the size of a volume.

  1. From AWS console, open 'ELASTIC BLOCK STORE/Volume'
  2. Select your volume and Modify volume(from Actions button)
  3. Change size (e.g. 8 to 20gib)
  4. Click Modify.
  5. Reboot from EC2 Dashboard.
  6. check size is changed by df -h
雄赳赳气昂昂 2024-11-16 18:55:34

我有一个解决方案,伙计们 yippeeee

假设您使用的是 Linux AMI,在您的情况下,您有一个简单的方法来增加文件系统的大小:

1) 停止实例

2) 分离根卷

3) 快照卷

4)使用新大小从快照创建新卷

5) 将新卷附加到原始卷所在位置的实例

6) 启动实例,停止除 ssh 之外的所有服务,并将根文件系统设置为只读

7) 放大文件系统(例如使用 resize2fs)和/或分区(如果需要)

8) 重新启动

作为替代方案,您还可以启动一个新实例并映射实例存储,或者您可以结合前面的两个步骤创建一个新的 ami。

I got a solution guys yippeeee

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.

剪不断理还乱 2024-11-16 18:55:34
  1. 使用 du -a | 查找最大的文件sort -n
  2. 停止某些服务,它们可能会阻止隐藏/删除的文件最终被删除。
  1. find the biggest files with du -a | sort -n
  2. stop some services, they might block hidden/removed files from being finally deleted.
泪意 2024-11-16 18:55:34

我跳过了所有分离/快照/新卷的内容...只是调整了大小。

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              5904748   4725152   1119608  81% /
none                  15728640         0  15728640   0% /dev/shm
[root@ip-10-25-6-214 ~]# resize2fs /dev/sda1
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/sda1 to 31457280 (4k) blocks.

I skipped all the detach/snapshot/new volume stuff... just did the resize.

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              5904748   4725152   1119608  81% /
none                  15728640         0  15728640   0% /dev/shm
[root@ip-10-25-6-214 ~]# resize2fs /dev/sda1
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/sda1 to 31457280 (4k) blocks.
独孤求败 2024-11-16 18:55:34

不确定 AWS 是否添加了额外的步骤以扩展添加的磁盘空间,但以下命令对我有用:

按照答案直到社区 wiki 第 6 步
步骤 7 的发布步骤如下:

  1. 检查该卷是否有分区。使用lsblk命令
sudo lsblk

输出:

NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

xvda       202:0    0  20G  0 disk
└─xvda1    202:1    0   8G  0 part /
  1. 检查分区是否需要扩展。在上一步的 lsblk 命令输出中,比较分区大小和卷大小。如果分区大小小于卷大小,请继续下一步。如果分区大小等于卷大小,则无法扩展分区。
  2. 扩展分区。使用growpart命令并指定要扩展的分区。
sudo growpart /dev/xvda 1
  1. 验证分区是否已扩展。使用 lsblk 命令。分区大小现在应等于卷大小
sudo lsblk

输出:

NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
xvda    202:0    0    20G  0 disk
└─xvda1 202:1    0    20G  0 part /

参考

Not sure if AWS has added additional steps inorder to extend the added disk space but the below commands worked for me:

Follow the answer till the community wiki Step 6
Post that for Step 7 follow the steps as below:

  1. Check whether the volume has a partition. Use the lsblk command
sudo lsblk

Output:

NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

xvda       202:0    0  20G  0 disk
└─xvda1    202:1    0   8G  0 part /
  1. Check whether the partition needs to be extended. In the lsblk command output from the previous step, compare the partition size and the volume size. If the partition size is smaller than the volume size, continue to the next step. If the partition size is equal to the volume size, the partition can't be extended.
  2. Extend the partition. Use the growpart command and specify the partition to extend.
sudo growpart /dev/xvda 1
  1. Verify that the partition has been extended. Use the lsblk command. The partition size should now be equal to the volume size
sudo lsblk

Output:

NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
xvda    202:0    0    20G  0 disk
└─xvda1 202:1    0    20G  0 part /

Reference

躲猫猫 2024-11-16 18:55:34

我将该磁盘安装在另一个 EC2 实例上,在该实例上我可以成功使用 Growthpart,然后调整 size2fs。之后安装回原始 EC2 实例。

I mounted the disk on another EC2 instance where I could successfully use growpart and then resize2fs. After that mounting back to the origin EC2 instance.

无言温柔 2024-11-16 18:55:34

当 EC2 实例是从“EBS-Store”而不是“Instance-Store”创建时,您的情况有效。从“instance-store”创建的 EC2 实例将始终为 /mnt 目录分配巨大的空间(大约 200GB 以上)。

否则,您的解决方案对于从“EBS-Store”创建的那些 EC2 机器有效。您可以使用此类机器做更多事情。

  1. 更改终止类型
  2. 更改实例类型
  3. 从实例创建 AMI
  4. 轻松自动扩展。

Your case is valid when the EC2 instance was created from "EBS-Store" rather than "Instance-Store". EC2 instance created from "instance-store" will always have a huge space (around 200GB +) allocated for /mnt directory.

Otherwise your solution is valid for those EC2 machine created from "EBS-Store". You can do more with such machines.

  1. Change the termination type
  2. Change the instance type
  3. Create an AMI from the instance
  4. Auto-scale with ease.
愛上了 2024-11-16 18:55:34

如果您遇到此错误

操作系统错误:[Errno 28] 设备上没有剩余空间

并且您正在使用 Docker 容器,您可以使用以下命令清理您的 EC2 实例:

sudo systemctl stop docker
sudo rm -rf /var/lib/docker
sudo systemctl start docker

If you got this error

OSError: [Errno 28] No space left on device

And you are using Docker containers, you can clean your EC2 instance with these commands:

sudo systemctl stop docker
sudo rm -rf /var/lib/docker
sudo systemctl start docker
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文