Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Storage management-LVM2

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

LVM2 stands for Logical Volume Manager Version 2

A solution that uses pure software to organize one or more underlying block devices and redefine them as a logical block device;

Use dm module in kernel to realize: dm module can organize one or more bottom block devices into a logical block device; use corresponding command in user space to issue system call to dm module, and then complete the management of post-logical block device

The procedure is as follows:

1. Create and represent physical volumes, PV

Note: If the device used to create the physical volume is a normal partition, be sure to change the partition ID to 8e;

2. Create volume groups based on PV, logical block devices, and specify the size of PE while creating volume groups;

Note: Once the PE size is specified, it is not allowed to change;

3. Create a logical volume in an already created volume group

4. Creating File Systems in Logical Volumes (Advanced Format)

5. Mount

Physical Volume Management Operations:

pvcreate: Create a physical volume

pvdisplay: Displays details of physical volumes

pvs: Displays simple information about physical volumes

pvremove: Remove physical volumes

pvmove: Move all PEs from a physical volume to another physical volume;

Volume group management operations:

vgcreate: Create a volume group

-s #{kKmMgG}: Specify the PE size. If this option is omitted, the default PE is 4M;

vgremove: Delete a volume group

vgextend: Expand the volume group capacity by adding a new pv to the volume group

vgextend VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]

vgrereduce: Reduce the volume group capacity and remove pv from the volume group; before doing this, you should use pvmove to ensure that there are no occupied PEs on the removed pv;

vgreduce VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]

vgdisplay: Displays details of volume groups

vgs: Displays short information about volume groups

Logical Volume Management Operations:

lvcreate: Create a logical volume

-L LV_SIZE(#{kK| mM| gG}): Specify the size of the logical volume, which cannot exceed the capacity of the volume group;

-l #%{FREE| VG| ORIGIN| PVS}: Specifies the percentage of storage units occupied by the logical volume;

LV_NAME: Specifies the name of the logical volume

-i #: When creating a logical volume, create it in stripes and indicate that there are #stripes on this logical volume

-I #: When creating logical volumes, create them in stripes and indicate the size of CHUNK;

lvremove: Remove logical volumes

lvdisplay: Displays details of logical volumes

lvs: Displays short information about logical volumes

lvchange: modify LV status

-ay: Activate logical volume

-an: Deactivate logical volumes

lvextend: extends the space of a logical volume,

Note: Be sure to extend the physical boundary of the logical volume first, and then extend the logical boundary of the logical volume;

When using ext family file systems, the resize2fs command extends logical boundaries;

Expand the physical boundaries of logical volumes:

lvextend -L [+]SIZE /PATH/TO/LVM

If SIZE has +, it means that SIZE space is added to the original logical volume capacity.

If SIZE does not have +: it means to expand the capacity of the logical volume to SIZE space

Expand logical boundaries of logical volumes:

e2fsck /PATH/TO/LVM

resize2fs [-f] /PATH/TO/LVM

lvreduce: Reduce the space of logical volumes

Note: Reduce the logical boundaries of logical volumes first, then reduce the physical boundaries of logical volumes;

When using ext family file systems, the resize2fs command reduces logical boundaries

lvreduce -L [-]SIZE /PATH/TO/LVM

If SIZE has-: it means to reduce SIZE space on the basis of the original logical volume capacity

If SIZE has no-: it means that the capacity of the logical volume is directly reduced to SIZE space

To make it easier to use logical volumes, two symbolic link files are created for/dev/dm-#devices:

/dev/mapper/VG_NAME-LV_NAME --> ../ dm-#

/dev/VG_NAME/LV_NAME --> ../ dm-#

Snapshots of logical volumes:

Snapshots are special logical volumes that are exact copies of the logical volumes that existed at the time the snapshot was taken; snapshots are the most appropriate choice for temporary copies of existing datasets and other operations that require backup or replication. Snapshots are the recording of system information at that time, just like taking pictures. If any data changes in the future, the original data will be moved to the snapshot area. Unchanged areas are shared between the snapshot area and the file system.

Snapshot logical volume creation method

lvcreate -L SNAPSHOT_SIZE -s -p r -n SNAPSHOT_NAME /PATH/TO/ORIGIN_LVM

-L SIZE: Specifies the size of the snapshot logical volume

-s: Create a snapshot logical volume

-p r: logical volume created for processing is read-only

SNAPSHOT_NAME: Specifies the name of the snapshot logical volume

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report