Linux LVM Insights with case

Source: Internet
Author: User

Lvm

Logical Volume Management LVM is a system tool for hard disks. No matter in Linux or other similar system, it is very useful. Traditional partitions use fixed-size partitioning, which is cumbersome to resize. However, LVM can create and manage "logical" volumes, rather than using physical hard disks directly. The administrator's flexible management of logical volumes can be scaled down and simple to operate without damaging the stored data. You can add a new hard disk to the LVM at will to directly extend the logical volume that already exists. LVM does not require a reboot to let the kernel know that the partition exists.


LVM Online parsing: Http://baike.baidu.com/view/361916.htm?fr=aladdin


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3E/D1/wKioL1PHyA-SOlYHAAGSj4hkxdo755.jpg "title=" QQ picture 20140717205135.jpg "alt=" Wkiol1phya-solyhaagsj4hkxdo755.jpg "/>


LVM only common commands

& nbsp       Create

< Span style= "Color:rgb (0,176,80);" > delete

Physical volume

Pvcreate

Pvdisplay

Pvremove

* *

Volume Group

Vgcreate

Vgdisplay

Vgremove

Vgextend Vgreduce

Logical volumes

Lvcreate

Lvdisplay

Lvremove

Lvextend Lvreduce


Access path to LV:

1,/dev/vg_name/lv_name

Eg:/dev/myvg/mylv

2,/dev/mapper/vg_name-lv_name

Eg:/dev/mapper/myvg-mylv

both of these are symbolic links, pointing to a file of/dev/dm-#


Reduction is dangerous!!!

reduce to Offline

1. Determine the target size after reduction, and ensure that there is enough space in the corresponding target logical volume size to accommodate all the previous numbers how to extend the logical volume:

2, first sanction the file system, and to perform mandatory testing

E2fsck-f

3. Reduce logical boundaries

RESIZE2FS DEVICE

4. Reduce physical boundaries

Lvreduce


DD If=/dev/zero of=/dev/sdb bs=512 count=1


/dev/null: Swallow all the data and discard it directly

/dev/zero: Bubble machine, Spit Zero


DD If=/dev/sdb of=/backup/mbr.backup Bs=1 count=512

Can be used for experimental filling


LVM Test Instructions


Create a disk partition by using FDISK. We need to create 3 2G partitions and do not require the partition to be of the same size. Similarly, partitions need to use the '8e' type to make them available for LVM.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/D4/wKioL1PH0Z2ggSIFAAA6RgJ-r0Q314.jpg "title=" 1.png " alt= "Wkiol1ph0z2ggsifaaa6rgj-r0q314.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3E/D4/wKioL1PH0miiSlOPAAOAe_V33Qk070.jpg "title=" 2.png " alt= "Wkiol1ph0miislopaaoae_v33qk070.jpg"/>


Repeat the above action to create the other two partitions. After partition creation is complete, we should have the following output:

Partx-a/dev/sdb


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3E/D4/wKioL1PH04fD4WBJAAG_Gxu2o80607.jpg "title=" 3.png " alt= "Wkiol1ph04fd4wbjaag_gxu2o80607.jpg"/>


Create physical volume (PV)


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/3E/D5/wKiom1PH01uBCRxfAAG6ZA0lQQ0423.jpg "title=" 4.png " alt= "Wkiom1ph01ubcrxfaag6za0lqq0423.jpg"/>


Create a volume group (VG)


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3E/D5/wKiom1PH1AyjIZI7AAEkZZK8UPM652.jpg "title=" 5.png " alt= "Wkiom1ph1ayjizi7aaekzzk8upm652.jpg"/>


Create a logical volume (LV)


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3E/D5/wKiom1PH1aOADFxuAAHbGUUzHUU738.jpg "title=" 6.png " alt= "Wkiom1ph1aoadfxuaahbguuzhuu738.jpg"/>


Now that the logical volume is ready, we can format and mount the logical volume, just like any other EXT2/3/4 partition!


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3E/D6/wKiom1PH1wuSdQvGAAGJJUbPHSU113.jpg "title=" 7.png " alt= "Wkiom1ph1wusdqvgaagjjubphsu113.jpg"/>

Mount and view


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/3E/D6/wKiom1PH12Dxgl4QAAGOF9jhMec729.jpg "title=" 8.png " alt= "Wkiom1ph12dxgl4qaagof9jhmec729.jpg"/>






This article is from the "Broken Saber" blog, please be sure to keep this source http://90sec.blog.51cto.com/7404127/1439705

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.