Centos扩容根目录办法
(1)先在品高云关闭服务,然后进行扩容,扩容到所需大小,开机后使用fdisk -l命令查看磁盘信息。当看到Disk /dev/vda与实际df -h显示大小不符时,说明增加磁盘成功了。
(2)使用fdisk /dev/vda, 创建新分区。注意:不同操作系统的磁盘命名方式不同,具体命名方式通过fdisk -l查询,有些是/dev/sda
[root@ceprei54]# fdisk /dev/vda
命令(输入 m 获取帮助): m
命令操作
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
命令(输入 m 获取帮助): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): p
分区号 (1-4,默认为 3): 3
起始 sector (499712-314572799,默认为 499712): #分区开始回车默认
将使用默认值 499712
Last sector, +扇区 or +size{K,M,G} (499712-501757,默认为 501757):
将使用默认值 501757
命令(输入 m 获取帮助): n
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p): p
Selected partition 4
起始 sector (62912512-314572799,默认为 62912512): #分区开始回车默认
将使用默认值 62912512
Last sector, +扇区 or +size{K,M,G} (62912512-314572799,默认为 314572799):
将使用默认值 314572799
命令(输入 m 获取帮助): t
分区号 (1-5): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)
命令(输入 m 获取帮助): p
命令(输入 m 获取帮助): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16
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.
(3)重启Linux操作系统,使用reboot命令。
(4)创建物理卷,使用pvcreate /dev/vda4命令(注意:这里选上面格式为8e那个)。
[root@ceprei54]# pvcreate /dev/vda4
Physical volume "/dev/vda4" successfully created
(5)查看新建物理卷和大小,使用pvdisplay命令。
[root@ceprei54]# pvdisplay
(6)将添加新的物理卷,加载到vg_ceprei卷组,使用vgextend vg_ceprei /dev/vda4命令。
[root@ceprei54]# vgextend vg_ceprei /dev/vda4
Volume group "vg_ceprei" successfully extended
(7)查看卷组信息,使用vgdisplay命令。
[root@ceprei54]# vgdisplay
(8)增加vg_ceprei大小,注意:如果是刚刚vda4新增的是70G,这里只能新增小于100G,不然会报错,使用lvresize -L +65G /dev/mapper/vg_ceprei-lv_root命令。
注:vg_ceprei-lv_root在df -h里面查看
[root@ceprei54]# lvresize -L +65G /dev/mapper/vg_ceprei-lv_root
Logical volume lv_root successfully resized
(9)重新识别vg_ceprei大小,使用resize2fs /dev/mapper/vg_ceprei-lv_root命令。
[root@ceprei]# resize2fs /dev/mapper/vg_ceprei-lv_root
(10)查看扩容后的大小 ,使用df -h命令。
[root@ceprei54]# df -h