LVM logical volume manager

Source: Internet
Author: User

The function is to dynamically allocate disk partitions and make multiple partitions or physical hard disks as a logical volume (equivalent to a logical hard disk)
It allows you to expand or reduce the disk or partition capacity at will. The implementation of LVM is to combine physical disks or physical partitions into independent parts through software.
VG (Virtual Disk), then divide the VG into LV (Virtual partition), format and mount it to the system for use.


Configuration method in Linux:
1. Convert sda2 sdb1-2 to LVM type Partition
Command fdisk/dev/sda input t (that is, the conversion type) Input 2 (that is, select the second partition, that is, sda2) Input 8e (that is, select the partition type)
Input w (save and launch)
2. Create a physical volume command: pvcreate/dev/sda; pvcreate/dev/sdb [1-2] (convert the original logical partition sda2 sdb1 sdb2 into an LVM physical volume)
3. Create a volume group command: vgcreate vg0/dev/sda2; vgcreate vg0/dev/sdb [1-2] (the volume group vg0 that combines physical partitions of a single LVM)
4. Run the command "lvcreate-n data-L 500 M vg0" to create an LVM logical volume. The data size is 500 M, and the data source is vg0)
5. format the LVM logical volume data command mkfs. ext3/dev/vg0/data (this can be mounted and used)
6. Expand the logical volume data of LVM to 1000 MB
Command: umount/dev/vg0/data (unmount LVM logical volume data)
Lvextend-L + 500 M/dev/vg0/data (increase LVM logical volume data 500 M)
E2fsck-f/dev/vg0/data; resize2fs/dev/vg0/data (update LVM logical volume data)
Mount-o remount/dev/vg0/data/mnt (re-mount the LVM logical volume data)
7. Reduce LVM logical volume data space to 800 M
Command: umount/dev/vg0/data (unmount LVM logical volume data)
E2fsck-f/dev/vg0/data; resize2fs/dev/vg0/data (update LVM logical volume data)
Lvreduce-L-200 M/dev/vg0/data (reduce LVM logical volume data by 200 M)
Mount/dev/vg0/data/mnt (Remount the LVM logical volume data)
8. Expand the physical volume group vg0 Space
Command: vgextend vg0/dev/sdc1 (added to sdc 1 to physical volume group vg0, sdc1 must be LVM-type partition)
9. Reduce the vg0 space of the physical volume group
Command: umount/dev/vg0/data (unmount all logical volumes of LVM)
Pvmove/dev/sdc1 (move sdc1 data to another volume)
Vgreduce vg0/dev/scb1 (remove the physical volume sdc1 from the vg0 Group of the volume group)
10. Snapshot technology (snapshot technology can save the current status of the disk and restore the disk status when data is lost)
Command: lvcreate-s-L 52 M-n sanp/dev/vg0/data (create LVM logical volume data snapshot sanp, 52M is the data volume size)
Mount/dev/vg0/sanp/mnt (mount to mnt using a sanp snapshot. deleting data on the disk does not affect sanp)
11. Delete LVM Management
Command: umount/dev/vg0/data (unmount all logical volumes of LVM)
Lvremove/dev/vg0/sanp (delete the snapshot logical volume)
Lvremove/dev/vg0/data (delete logical volume)
Vgchange-an vg0 (cancel vg0 activation)
Vgremove vg0 (delete vg0)
Vgscan (used to search for known vg)
Pvscan (view LVM physical volumes)
 
 
 
 
Author "Growth Course"

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.