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

How to understand LVM

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces you how to understand LVM, the content is very detailed, interested friends can use for reference, hope to be helpful to you.

Basic concept

LVM:logical volume manager logical volume management, a mechanism for managing disk partitions

LVM logical volume management encapsulates the underlying physical hard disk abstractly and presents it to the upper system in the form of logical volume. The size of logical volume can be adjusted dynamically without losing existing data. The newly added hard disk will not change the existing upper logical volume, which greatly improves the flexibility of disk management, while mounting the new hard disk directly with fdisk partition requires data migration.

Physical storage medium (The physical media): in this case, the storage device of the system: the hard disk, such as / dev/hda, / dev/sda, etc., is the storage unit at the lowest level of the storage system.

Physical volume (physical volume): a physical volume refers to a hard disk partition or a device that logically has the same function as a disk partition (such as RAID). It is the basic storage logic block of LVM, but compared with basic physical storage media (such as partitions, disks, etc.), it contains management parameters related to LVM.

Volume group (Volume Group): a LVM volume group is similar to a physical hard disk (/ dev/hda) in a non-LVM system and consists of physical volumes. You can create one or more "LVM partitions" (logical volumes) on a volume group, and the LVM volume group consists of one or more physical volumes.

Logical volumes (logical volume): LVM's logical volumes are similar to hard disk partitions (/ dev/hda1) in non-LVM systems, and file systems can be established on top of logical volumes (such as / home or / usr, etc.).

PE (physical extent): each physical volume is divided into basic units called PE (Physical Extents), and PE with a unique number is the smallest unit that can be addressed by LVM. The size of PE is configurable and defaults to 4MB.

LE (logical extent): logical volumes are also divided into basic addressable units called LE (Logical Extents). In the same volume group, the size of LE and PE are the same and correspond one to one.

Understand:

A hard disk (physical storage medium) is formatted as a physical volume (physical volume), and its interior is divided into several PE (physical extent) with a default size of 4m. Then a volume group (Volume Group) is created on the basis of PV. One or more PV can be added to the VG. VG is like a space pool. If there are as many PV,VG as there are, logical volumes (logical volume) are created based on VG. A logical volume is a number of PE, and then format and mount the LV (treat the LV as a partition)

Basic operation

Implement LVM

Create PV: use the pvdisplay or pvs command to view the created physical volume

Pvcreate hard disk name pvcreate / dev/sdb / dev/sdc

Create a volume group (VG) to add physical volumes to the volume group: view the created volume group through vgdisplay or vgs

Vgcreate Custom VG name PVvgcreate VGName / dev/sdb / dev/sdc to be added

Create logical volumes based on volume groups (LV): use the command lvs or lvdisplay to view the details of lv

Lvcreate-n Custom logical Volume name-L size VG name of the logical volume to be created lvcreate-n LVName-L 3G VGName

Create a file system for the created logical volume (formatted)

Mkfs.ext4 / dev/VGName/LVName

Mount LV

Mount / dev/VGName/LVName / mnt

LVM deletion

The process of deleting a logical volume must be

Unmount-delete lv---, delete vg---, delete pv

Delete LV

Lvremove logical volume name lvremove / dev/vgTest/lvTest

Delete VG

Lvremove logical volume name lvremove / dev/vgTest/lvTest

Delete PV

Pvremove pv name pvremove / dev/sdb / dev/sdc

Stretch VG (PE is not enough, add a new hard drive)

Format the hard drive to be added to VG as PV (may require fdisk to create a new hard disk partition)

Pvcreate / dev/sdd

Adds a new PV to the specified volume group

Vgextend vg name / dev/sdd

View the expanded VG

Vgs

Stretch LV (when VG has free, it will be available after the previous step)

Make sure there is enough free space in the VG

Vgdisplay

Extended logic volume

Lvextend-L + 1G / dev/vgTest/lvTest

Check the size of the expanded lv

Lvdisplay

Update the file system

Resize2fs / dev/vgTest/lvTest

View the updated file system

Df-h on how to understand LVM to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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

Internet Technology

Wechat

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

12
Report