Use, expansion, and deletion of Linux LVM logical volumes-use multiple hard drive combinations

Source: Internet
Author: User



1, creating a logical volume

View Physical Disk:[[email protected] ~]# parted -l | grep  ' Disk /dev/s '  # If the partition table is gpt[[email protected] ~]# fdisk -l | grep  ' Disk /dev/s '     #如果分区表是MBRDisk  /dev/sda: 214.7 GB, 214748364800 bytes, 419430400  Sectorsdisk /dev/sdc: 21.5 gb, 21474836480 bytes, 41943040 sectorsdisk  /DEV/SDD: 21.5 GB, 21474836480 BYTES, 41943040 SECTORSDISK /DEV/SDB:  21.5 gb, 21474836480 bytes, 41943040 sectors[[email protected] ~]#   If the partition is less than 2T, it is recommended to convert to MBR partition table [[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 Create pv[[email protected] ~]# pvcreate /dev/sdb[[email  on the free disk 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 ' volume group [[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] ~]#  create a logical volume based on VG: [[Email protected] ~]# lvcreate  --name logic_chunli --size 59g   vg_chunli[[email protected] ~]#  lvdisplay  Boot automatically mount: [r[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 expansion

[[email protected] ~]# fdisk -l | grep  '/dev/s ' Disk /dev/sdc:  21.5 GB, 21474836480 BYTES, 41943040 SECTORSDISK /DEV/SDA: 214.7 GB,  214748364800 bytes, 419430400 sectors/dev/sda1   *         2048     2099199     1048576    83  Linux/dev/sda2         2099200    419430399   208665600   8e  linux lvmdisk /dev/ sdb: 21.5 gb, 21474836480 bytes, 41943040 sectorsdisk /dev/sdd: 21.5  GB, 21474836480 bytes, 41943040 sectorsDisk /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. Delete the logical volume

[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





This article from "Li Chunli" blog, reproduced please contact the author!

Use, expansion, and deletion of Linux LVM logical volumes-use multiple hard drive combinations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.