RHCE Learning Notes-LVM logical volumes

Source: Internet
Author: User

This section learns how to create snapshots of LVM,LVM and related configurations for raid.


For ordinary partitions, the scale is not high, once the partition format is complete, it is difficult to flexibly increase or reduce the size of the partition. To solve this problem, you can use LVM (logical volumes). The basic process is to initialize the physical disk or partition as a physical volume (PV), then add PV to the VG (volume group), and finally divide the logical partition (LVM) on the VG, which can be formatted and mounted as normal partitions.


First Look at PV


A new disk is divided into 6 partitions by gdisk, each partition 2G, is set to LVM type

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9C/wKioL1S15fSThNasAAB8jUksbS0521.jpg "style=" float: none; "title=" 1.PNG "alt=" Wkiol1s15fsthnasaab8juksbs0521.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9C/wKioL1S15fjQOwSVAAEE7Un_PZc171.jpg "style=" float: none; "title=" 2.PNG "alt=" Wkiol1s15fjqowsvaaee7un_pzc171.jpg "/>


Create PV

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9C/wKioL1S15gHBE5YLAAJw49Gii6w987.jpg "style=" float: none; "title=" 3.PNG "alt=" Wkiol1s15ghbe5ylaajw49gii6w987.jpg "/>



After you create the PV, you need to create the VG and then add the PV to the VG

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9C/wKioL1S15gOxjt6zAADnyvVvsLc406.jpg "style=" float: none; "title=" 4.PNG "alt=" Wkiol1s15goxjt6zaadnyvvvslc406.jpg "/>


You can view the specific information through the Vgdisplay, note that the size of the PE is 4M, this is the smallest calculation unit of increase or decrease

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9F/wKiom1S15T3CTvJYAAFH0QmbQZk480.jpg "style=" float: none; "title=" 5.PNG "alt=" Wkiom1s15t3ctvjyaafh0qmbqzk480.jpg "/>


Enter VG, tab two times to view related commands

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9C/wKioL1S15gqyyKGEAACyS004LDk087.jpg "style=" float: none; "title=" 6.PNG "alt=" Wkiol1s15gqyykgeaacys004ldk087.jpg "/>


We can continue to add new partitions to the VG.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9F/wKiom1S15UejnHPEAAGu4FDusoA583.jpg "style=" float: none; "title=" 7.PNG "alt=" Wkiom1s15uejnhpeaagu4fdusoa583.jpg "/>


I did not convert the Sdc7 into PV, but added directly to the VG, but once added he automatically initialized to PV.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9C/wKioL1S15hfCxpw9AAGh09I8pcA155.jpg "style=" float: none; "title=" 8.PNG "alt=" Wkiol1s15hfcxpw9aagh09i8pca155.jpg "/>


Can add natural can reduce

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9F/wKiom1S15VPQA4FOAAHa5AYBbe4039.jpg "style=" float: none; "title=" 9.PNG "alt=" Wkiom1s15vpqa4foaaha5aybbe4039.jpg "/>


The VG is ready to create the LVM.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9C/wKioL1S15iLQSrZmAAB3s38qbOQ483.jpg "style=" float: none; "title=" 10.PNG "alt=" Wkiol1s15ilqsrzmaab3s38qboq483.jpg "/>


The LV related commands are as follows, can be added, reduced, displayed, converted, etc.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9C/wKioL1S15iTDHaSQAACruSwv7Ho505.jpg "style=" float: none; "title=" 12.PNG "alt=" Wkiol1s15itdhasqaacruswv7ho505.jpg "/>


Create a 110M-sized logical volume

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9F/wKiom1S15VuSPdWdAABuWOiz9Ns050.jpg "style=" float: none; "title=" 13.PNG "alt=" Wkiom1s15vuspdwdaabuwoiz9ns050.jpg "/>


Confirm

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9C/wKioL1S15ieDTbc8AACA1bmPZqM778.jpg "style=" float: none; "title=" 14.PNG "alt=" Wkiol1s15iedtbc8aaca1bmpzqm778.jpg "/>


Note that his size is actually 112M, because the size of the PE is 4M, this 4M is the smallest unit, can not break open, so 28 PE is 112M


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9F/wKiom1S15V_RBjuqAAGCdyUES5Q782.jpg "style=" float: none; "title=" 15.PNG "alt=" Wkiom1s15v_rbjuqaagcdyues5q782.jpg "/>


112 divided by 4, just 28.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9C/wKioL1S15i6gBJA5AAFfKXChE_M146.jpg "style=" float: none; "title=" 16.PNG "alt=" Wkiol1s15i6gbja5aaffkxche_m146.jpg "/>


Large L can specify the size directly, small l is the value of the specified number of PE

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9F/wKiom1S15WWSM4T2AABBsVZYCnE267.jpg "style=" float: none; "title=" 17.PNG "alt=" Wkiom1s15wwsm4t2aabbsvzycne267.jpg "/>


You can also set a percentage of the remaining space

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9C/wKioL1S15jGj7MIXAABI4HEMUX4250.jpg "style=" float: none; "title=" 18.PNG "alt=" Wkiol1s15jgj7mixaabi4hemux4250.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9F/wKiom1S15WrRBBxqAADG4ILp0FQ105.jpg "style=" float: none; "title=" 19.PNG "alt=" Wkiom1s15wrrbbxqaadg4ilp0fq105.jpg "/>


Delete a logical volume

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9C/wKioL1S15jqT5KsHAAEydgcGi7Q881.jpg "style=" float: none; "title=" 20.PNG "alt=" Wkiol1s15jqt5kshaaeydgcgi7q881.jpg "/>



For logical volumes that have been created, they can be formatted and mounted as normal partitions


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9F/wKiom1S15XaTgyCDAAGubz8Rcho701.jpg "style=" float: none; "title=" 21.PNG "alt=" Wkiom1s15xatgycdaagubz8rcho701.jpg "/>



To extend a logical volume 200M, note that his file system is still 109M unchanged, and we also need to populate the file system with whitespace. This is similar to the Windows virtual machine inside the expansion of the hard disk, the same need to use the DiskPart extend command to extend the file system.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9F/wKiom1S15XuSDiJ9AAEQmpfUoFY367.jpg "style=" float: none; "title=" 23.PNG "alt=" Wkiom1s15xusdij9aaeqmpfuofy367.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9C/wKioL1S15krQnCrvAAGUjQfn1OQ944.jpg "style=" float: none; "title=" 24.PNG "alt=" Wkiol1s15krqncrvaagujqfn1oq944.jpg "/>


Rhel can be used XFS_GROWFS to expand the Xfs file system, or directly with the RESIZE2FS to deal with the device


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/A0/wKiom1S15YbS_3EhAABcEpqnLMs570.jpg "style=" float: none; "title=" 25.PNG "alt=" Wkiom1s15ybs_3ehaabcepqnlms570.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9C/wKioL1S15lnTgHZuAAMB3oJ7nXI842.jpg "style=" float: none; "title=" 26.PNG "alt=" Wkiol1s15lntghzuaamb3oj7nxi842.jpg "/>


Note that the XFS system only grows and cannot be reduced! So if you need to reduce LVM, partitions can only use EXT4.



Here's a demonstration of how to expand or shrink ext4 LVM


First, create a 100M Lv2

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9C/wKioL1S15mHBTVDyAAJBPFBHyNE831.jpg "style=" float: none; "title=" 28.PNG "alt=" Wkiol1s15mhbtvdyaajbpfbhyne831.jpg "/>


Mount to/bb

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/A0/wKiom1S15ZuTsRVbAAH9JgK9ukw455.jpg "style=" float: none; "title=" 29.PNG "alt=" Wkiom1s15zutsrvbaah9jgk9ukw455.jpg "/>


Expansion of LVM:


100M expansion

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9C/wKioL1S15mehYcX3AAB1sdjXcHE274.jpg "style=" float: none; "title=" 30.PNG "alt=" Wkiol1s15mehycx3aab1sdjxche274.jpg "/>


Populating the file system

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/A0/wKiom1S15aLSqaS8AAJ17W8us0k641.jpg "style=" float: none; "title=" 31.PNG "alt=" Wkiom1s15alsqas8aaj17w8us0k641.jpg "/>


To reduce LVM:


Then Umount, check the Lv2 file system for errors, and then first need to reduce the file system size, here to 120M

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9C/wKioL1S15nPDNJ6WAAI_OtSIp0k668.jpg "style=" float: none; "title=" 32.PNG "alt=" Wkiol1s15npdnj6waai_otsip0k668.jpg "/>


Then reduce the size of the LVM and reduce the 70M

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9D/wKioL1S18QCz1GRoAAM8v-vyhHk876.jpg "style=" float: none; "title=" 33.PNG "alt=" Wkiol1s18qcz1groaam8v-vyhhk876.jpg "/>



In addition to being able to increase and decrease LVM, you can also take snapshots. Many of the principles of backup software, such as the virtual machine is to take a snapshot of the disk, and then to the snapshot backup, if the time of the backup to write new information, the information is saved in a new snapshot, the backup is finished before the changes are written back to disk; If the snapshot space is not enough, you can imagine the consequences are catastrophic Beans have met many similar problems on Veeam B&r and ESXi.


Create a snapshot, specify a space of 100M, you can view the snapshot information


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9D/wKioL1S18RfASjbNAAIxGzCUCuw793.jpg "style=" float: none; "title=" 38.PNG "alt=" Wkiol1s18rfasjbnaaixgzcucuw793.jpg "/>


Create a mount point, mount the snapshot, BB inside is attached to my original lvm,cc inside is a snapshot, you can find their content is the same



650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/A0/wKiom1S18FWBjzFhAAIwSswAW-I196.jpg "style=" float: none; "title=" 39.PNG "alt=" Wkiom1s18fwbjzfhaaiwsswaw-i196.jpg "/>


Write a file in BB and CC to see, no problem


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9D/wKioL1S18SXR9HtLAAGbTqTDyRQ932.jpg "style=" float: none; "title=" 40.PNG "alt=" Wkiol1s18sxr9htlaagbtqtdyrq932.jpg "/>


The contents of the snapshot can be re-written back to the original LVM via Lvconvert

For example


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/A0/wKiom1S18FyjOsyoAAAuRD3qfTs712.jpg "style=" float: none; "title=" 42.PNG "alt=" Wkiom1s18fyjosyoaaaurd3qfts712.jpg "/>

After the restart found/bb inside the manually created files are not, but the contents of the snapshot are written in


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/A0/wKiom1S18FvBVxpUAABidCs51tU197.jpg "title=" 41.PNG "Style=" Float:none; "alt=" wkiom1s18fvbvxpuaabidcs51tu197.jpg "/>


Finally see how soft RAID is configured. RAID fundamentals are not covered, this is it common sense. Windows can set up soft Raid,rhel with similar functionality from the Win2000 start. Personally feel that soft raid is no use, after all, the motherboard almost all support the installation of hard raid, production environment and no one will do a server to do a soft raid, these are configured on the host hard disk or SAN.


Simply look at the creation and deletion of soft raid, the command used is Mdadm


Created a RAID5,

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/9D/wKioL1S18SyATcKEAABNhPE9Stw142.jpg "style=" float: none; "title=" 44.PNG "alt=" Wkiol1s18syatckeaabnhpe9stw142.jpg "/>


View Details

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/9D/wKioL1S18TaCrAG9AAK1EafuZwI149.jpg "style=" float: none; "title=" 45.PNG "alt=" Wkiol1s18tacrag9aak1eafuzwi149.jpg "/>


Can be formatted and mounted


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/9D/wKioL1S18UPgZYZ7AAHYFEw25B8043.jpg "style=" float: none; "title=" 46.PNG "alt=" Wkiol1s18upgzyz7aahyfew25b8043.jpg "/>


Remove Uninstall raid


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/A0/wKiom1S18HmguRGeAACJbLXoMwU203.jpg "style=" float: none; "title=" 47.PNG "alt=" Wkiom1s18hmgurgeaacjblxomwu203.jpg "/>


This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1603883

RHCE Learning Notes-LVM logical volumes

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.