进入命令
fdisk /dev/sdb
进入后按m可以看提示信息
因为这里我硬盘只有5个g
所以只需要选n分区,然后一直回车
按p打印,可以看到结果成功创建sdb1(5G)
按w保存退出即可
Sdc1的操作一样
创建完分区后,最好加载分区文件,防止后续可能出现一些问题
[root@xiaojie ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@xiaojie ~]# vgcreate GP /dev/sdb1
Volume group "GP" successfully created
[root@xiaojie ~]# lvcreate -l 100%VG -n data GP
Logical volume "data" created.
[root@xiaojie ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
[root@xiaojie ~]# vgextend GP /dev/sdc1
Volume group "GP" successfully extended
[root@xiaojie ~]# lvextend -L +3G /dev/GP/data
Size of logical volume GP/data changed from <5.00 GiB (1279 extents) to <8.00 GiB (2047 extents).
Logical volume GP/data successfully resized.
[root@xiaojie ~]# lvcreate -l 100%VG -n file GP
Reducing 100%VG to remaining free space <2.00 GiB in VG.
Logical volume "file" created.
格式化(因为我使用的是openEuler所以用ext4)如果是Centos则是使用xds
创键目录
[root@xiaojie ~]# mkdir /data /file
挂载
[root@xiaojie ~]# mount /dev/GP/data /data
[root@xiaojie ~]# mount /dev/GP/file /file
验证挂载
输入mount可以看到最后两行,已经挂载成功
也可以使用df -TH命令查看
验证结果
先卸载
[root@xiaojie ~]# umount /data
[root@xiaojie ~]# umount /file
[root@xiaojie ~]# lvremove /dev/GP/data
Do you really want to remove active logical volume GP/data? [y/n]: y
Logical volume "data" successfully removed.
[root@xiaojie ~]# lvremove /dev/GP/file
Do you really want to remove active logical volume GP/file? [y/n]: y
Logical volume "file" successfully removed.
[root@xiaojie ~]# vgremove GP
Volume group "GP" successfully removed
[root@xiaojie ~]# pvremove /dev/sdb1
Labels on physical volume "/dev/sdb1" successfully wiped.
[root@xiaojie ~]# pvremove /dev/sdc1
Labels on physical volume "/dev/sdc1" successfully wiped.
在分别进入[root@xiaojie ~]# fdisk /dev/sdb
[root@xiaojie ~]# fdisk /dev/sdc
按d删除分区
再重新重载
[root@xiaojie ~]# partprobe /dev/sdb
[root@xiaojie ~]# partprobe /dev/sdc
可以用fdisk -l查询结果
Can't open /dev/sdb1 exclusively. Mounted filesystem? '
将扩展的容量加载到目前使用的分区中:
# xfs_growfs /dev/GP/data //或在使用lvextend扩容时加 -r 选项
# lvextend -r -L +3G /dev/GP/data
CentOS 7之前操作系统实现减少逻辑卷容量的方法(CentOS 7不支持逻辑卷容量减少?):
# umount /dev/GP/data
# e2fsck -f /dev/GP/data
# resize2fs /dev/GP/data 2G //重新定义data逻辑卷大小为2G
# lvresize -L 2G /dev/GP/data
# mount /dev/GP/data /abc //挂载使用,此时data卷只剩下2G,剩余容量可用于创建其他LV卷
##