Linux study Notes-LVM management

Source: Internet
Author: User
1. LVMLVM is short for logical disk volume management (LogicalVolumeManager). it manages disk partitions in Linux. LVM is a logical layer built on hard disks and partitions, to improve the flexibility of disk partition management. You can use the LVM system administrator...
1. LVM is short for Logical Volume Manager (LVM). It is a mechanism for managing disk partitions in Linux, LVM is a logical layer built on hard disks and partitions to improve the flexibility of disk partition management. The LVM system administrator can easily manage disk partitions. for example, you can connect several disk partitions to an entire volume group to form a storage pool.
2. basic terms of LVM # The physical media refers to The storage devices of The system: hard disks, such as/dev/hda1 and/dev/sda, is the storage unit at the lowest layer of the storage system. Www.2cto.com # physical volume refers to a hard disk partition or a device (such as RAID) with the same functions as a disk partition logically. it is the basic storage logical block of LVM, however, compared with basic physical storage media (such as partitions and disks), it contains management parameters related to LVM. # Volume Group (Volume Group) an LVM Volume Group is similar to a physical hard disk in a non-LVM system and consists of physical volumes. You can create one or more "LVM partitions" (logical volumes) on the volume group. The LVM volume group consists of one or more physical volumes. # Logical volume (logical volume) the logical volume of LVM is similar to the hard disk partition in a non-LVM system. a file system (such as/home or/usr) can be created on the logical volume ). # PE (physical extent) each Physical volume is divided into basic units called PE (physical Extents). PES with unique numbers are the smallest units that can be addressable by LVM. The PE size is configurable. the default value is 4 MB. # LE (logical extent) Logical volumes are also divided into the addressable basic units called LE (logical Extents. In the same volume group, the LE size and PE are the same and one-to-one correspondence.
3. create and manage LVM
(1) install LVM software # rpm-ivh lvm ..... I386.rpm (2) create a partition using a partition tool (such as fdisk) to create an LVM partition. the method is the same as that for creating other general partitions. The difference is that the LVM partition type is 8e. (3) the command for creating a physical volume to create a physical volume is pvcreate. This command is used to create all partitions or disks to be added to the volume group as physical volumes. The command to create the entire disk as a physical volume is: # pvcreate/dev/hdb the command to create a single partition as a physical volume is: # pvcreate/dev/hda5 www.2cto.com (4) run the vgcreate command to create a volume group. create a physical volume created using pvcreate as a complete volume group: # The first parameter of the vgcreate web_document/dev/hda5/dev/hdb vgcreate command is to specify the logical name of the volume group: web_document. The following parameter specifies all partitions and disks that you want to add to the volume group. In addition to creating a volume group web_document, vgcreate also sets a 4 mb pe (4 MB by default ), this indicates that all logical volumes created on the volume group are expanded or reduced in 4 MB increments. Because of the kernel, the PE size determines the maximum size of the logical volume. the 4 mb pe determines that the maximum size of a single logical volume is 256 GB, if you want to use a logical volume larger than GB, specify a larger PE when creating the volume group. The PE size ranges from 8 KB to 512 MB, and must always be a multiple of 2 (use-s to specify. for details, see man vgcreate ). (5) to activate a volume group immediately, instead of restarting the system, you can use vgchange to activate the volume group: # vgchange-a y web_document (6) add a new physical volume to the volume group. when the system installs a new disk and creates a new physical volume, you need to add it to an existing volume group, run the vgextend command: # vgextend web_document/dev/hdc1 (/dev/hdc1 is the new physical volume) (7) to delete a physical volume from a volume group, you must first confirm that the physical volume to be deleted is not in use by any logical volume, you need to run the pvdisplay command to check the information of a physical volume. if a physical volume is being used by a logical volume, you need to back up the data of the physical volume to another place and then delete it. The command to delete a physical volume is vgreduce: # vgreduce web_document/dev/hda1 (8). the command to create a logical volume is lvcreate: # lvcreate-L1500-n www1 web_document this command creates a logical volume named www1 and the size is mb on the volume group web_document, the device entry is/dev/web_document/www1 (web_document is the volume group name and www1 is the logical volume name ). If you want to create a logical volume that uses all the volume groups, you must first check the number of PES in the volume group, and then specify: # vgdisplay web_document | grep "Total PE" Total PE 45230 www.2cto.com # lvcreate-l 45230 web_document-n www1 (9) after creating a file system, you can load and use it: # mkdir/data/wwwroot # mount/dev/web_document/www1/data/wwwroot (10) before deleting a logical volume, you must detach it and then delete it: # umount/dev/web_document/www1 # lvremove/dev/web_document/www1lvremove -- do you really want to remove "/dev/web_doc Ument/www1 "? [Y/n]: ylvremove -- doing automatic backup of volume group "web_document" lvremove -- logical volume "/dev/web_document/www1" successfully removed (11) to expand the logical volume size, LVM provides the ability to easily adjust the logical volume size. the command to expand the logical volume size is lvcreate: # lvextend-L12G/dev/web_document/volumes -- extending logical volume "/dev/web_document/www1" to 12 GBlvextend -- doing automatic backup of volume group "web_document" lvextend -- logical volume"/ The command above dev/web_document/www1 "successfully extended expands the size of the logical volume www1 to 12 GB. # Lvextend-L + 1G/dev/web_document/www1 www.2cto.com lvextend -- extending logical volume "/dev/web_document/www1" to 13 GBlvextend -- doing automatic IC backup of volume group "web_document" lvextend -- logical volume "/dev/web_document/www1" successfully extended (12) to reduce the logical volume size, you can use lvreduce to achieve the logical volume capacity. you also need to first uninstall the file system: # umount/data/wwwroot # resize_reiserfs-s-2G/dev/web_document/www1 # lvreduce-L-2G/dev/web_document/www1 # mount-t reiserfs/dev/web_document/www1/data/ wwwroot
LVM has good scalability and is very convenient to use. You can easily adjust the volume Group and logical volume size to further adjust the file system size. Author GNU sleep
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.