linux - 在 AWS ec2 上提供新卷

标签 linux amazon-web-services ubuntu amazon-ec2 amazon-ebs

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












我们不允许在 Stack Overflow 上提出有关专业服务器或网络相关基础设施管理的问题。您可以编辑问题,使其成为 on-topic对于堆栈溢出。


2年前关闭。







Improve this question




我现有的卷用完了磁盘空间。我按照这些说明根据旧卷的快照创建了一个新卷:

Log into the AWS Management Console

Make sure that the Instance that you wish to change is not currently running

Navigate to Elastic Block Store > Volumes

Check the box next to the Volume that needs more space

Click the More… drop down list and select Create Snapshot

Enter a Name and a Description

Navigate to Elastic Block Store> Snapshots

Monitor the progress of the Snapshot for completion

Once complete, navigate back to Elastic Block Store > Volumes

Click Create Volume

Enter the desired size for the new volume

Make sure that you select the same Availability Zone for your instance

Select the Snapshot that you just created

Click Yes, Create

Monitor the progress of the Volume for completion

Once complete, Check the box next to the Volume that is currently connected to the Instance

Make sure that no other Volumes are selected

Click the More… drop down list and select Click the More… drop down list and select Detach Volume

Uncheck the box selected and check the box next to the new Volume

Click the More… drop down list and select Click the More… drop down list and select Attach Volume

Select the Instance that you wish to change

Change the value in Device from xvdf to /dev/sda1

Click Yes, Attach

Navigate to Instances and start your Instance

Once you are satisfied that the volume works, feel free to delete the Snapshot and old Volume if you like



遵循这些确切说明后,我登录到 ec2 实例并注意到以下内容:
$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0         7:0    0   18M  1 loop /snap/amazon-ssm-agent/1480
loop1         7:1    0 93.8M  1 loop /snap/core/8935
loop2         7:2    0   18M  1 loop /snap/amazon-ssm-agent/1566
loop3         7:3    0 91.4M  1 loop /snap/core/8689
nvme0n1     259:0    0  100G  0 disk 
└─nvme0n1p1 259:1    0    8G  0 part /

设备nvme0n1p1是磁盘空间不足的那个:
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           390M   16M  375M   4% /run
/dev/nvme0n1p1  7.7G  7.7G     0 100% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/loop0       18M   18M     0 100% /snap/amazon-ssm-agent/1480
/dev/loop1       94M   94M     0 100% /snap/core/8935
/dev/loop3       92M   92M     0 100% /snap/core/8689
/dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1566
tmpfs           390M     0  390M   0% /run/user/1000

新卷是用 100GB 的磁盘空间创建的。我想可能是这样的:
nvme0n1     259:0    0  100G  0 disk 

所以我的问题是如何利用这 100G?这就是创建新卷的重点..

最佳答案

通过使用此功能 Modify EBS Volumes,您可以跳过增加 EBS 卷大小的漫长过程。 .

如您所见,磁盘 nvme0n1新大小为 100G ,但根分区仍然是8G .根分区nvme0n1p1必须扩展并且必须调整其文件系统的大小。

1. 扩展分区

growpart /dev/nvme0n1 1
1表示分区号,即nvme0n1p1 .

如果 growpart命令不存在,使用 apt install cloud-guest-utils 安装

2. 调整文件系统大小

对于 xfs ,
xfs_growfs -d /

如果是 ext文件系统,
resizefs /dev/nvme0n1p1

关于linux - 在 AWS ec2 上提供新卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61162003/

相关文章:

amazon-web-services - 不使用分区键查询 DynamoDB 表的全局二级索引

ubuntu - 如何在 ubuntu 12.04 上安装 libmysqld-dev?

linux - apachectl start 找不到 httpd 但它在那里?

node.js - Express/HTTP 监听每个端口的 EADDRINUSE?

linux - 在 Ubuntu 启动时运行 Python 脚本 [失败]

ios - "' UnsafeRawBufferPointer ' is not convertible to ' UnsafePointer<_> ' "在 SQLite.swift 中尝试使用 AWSAppSync swift 4

node.js - npm start 以 - fatal error : MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory 结束

ubuntu - 在lfs中不知不觉跳过了一步

ubuntu - Jenkins cli 命令返回身份验证错误

linux - 为什么没有分配给 pci 设备的 BAR 地址?