在控制台扩容操作后,进行命令行配置扩容。
MBR和ext4命令如下:
type growpart || yum install -y cloud-utils-growpart
LC_ALL=en_US.UTF-8 growpart /dev/vda 1
resize2fs /dev/vda1
#扩展自带分区
xfs_growfs /dev/centos/root
扩展系统磁盘
ext 格式:resize2fs -p /dev/cenots/root
xfs 格式:xfs_growfs /dev/centos/root
=====
一般上面的情况就可以了。但是如果格式化分区:
mkfs.ext4 /dev/sdb2
出现:Could not stat /dev/sda3 --- No such file or directory
需要partprobe命令加载:
#查看是否安装partprobe
[root@iZm5e7unwrg8d8byylz6dfZ xiaozhou1024] rpm -q parted
parted-3.1-29.el7.x86_64
[root@iZm5e7unwrg8d8byylz6dfZ xiaozhou1024] partprobe
[root@iZm5e7unwrg8d8byylz6dfZ xiaozhou1024] mkfs.ext3 /dev/vda2
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
5251072 inodes, 20972800 blocks
1048640 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
641 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
格式化分区完成后,再进行挂载:
[root@iZm5e7unwrg8d8byylz6dfZ xiaozhou1024]fdisk -l
Disk /dev/vda: 128.8 GB, 128849018880 bytes, 251658240 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: 0x000b2d99
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83875364 41936658+ 83 Linux
/dev/vda2 83875840 251658239 83891200 83 Linux
[root@iZm5e7unwrg8d8byylz6dfZ xiaozhou1024]echo "/dev/vda2 /data ext3 defaults 0 0" >> /etc/fstab
[root@iZm5e7unwrg8d8byylz6dfZ xiaozhou1024]mount a
临时挂载:
[root@iZm5e7unwrg8d8byylz6dfZ xiaozhou1024]mkdir /data
[root@iZm5e7unwrg8d8byylz6dfZ xiaozhou1024]mount /dev/vda2 /data
#查看挂载情况
[root@iZm5e7unwrg8d8byylz6dfZ xiaozhou1024] df -h
查看磁盘挂载情况:
lsblk
常规挂载文档:https://blog.csdn.net/ivneptune/article/details/130706773