Linux LVM Logical Volume detailed

Source: Internet
Author: User

There were new people asking me what was LVM? I said it was an egg roll! A joke, LVM is the meaning of logical volume.

Can not underestimate the role of this LVM, its use is important!

Let me take a look at how LVM works:

To understand the role of logical volumes, first familiarize yourself with the following four concepts:

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/88/B3/wKiom1f_UgyRL3XxAALKmLRtaiY825.png-wh_500x0-wm_3 -wmp_4-s_126707043.png "title=" Qq20161013172109.png "alt=" Wkiom1f_ugyrl3xxaalkmlrtaiy825.png-wh_50 "/>


①pe (physical extension)

②PV (physical volume)

③VG (volume group, also called PE pool)

④LV (Logical volume)

See here, you will certainly say, oops, said too official, do not understand the wood there? Don't worry, please listen to me carefully!

Why do we have to make a logical volume? For a running server, what should you do if there is a sudden shortage of disk space? The general approach must be to shut down, and then add a new large space hard disk, and then the original hard drive data to the new hard disk, and then the boot is OK. I can tell you responsibly that this approach is undesirable. First of all, for an enterprise, the server is running a variety of applications, how can suddenly stop to let you go to add the hard drive, then there is no good solution can not be shut down, but also to achieve the purpose of expanding disk space? This is going to use the LVM technology we're going to talk about next.

Before working on the LVM technology, let's first describe how LVM works. The so-called know it is also necessary to know why, at the outset to status quo.

The biggest function of logical volume is stretching, so-called stretching is to enlarge the space of the logical volume, and then do the format and mount operation can be used. First, the physical hard disk is transferred to a physical volume (PV), the unit in PV is a single PE. The different PV also composes the VG (also called the PE pool), and finally creates the LV (logical volume). LV is based on the existence of VG, LV stretching is obtained from the VG of PE formation.

Below, we start to create LVM:

① Creating PV (physical volume)

Pvcreate/dev/sdb/dev/sdc

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/89/1B/wKioL1gINEvhfhRzAAASHgTliO4249.png-wh_500x0-wm_3 -wmp_4-s_503512557.png "title=" Qq20161020110443.png "alt=" Wkiol1ginevhfhrzaaashgtlio4249.png-wh_50 "/>

Note: After creating the physical volume, we can view it with the following two commands:

⑴pvdisplay

⑵pvs (viewing information relatively simple)


② Create a VG (volume group) and add PV to the volume group

Vgcreate Volume Group name/DEV/SDB/DEV/SDC

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/89/1B/wKioL1gINf-AlesCAAAQid79RKE552.png-wh_500x0-wm_3 -wmp_4-s_733006652.png "title=" Qq20161020111159.png "alt=" Wkiol1ginf-alescaaaqid79rke552.png-wh_50 "/>


Note: After creating a volume group, we can view it with the following two commands:

⑴vgdisplay

⑵vgs


③ Creating a LV (logical volume)
Lvcreate-n Logical Volume name-l space Size volume group name

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/89/1E/wKiom1gIO8XQm8f9AAAPX6SBzAs626.png-wh_500x0-wm_3 -wmp_4-s_1271110052.png "title=" Qq20161020113646.png "alt=" Wkiom1gio8xqm8f9aaapx6sbzas626.png-wh_50 "/>

Note: After you create a logical volume, we can view it with the following two commands:

⑴lvdisplay

⑵lvs


④ Creating a file system for a logical volume

Mkfs.ext4/dev/vgtest/mylv

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/89/1E/wKiom1gIPSyhkknpAAFVyvqRBFg832.png-wh_500x0-wm_3 -wmp_4-s_708534536.png "title=" Qq20161020114233.png "alt=" Wkiom1gipsyhkknpaafvyvqrbfg832.png-wh_50 "/>


⑤ Mount use

Mount/dev/vgtest/mylv/mnt

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/89/1B/wKioL1gIPzmzwkmJAABVDJrbdIM361.png-wh_500x0-wm_3 -wmp_4-s_21708754.png "title=" Qq20161020115126.png "alt=" Wkiol1gipzmzwkmjaabvdjrbdim361.png-wh_50 "/>




To delete LVM:

① Uninstall

Umount/mnt

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/89/1B/wKioL1gIP-ygD6MTAABHgVi-ADA465.png-wh_500x0-wm_3 -wmp_4-s_2522363686.png "title=" Qq20161020115430.png "alt=" Wkiol1gip-ygd6mtaabhgvi-ada465.png-wh_50 "/>


② Deleting a logical volume (LV)

Lvremove/dev/vgtest/mylv

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/89/1E/wKiom1gIQGqD-0aVAADb9JOsuRM870.png-wh_500x0-wm_3 -wmp_4-s_45579095.png "title=" Qq20161020115634.png "alt=" Wkiom1giqgqd-0avaadb9josurm870.png-wh_50 "/>


③ Deleting a volume group (VG)

Vgremove Vgtest

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/89/1E/wKiom1gIQL7TQUaFAADeKhvumtk901.png-wh_500x0-wm_3 -wmp_4-s_2377612031.png "title=" Qq20161020115800.png "alt=" Wkiom1giql7tquafaadekhvumtk901.png-wh_50 "/>④


④ removing PV

Pvremove/dev/sdb/dev/sdc

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/89/1B/wKioL1gIQSGD1gLSAADQuQfTf7s357.png-wh_500x0-wm_3 -wmp_4-s_96957606.png "title=" Qq20161020115936.png "alt=" Wkiol1giqsgd1glsaadquqftf7s357.png-wh_50 "/>



This article is from the "Brother Hong Linux World" blog, so be sure to keep this source http://zhengkangkang.blog.51cto.com/12015643/1863800

Linux LVM Logical Volume detailed

Related Article

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.