共计 1992 个字符,预计需要花费 5 分钟才能阅读完成。
现状:
centos 7,/ 对应分区为 xfs 格局,且无 lvm。
只有一个分区,大小 40GB,而整个磁盘大小 200GB。
指标:
将残余磁盘空间都调配给以后分区。根本步骤为先调整分区大小,再调整 mount 的 / 的大小。
-
查看以后 / 分区文件系统为 xfs,大小 40GB
[root@hgcndn ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 489M 0 489M 0% /dev tmpfs tmpfs 496M 8.0K 496M 1% /dev/shm tmpfs tmpfs 496M 38M 458M 8% /run tmpfs tmpfs 496M 0 496M 0% /sys/fs/cgroup /dev/sda1 xfs 40G 40G 585M 99% / tmpfs tmpfs 100M 0 100M 0% /run/user/1001 vagrant vboxsf 376G 157G 220G 42% /vagrant vagrant_data vboxsf 376G 157G 220G 42% /vagrant_data tmpfs tmpfs 100M 0 100M 0% /run/user/1000
-
查看以后分区信息
[root@hgcndn ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk └─sda1 8:1 0 40G 0 part / [root@hgcndn ~]# fdisk -l /dev/sda Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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 Disk label type: dos Disk identifier: 0x0009ef1a Device Boot Start End Blocks Id System /dev/sda1 * 2048 83886079 41942016 83 Linux
-
装置须要的工具
yum install cloud-utils-growpart gdisk -y
-
growpart 重写分区表,调整分区大小,1 为分区号,如果扩容 sd2,则为 2
[root@hgcndn ~]# growpart /dev/sda 1 CHANGED: partition=1 start=2048 old: size=83884032 end=83886080 new: size=419428319 end=419430367
-
确认分区大小曾经调整为 200GB
[root@hgcndn ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk └─sda1 8:1 0 200G 0 part /
-
xfs_growfs 扩容 /
[root@hgcndn ~]# xfs_growfs / meta-data=/dev/sda1 isize=512 agcount=4, agsize=2621376 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=10485504, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=5119, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 10485504 to 52428539
-
确认 / 扩容为 200GB
[root@hgcndn ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 489M 0 489M 0% /dev tmpfs tmpfs 496M 8.0K 496M 1% /dev/shm tmpfs tmpfs 496M 38M 458M 8% /run tmpfs tmpfs 496M 0 496M 0% /sys/fs/cgroup /dev/sda1 xfs 200G 40G 161G 20% / tmpfs tmpfs 100M 0 100M 0% /run/user/1001 vagrant vboxsf 376G 157G 219G 42% /vagrant vagrant_data vboxsf 376G 157G 219G 42% /vagrant_data tmpfs tmpfs 100M 0 100M 0% /run/user/1000
正文完