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

LVM logical Volume Manager

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

Lvm:logical volume manager logical volume manager, through DM module device mapping components, can organize one or more underlying block devices into a logical device module.

Functional features: it can be dynamically expanded and reduced without affecting the data content in the disk.

Disadvantages: lv is controlled by software, not directly stored on physical devices, if there is data corruption is not easy to recover, the real use should be placed on the redundant raid.

The process of creating a lvm:

If there is a hard disk device or a partition at the bottom, or a RAID is in or based on any block device, and now the partition is made into a physical volume PV (capable of self-storage device), we can divide the storage space provided in the PV into multiple independent storage units on a lower unit, and combine the storage units on a high level to form a component. We become the volume group VG, which can contain multiple physical volumes. All available space of the volume group is provided by the physical volume PV. The volume group is similar to extended partitions and cannot be used directly. It needs to be partitioned into logical partitions and can be mounted in format. Therefore, we have to create LV components on the basis of VG. LV is the real logical volume and can only be used for formatted mount. Lv can be expanded and reduced across multiple PV. There is also a concept of blocks, that is, PE,PE is created when the VG is created, and the default size is 4m. If the VG has been created, you cannot modify the size of the PE. You can only recreate the VG and modify the PE. If the PE has been assigned to the LV, then the PE is called LE.

PV management tools

An example of the creation process:

1. Create three partition sizes of 5G and adjust the partition id to 8e

Create a physical volume PV: pvcreate / dev/sda5

Pvcreate / dev/sda6

Pvdisplay: viewing details of pv volum

Create a volume group VG: vgcreate-s 16m testvg / dev/sda5

Extend vgextend testvg / dev/sda6

Vgdisplay: check whether the size is right or not

Create logical volume LV: lvcreate-L 4G-n testlv testvg

Ls / dev/mapper check testvg-testlv exists, you can format the mount to use

Format: mke2fs-t ext4-L TESTLV / dev/testvg/testlv

Mount: mount / dev/testvg/testlv / mnt

Lv extension: lvextend-L 5G / dev/testvg/testlv extends directly to 5G

Df-h: view changes in disk space

Expand all usage spaces: resize2fs / dev/testvg/lv

Lv reduction: umount / mnt

E2fsck-f / dev/testvg/testlv forced detection and repair

Resize2fs / dev/testvg/testlv 3G

Lvreduce-L 3G / dev/testvg/testlv

Mount / dev/testvg/testlv / mnt

Create a snapshot: lvcreate-s-L 512m-n testlv-snap-p r / dev/testvg/testlv

Mount / dev/testvg/testlv-snap / user

Delete snapshot: umount / user

Lvremove / dev/testvg/testlv-snap

Delete LV,VG,PV: umount / user

Remove lv: lvremove / dev/testvg/testlv

Remove VG: vgremove testvg

Remove PV: pvremove / dev/sda5

Pvremove / dev/sda6

Ps: the amount of data in the original volume should not exceed the size of the snapshot volume. When the snapshot volume was first created, it was empty. When it was opened, all the files in it actually provided another access to the original volume through the snapshot volume. Once the data on the original volume changes, in order to ensure that the snapshot volume can access the state created before the snapshot volume, we must copy a copy to the snapshot volume. For temporary storage, so that the timestamps of the data accessed through the snapshot volume are all in the state before the start. At this time, I need to copy all the data quickly through the timestamp and save it as a copy to another backup device. Once the replication and backup is completed, the snapshot volume will complete the task, and then restore the backed-up data to the original volume when you want to restore it.

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

Network Security

Wechat

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

12
Report