aws服务器centos8系统硬盘分区问题
申请了100G的硬盘空间,系统安装好后,查看空间情况:
发现只有4gG不到,赶紧一顿操作
大前提:安装一个工具growpart
这个是在centos8下面的yum安装:yum install -y cloud-utils-growpart
安装完成后,就开始找回剩下空间
主要3个步骤:
根目录97G,完工
1、安装工具:yum install -y cloud-utils-growpart
2、运行growpart 命令扩容分区,扩容操作:growpart /dev/xvda 2
[root@ip-172-31-18-218 ~]# growpart /dev/xvda 2
CHANGED: partition=2 start=2099200 old: size=5908480 end=8007680 new: size=207615967 end=209715167
3、进行文件系统的在线扩容,需要使用xfs_growfs命令进行扩展
[root@ip-172-31-18-218 ~]# xfs_growfs /dev/xvda2
meta-data=/dev/xvda2 isize=512 agcount=4, agsize=184640 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=738560, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log 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 738560 to 25951995
全部完整操作:
[root@ip-172-31-18-218 ~]# df -l
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 8171688 0 8171688 0% /dev
tmpfs 8208468 0 8208468 0% /dev/shm
tmpfs 8208468 16788 8191680 1% /run
tmpfs 8208468 0 8208468 0% /sys/fs/cgroup
/dev/xvda2 2944000 1785856 1158144 61% /
/dev/xvda1 999320 87756 842752 10% /boot
tmpfs 1641692 0 1641692 0% /run/user/1001
[root@ip-172-31-18-218 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 100G 0 disk
├─xvda1 202:1 0 1G 0 part /boot
└─xvda2 202:2 0 2.8G 0 part /
[root@ip-172-31-18-218 ~]# growpart /dev/xvda 1
NOCHANGE: partition 1 is size 2097152. it cannot be grown
[root@ip-172-31-18-218 ~]# growpart /dev/xvda 2
CHANGED: partition=2 start=2099200 old: size=5908480 end=8007680 new: size=207615967 end=209715167
[root@ip-172-31-18-218 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 100G 0 disk
├─xvda1 202:1 0 1G 0 part /boot
└─xvda2 202:2 0 99G 0 part /
[root@ip-172-31-18-218 ~]# df -l
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 8171688 0 8171688 0% /dev
tmpfs 8208468 0 8208468 0% /dev/shm
tmpfs 8208468 16788 8191680 1% /run
tmpfs 8208468 0 8208468 0% /sys/fs/cgroup
/dev/xvda2 2944000 1786120 1157880 61% /
/dev/xvda1 999320 87756 842752 10% /boot
tmpfs 1641692 0 1641692 0% /run/user/1001
[root@ip-172-31-18-218 ~]# fdisk -l
Disk /dev/xvda: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xfb1545d0
Device Boot Start End Sectors Size Id Type
/dev/xvda1 * 2048 2099199 2097152 1G 83 Linux
/dev/xvda2 2099200 209715166 207615967 99G 83 Linux
[root@ip-172-31-18-218 ~]# xfs_growfs /dew/xvda2
xfs_growfs: path resolution failed for /dew/xvda2: No such file or directory
[root@ip-172-31-18-218 ~]# xfs_growfs /dev/xvda2
meta-data=/dev/xvda2 isize=512 agcount=4, agsize=184640 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=738560, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log 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 738560 to 25951995
[root@ip-172-31-18-218 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 7.9G 17M 7.9G 1% /run
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
/dev/xvda2 99G 2.4G 97G 3% /
/dev/xvda1 976M 86M 823M 10% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/1001
完结!