我的 EC2 实例的 EBS 存储卷几乎已满,然后我尝试从 50gb 升级到 70gb。升级过程需要很长时间,我没有检查多少分钟/小时,但几天后我看到进度状态已完成。然后我尝试转到 SSH 并使用命令df -h
,但大小仍然是 50gb。为什么?
mount
返回 :
[root@ip-172-31-23-37 ec2-user]# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,size=1878544k,nr_inodes=469636,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
/dev/nvme0n1p1 on / type xfs (rw,noatime,attr2,inode64,noquota)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=25,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=13932)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,relatime)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=379360k,mode=700,uid=1000,gid=1000)
我尝试xfs_growfs -d /dev/nvme0n1p1
返回:
[root@ip-172-31-23-37 ec2-user]# xfs_growfs -d /dev/nvme0n1p1
meta-data=/dev/nvme0n1p1 isize=512 agcount=26, agsize=524159 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1 spinodes=0
data = bsize=4096 blocks=13106683, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data size unchanged, skipping
无-d
参数:
[root@ip-172-31-23-37 kristacrm-new]# xfs_growfs /dev/nvme0n1p1
meta-data=/dev/nvme0n1p1 isize=512 agcount=26, agsize=524159 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1 spinodes=0
data = bsize=4096 blocks=13106683, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
我也尝试过xfs_resize
,但找不到命令
我尝试重新启动我的 EC2 实例,但仍然有 50gb。
答案1
假设你的文件系统正在ext4
运行:
sudo resize2fs /dev/nvme0n1p1
这应该有帮助:)
答案2
刚刚发现 AWS 官方指南
首先,使用该lsblk
命令显示有关连接到实例的 NVMe 块设备的信息。:
[root@ip-172-31-23-37 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 70G 0 disk
|-nvme0n1p1 259:1 0 50G 0 part /
`-nvme0n1p128 259:2 0 1M 0 part
[root@ip-172-31-23-37 ~]# growpart /dev/nvme0n1 1
CHANGED: partition=1 start=4096 old: size=104853471 end=104857567 new: size=146796511 end=146800607
nvme0n1
有 70gb 但nvme0n1p1
(可能是分区)只有 50gb。
要扩展根卷上的分区,请使用以下growpart /dev/nvme0n1 1
命令。请注意,设备名称和分区号之间有一个空格。
[root@ip-172-31-23-37 ~]# growpart /dev/nvme0n1 1
CHANGED: partition=1 start=4096 old: size=104853471 end=104857567 new: size=146796511 end=146800607
然后再次检查使用lsblk
:
[root@ip-172-31-23-37 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 70G 0 disk
|-nvme0n1p1 259:1 0 70G 0 part /
`-nvme0n1p128 259:2 0 1M 0 part
现在nvme0n1p1
大小与 相同nvme0n1
。但 df 命令仍然显示 50gb
[root@ip-172-31-23-37 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 384K 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/nvme0n1p1 50G 41G 9.6G 81% /
tmpfs 371M 0 371M 0% /run/user/1000
最终命令是xfs_growfs -d /
并将返回:
[root@ip-172-31-23-37 ~]# xfs_growfs -d /
meta-data=/dev/nvme0n1p1 isize=512 agcount=26, agsize=524159 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1 spinodes=0
data = bsize=4096 blocks=13106683, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13106683 to 18349563
明白了!最后df
命令也显示 70gb。
[root@ip-172-31-23-37 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 384K 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/nvme0n1p1 70G 41G 30G 58% /
tmpfs 371M 0 371M 0% /run/user/1000