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

Detailed introduction of LVM in Linux

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

Share

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

This article mainly introduces "detailed introduction of LVM in Linux". In daily operation, I believe many people have doubts about the detailed introduction of LVM in Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "detailed introduction of LVM in Linux". Next, please follow the editor to study!

What is LVM?

What is LVM?LVM (Logical Volume Manager) logical volume management? it is a kind of logical collection of one or more hard disk partitions, which is equivalent to a large hard disk to use. When the hard disk space is insufficient, you can continue to add the partitions of other hard disks to it. This is a dynamic management of disk space, which has great flexibility compared with ordinary disk partitions. Ordinary disk partitions are used. When the partition space of a disk is not enough, it can bring a lot of trouble. To some extent, using LVM can solve the problems caused by ordinary disk partitions.

Why use LVM?

LVM is usually used in systems with a large number of disks, but it is also suitable for small systems with only one or two hard drives.

What are the benefits of using LVM in small systems?

Traditional file systems are partition-based, and each file system corresponds to a partition. This approach is intuitive, but not easy to change:

1. Different zones are relatively independent and unrelated to each other, and the space in each zone is easy to be used unevenly, and the space can not be fully utilized.

two。 When a file system / partition is full, it cannot be expanded, so it can only be repartitioned / established, which is very troublesome, or move the data in the partition to another larger partition; or use the space of other partitions by symbolic connection.

3. If you want to merge multiple partitions on the hard disk, you can only use re-partition, which requires data backup and recovery.

When using LVM, the situation is different:

1. Multiple partitions of the hard disk are managed as volume groups by LVM, which can easily add or remove partitions to expand or reduce the available capacity of the volume group and make full use of the hard disk space.

two。 The file system is based on logical volumes, which can be resized as needed (within the volume group capacity) to meet the requirements

3. The file system is built on LVM and can be cross-partition and easy to use.

What are the benefits of using LVM for large systems?

In large systems that use many hard drives, the use of LVM is mainly to facilitate management and increase the expansibility of the system. In a large system with many hard drives of different capacities, it is a skillful task to allocate space to different users, and it is necessary to strike a balance between the needs of users and the actual available space. The space for users / user groups is based on LVM and can be increased at any time as required or adjusted for each logical volume according to usage. When there is not enough space in the system to add a new hard disk, it is not necessary to move the user's data from the original hard disk to the new hard disk, but only to add the new partition to the volume group and expand the logical volume. Similarly, it is possible to use LVM with non-stop service. Transfer user data from the old hard drive to the new hard disk space.

N disks can form a large space VG1, and then partition the required partitions from the VG1.

Partition a portion of the disk space from the remaining space to a partition

In this way, when there is not enough space in a partition, it can increase the disk space used by the partition.

[noun interpretation]

1. PV (Physical Volume): the physical volume, which is at the bottom of LVM, can be a physical hard disk or partition.

2.PP (Physical Extend): physical area, the smallest storage unit that can be used for allocation in PV, which can be specified when creating a PV, such as 1m, 2m, 4m, 8m, 32m, 64m. The PE size that makes up all PV in the same VG should be the same.

3.VG (Volume Group): volume groups, built on top of PV, can contain one or more PV.

4. LV (Logical Volume): logical volume, based on VG, is equivalent to the concept of the original partition. But the size can be changed dynamically.

[create LVM]

1. View the newly added hard drives in the system

2. Partition the disk (create PV) and divide it into two partitions on / dev/sdb

3. Use the fdisk-l command to view the partition table

4. After building the partition, use the pvcreate command to create a PV on the newly created partition

5. Use the vgcreate command to create a VG named vgdate, and add all the newly created PV to vgdate

6. Use the lvcreate-L 500m-n lv01 vgdate command to create a 500m LV named lv01 from VG vgdate

The directory where the first LV we created is / dev/vgdate/lv01

7. Use the mkfs / dev/vgdate/lv01 command to format lv01

8. The file system under Linux needs to be mounted before it can be used. We first use the mkdir / date command to create an empty directory, and then use the mount / deta/vgdate/lv01 / date command to mount our lv01 partition to the / date directory. At this point, our newly created lv can be used.

At this point, the study of "detailed introduction to LVM in Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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