Linux LVM 逻辑卷的使用,扩容,删除 -- 将多块硬盘组合一起使用
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux LVM 逻辑卷的使用,扩容,删除 -- 将多块硬盘组合一起使用相关的知识,希望对你有一定的参考价值。
1,创建逻辑卷
查看物理磁盘: [[email protected] ~]# parted -l | grep ‘Disk /dev/s‘ #如果分区表是GPT [[email protected] ~]# fdisk -l | grep ‘Disk /dev/s‘ #如果分区表是MBR Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sdd: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors [[email protected] ~]# 如果分区小于2T,建议转换为MBR分区表 [[email protected] ~]# parted -s /dev/sdb mklabel msdos [[email protected] ~]# parted -s /dev/sdc mklabel msdos [[email protected] ~]# parted -s /dev/sdd mklabel msdos [[email protected] ~]# dd if=/dev/zero of=/dev/sdb bs=512K count=1 [[email protected] ~]# dd if=/dev/zero of=/dev/sdc bs=512K count=1 [[email protected] ~]# dd if=/dev/zero of=/dev/sdd bs=512K count=1 在空闲磁盘上创建PV [[email protected] ~]# pvcreate /dev/sdb [[email protected] ~]# pvcreate /dev/sdc [[email protected] ~]# pvcreate /dev/sdd [[email protected] ~]# pvdisplay #验证上述结果 基于PV上创建VG [[email protected] ~]# vgcreate VG_chunli /dev/sdb /dev/sdc /dev/sdd #创建名为‘VG_chunli‘的卷组 [[email protected] ~]# vgdisplay #验证上述结果 [[email protected] ~]# vgs #验证上述结果 VG #PV #LV #SN Attr VSize VFree VG_chunli 3 0 0 wz--n- 59.99g 59.99g [[email protected] ~]# 基于VG创建逻辑卷: [[email protected] ~]# lvcreate --name Logic_chunli --size 59G VG_chunli [[email protected] ~]# lvdisplay 开机自动挂载: [[email protected] ~]# mkfs.ext4 /dev/VG_chunli/Logic_chunli [[email protected] ~]# mkdir /mnt/mount [[email protected] ~]# blkid /dev/VG_chunli/Logic_chunli /dev/VG_chunli/Logic_chunli: UUID="739588df-466a-41c2-a703-8860fe849134" TYPE="ext4" [[email protected] ~]# vim /etc/fstab #在尾行追加 UUID="739588df-466a-41c2-a703-8860fe849134" /mnt/mount ext4 defaults 1 2 [[email protected] ~]# mount -a [[email protected] ~]# df -hT #查看挂载信息 Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VG_chunli-Logic_chunli ext4 58G 53M 55G 1% /mnt/mount [[email protected] ~]# [[email protected] ~]# vgs #查看剩余的VG VG #PV #LV #SN Attr VSize VFree VG_chunli 3 1 0 wz--n- 59.99g 1012.00m [[email protected] ~]# [[email protected] ~]# pvs #查看剩余的PV PV VG Fmt Attr PSize PFree /dev/sdb VG_chunli lvm2 a-- 20.00g 0 /dev/sdc VG_chunli lvm2 a-- 20.00g 0 /dev/sdd VG_chunli lvm2 a-- 20.00g 1012.00m [[email protected] ~]#
2,LVM 扩容
[[email protected] ~]# fdisk -l | grep ‘/dev/s‘ Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 419430399 208665600 8e Linux LVM Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sdd: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sde: 161.1 GB, 161061273600 bytes, 314572800 sectors [[email protected] ~]# pvcreate /dev/sde [[email protected] ~]# vgs #查看已经存在的VG VG #PV #LV #SN Attr VSize VFree VG_chunli 3 1 0 wz--n- 59.99g 1012.00m cl 1 3 0 wz--n- 199.00g 4.00m [[email protected] ~]# [[email protected] ~]# vgextend cl /dev/sde #扩展cl [[email protected] ~]# lvextend --size 200G /dev/cl/home [[email protected] ~]# df -hT /dev/mapper/cl-home xfs 150G 33M 150G 1% /home [[email protected] ~]# xfs_growfs /dev/cl/home [[email protected] ~]# df -hT /dev/mapper/cl-home xfs 200G 33M 200G 1% /home [[email protected] ~]#
3, 删除逻辑卷
[[email protected] ~]# umount /dev/VG_chunli/LV_chunli [[email protected] ~]# lvremove /dev/VG_chunli/LV_chunli [[email protected] ~]# vgremove VG_chunli [[email protected] ~]# pvremove /dev/sdb
本文出自 “李春利” 博客,转载请与作者联系!
以上是关于Linux LVM 逻辑卷的使用,扩容,删除 -- 将多块硬盘组合一起使用的主要内容,如果未能解决你的问题,请参考以下文章