如何增加我的 AWS EC2 计算机上的根磁盘空间。原来是16GB,我把它增加到48GB,但仍然有问题,不知道该怎么办
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 33.3M 1 loop /snap/amazon-ssm-agent/3552
loop1 7:1 0 25M 1 loop /snap/amazon-ssm-agent/4046
loop2 7:2 0 55.5M 1 loop /snap/core18/2074
loop3 7:3 0 55.4M 1 loop /snap/core18/2128
loop4 7:4 0 67.6M 1 loop /snap/lxd/20326
loop5 7:5 0 32.3M 1 loop /snap/snapd/12398
loop6 7:6 0 70.3M 1 loop /snap/lxd/21029
loop7 7:7 0 32.3M 1 loop /snap/snapd/12704
xvda 202:0 0 48G 0 disk
└─xvda1 202:1 0 48G 0 part /
df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 16197480 16177928 3168 100% /
devtmpfs 4068964 0 4068964 0% /dev
tmpfs 4074932 0 4074932 0% /dev/shm
tmpfs 814988 80264 734724 10% /run
tmpfs 5120 0 5120 0% /run/lock
tmpfs 4074932 0 4074932 0% /sys/fs/cgroup
/dev/loop0 34176 34176 0 100% /snap/amazon-ssm-agent/3552
/dev/loop2 56832 56832 0 100% /snap/core18/2074
/dev/loop1 25600 25600 0 100% /snap/amazon-ssm-agent/4046
/dev/loop3 56832 56832 0 100% /snap/core18/2128
/dev/loop4 69248 69248 0 100% /snap/lxd/20326
/dev/loop5 33152 33152 0 100% /snap/snapd/12398
/dev/loop6 72064 72064 0 100% /snap/lxd/21029
/dev/loop7 33152 33152 0 100% /snap/snapd/12704
df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/root ext4 16G 16G 3.1M 100% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 796M 79M 718M 10% /run
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/loop0 squashfs 34M 34M 0 100% /snap/amazon-ssm-agent/3552
/dev/loop2 squashfs 56M 56M 0 100% /snap/core18/2074
/dev/loop1 squashfs 25M 25M 0 100% /snap/amazon-ssm-agent/4046
/dev/loop3 squashfs 56M 56M 0 100% /snap/core18/2128
/dev/loop4 squashfs 68M 68M 0 100% /snap/lxd/20326
/dev/loop5 squashfs 33M 33M 0 100% /snap/snapd/12398
/dev/loop6 squashfs 71M 71M 0 100% /snap/lxd/21029
/dev/loop7 squashfs 33M 33M 0 100% /snap/snapd/12704
答案1
您的磁盘和根文件系统所在的分区已调整大小,但文件系统本身并未调整。它是 ext4,因此请使用resize2fs /dev/xvda1
(如果未指定大小,resize2fs
则会将文件系统的大小调整为底层块设备的大小)。ext4
支持在线增长,因此您甚至不需要先卸载它。