Linux notes 2-5 lvm-expandable disk

Source: Internet
Author: User

5.lvm*********************
For creating an extensible disk

# # 1.LVM Build # #
pvs              //View physical Volume information
vgs               //View physical volume group information
LVs               //View Logical Volume Information
established:
Fdisk/dev/vdb                  //divides the physical partition and modifies the partition ID to 8e
pvcreate/ DEV/VDB1             //Creating a physical volume
Vgcreate hello/dev/ VDB1      //Creating a physical volume group
lvcreate-l 100m-n lv0 Hello  //Creating a logical volume

Test:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/FC/wKiom1gi9mXyWRpCAAD0uGOgFXk316.png "title=" Capture 1. PNG "style=" Float:none; "alt=" Wkiom1gi9mxywrpcaad0ugogfxk316.png "/>

# # 2.LVM Management # #

# #扩展磁盘 # #--supported disk extensions in use
Lvextend-l 200m/dev/hello/lv0//Extended Logical volume size to 200M
Xfs_growfs/dev/hello/lv0//Extended file system

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/89/F8/wKioL1gi98ighDftAAAkrJqe8-0161.png "style=" float: none; "Title=" Captures 1. PNG "alt=" Wkiol1gi98ighdftaaakrjqe8-0161.png "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/89/FC/wKiom1gi98nzQQk7AACAV9vpFtU465.png "style=" float: none; "Title=" Captures 2. PNG "alt=" Wkiom1gi98nzqqk7aacav9vpftu465.png "/>

PVCREATE/DEV/VDB2//Create physical volume

Vgextend HELLO/DEV/VDB2//Extended Physical volume

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/89/F8/wKioL1gi98zCbRDQAAA4jBkvn-g400.png "style=" float: none; "Title=" Captures 3. PNG "alt=" Wkiol1gi98zcbrdqaaa4jbkvn-g400.png "/>
It seems that the partition size can be infinitely extended, but the fact is limited by the file system, the partition size can not be infinitely extended, for example, XFS file system support maximum partition size of 18EB

# #缩减磁盘 # #

Note: XFS does not support file system reduction, which causes the disk to not shrink, so we use the Ext file system for this experiment

Shrink file System--You must uninstall the device before shrinking
umount/mnt///unloading equipment
E2fsck-f/dev/hello/lv0//testing equipment
Resize2fs/dev/hello/lv0 200M//Shrink file system to 200M

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/89/F8/wKioL1gi-HjiJzTVAAAYozllfMc195.png "style=" float: none; "title=" capture. PNG "alt=" Wkiol1gi-hjijztvaaayozllfmc195.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/89/FC/wKiom1gi-HjAchbdAAAkrJqe8-0333.png "style=" float: none; "Title=" Captures 1. PNG "alt=" Wkiom1gi-hjachbdaaakrjqe8-0333.png "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/89/F8/wKioL1gi-HmSwt9hAACi5MOspYo550.png "style=" float: none; "Title=" Captures 2. PNG "alt=" Wkiol1gi-hmswt9haaci5mospyo550.png "/>

Reduce the logical volume size--You must shrink the file system size before reducing the logical volume size
Lvreduce-l 200m/dev/hello/lv0
650) this.width=650; src= http://s2.51cto.com/wyfs02/M01/89/FC/ Wkiom1gi-hvil7t6aab8yco8vv8476.png "style=" Float:none; "Title=" Captures 4. PNG "alt=" wkiom1gi-hvil7t6aab8yco8vv8476.png "/>
reduced physical volume

remove VDB1
pvmove/dev/vdb1/dev/ VDB2                      //moving VDB1 data to VDB2
Vgreduce hello/dev/vdb1                       //Remove the
PVREMOVE/DEV/VDB1 from the physical volume group                              //Deleting a physical volume

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/89/FC/wKiom1gi-PWRRscEAAB0681i4Lc554.png "style=" float: none; "title=" capture. PNG "alt=" Wkiom1gi-pwrrsceaab0681i4lc554.png "/>650) this.width=650; src=" Http://s3.51cto.com/wyfs02/M02/89/FC /wkiom1gi-peaobmuaaczztvkczo052.png "style=" Float:none; "Title=" Captures 2. PNG "alt=" Wkiom1gi-peaobmuaaczztvkczo052.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/FC/wKiom1gi-SewzccvAABgMZf510o654.png "title=" Capture 3. PNG "alt=" Wkiom1gi-sewzccvaabgmzf510o654.png "/>

Problems that may occur in the operation

1> reduced file system size is larger than the logical volume size, causing the device to become unusable
Workaround extend the logical volume size before performing a reduced file system, reducing the size of the logical volume
2> not remove device from physical volume, delete device directly in Fdisk
An unknown partition appears in the physical volume, and the Vgreduce--removemissing Physical volume group is used to remove the unknown device

# # 3.LVM Snapshot # #--Keep your data safe

Write Data on disk
Mount/dev/hello/lv0/mnt
touch/mnt/file{1..10}
Ls/mnt

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/89/F8/wKioL1gi-cXSzM2JAAA3zT5KL5g463.png "style=" float: none; "title=" 1.PNG "alt=" Wkiol1gi-cxszm2jaaa3zt5kl5g463.png "/>

Create a Snapshot
Umount/mnt
Lvcreate-l 10m-n lv0-backup-s/dev/hello/lv0
LVS650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/89/FC/wKiom1gi-cbjaGHZAABy56yhMVM125.png "title = "2.PNG" style= "Float:none;" alt= "Wkiom1gi-cbjaghzaaby56yhmvm125.png"/>

Delete data

Mount/dev/hello/lv0-ba ckup/mnt

Ls/mnt

rm-fr/mnt/*

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/F9/wKioL1gi-cbjj_WBAAA4SBc-RWo235.png "title=" 3.PNG " Style= "Float:none;" alt= "Wkiol1gi-cbjj_wbaaa4sbc-rwo235.png"/>
Re-create the snapshot
Umount/mnt
Lvremove/dev/hello/lv0-backup
Lvcreate-l 10m-n lv0-backup-s/dev/hello/lv0

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/89/F9/wKioL1gi-neC9Ia7AABfXX3MA6Q437.png "style=" float: none; "title=" capture. PNG "alt=" Wkiol1gi-nec9ia7aabfxx3ma6q437.png "/>

Data recovery
Mount/dev/hello/lv0-backup/mnt
Ls/mnt

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/89/FC/wKiom1gi-nfClrE8AABhAHwLqRs523.png "style=" float: none; "Title=" Captures 1. PNG "alt=" Wkiom1gi-nfclre8aabhahwlqrs523.png "/>
# # 4.LVM Delete # #--deleted sequentially

Lvremove//deleting snapshots and logical volumes

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/89/F9/wKioL1gi-ubhgxvaAACgbqSVtpg433.png "style=" float: none; "title=" capture. PNG "alt=" Wkiol1gi-ubhgxvaaacgbqsvtpg433.png "/>

Vgremove//Deleting physical volume groups

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/89/FC/wKiom1gi-ueQYjzTAABI-blHClA327.png "style=" float: none; "Title=" Captures 1. PNG "alt=" Wkiom1gi-ueqyjztaabi-blhcla327.png "/>
Pvremove//Deleting physical volumes

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/89/F9/wKioL1gi-uehrp4_AABE0WUQL-0829.png "style=" float: none; "Title=" Captures 2. PNG "alt=" Wkiol1gi-uehrp4_aabe0wuql-0829.png "/>
# 5. Command and script create partition # #

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/FC/wKiom1gi-0jAubpaAAAXSsByphc987.png "title=" capture. PNG "style=" Float:none; "alt=" Wkiom1gi-0jaubpaaaaxssbyphc987.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/89/FC/wKiom1gi-0fT7c4TAAAXPqC5C5w546.png "style=" float: none; "Title=" Captures 1. PNG "alt=" Wkiom1gi-0ft7c4taaaxpqc5c5w546.png "/>



Linux notes 2-5 lvm-expandable disk

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.