LVM扩容
1、执行fdisk /dev/vda命令对磁盘剩余空间进行分区;当遇到Command (m for help):时输入n,表示新建分区;然后当需要输入时,直接按Enter键;当再次遇到Command (m for help):时输入w,表示写入保存。
[root@host-192-168-60-16 ~]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
Partition number (3,4, default 3):
First sector (20971520-104857599, default 20971520):
Using default value 20971520
Last sector, +sectors or +size{K,M,G} (20971520-104857599, default 104857599):
Using default value 104857599
Partition 3 of type Linux and of size 40 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.2、执行以下命令更新磁盘分区表
3、查看刚刚新建的分区,发现名字为vda3,大小为40G
4、使用vda3分区创建一个pv
5、把/dev/vda3这个pv加入到centos这个vg中,此时vg的空间会增加40G
6、查看centos这个vg的大小,发现为48.99G
7、扩展/dev/centos/root
在第6步中我们看到centos这个vg的总大小为48.99GiB,Free PE为10239 ,Free Size小于40.00GiB。我们把所有Free PE都加到/dev/centos/root这个lv下
注意:如果只是想把/dev/centos/root扩展到指定大小,比如40G,那么可以执行如下命令:
8、执行以下命令使根目录生效
9、查看根目录大小
Reference
Last updated
Was this helpful?