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

Disk management: LVM logical volum

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Introduction to LVM

   LVM (Logical Volume Manager logical Volume Management) is the logical volume manager of the Linux operating system.

   LVM sets the partitions of one or more hard disks logically, which is equivalent to a large hard disk to use. When the hard disk space is not enough, you can continue to add the partitions of other hard disks to it. This can realize the dynamic management of disk space and has great flexibility compared to ordinary disk partitions.

Compared with traditional disks and partitions,    provides a higher level of disk storage for computers. It makes it more convenient for system administrators to allocate storage space for applications and users.

Logical volume basic term physical storage medium (The physical media): here refers to the storage device of the system: the hard disk, such as / dev/hda1, / dev/sda, etc., is the storage unit at the lowest level of the storage system. Volume group (Volume Group,vg): a LVM volume group is similar to a physical hard disk 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,lv): LVM's logical volumes are similar to hard disk partitions 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. Create the partition first and set the partition type of LVM

MBR partition creation

Modify MBR partition type

Save exit

Create a GPT partition and modify the partition type

Use the lsblk command to view partitions

Create a physical volume (PV)

Convert all three created disks to physical volume PV

Use the pvs command to view physical volume information

Create a volume group (VG)

Due to the later expansion of volume group space, we first use 2 disks to form a volume group.

Use the vgs command to view volume group information

Create a logical volume (LV)

Create a logical volume test1 of 4G size

Use all the remaining space in the volume group to create a logical volume test2

Use the lvs command to view the created logical volume information

Create a file system

Create an ext4 file system on / dev/vg0/test1

Create a xfs file system on / dev/vg0/test2

Mount the file system to the specified directory

Create a mount directory and mount the disk

Create a file in the mount directory to observe the impact of later expansion and reduction of the file system on data

Logical volume expansion using the vgdisplay check command to see the information of the volume group

It can be found that the free space of the volume group is 0, which needs to be expanded.

Use the vgextend command to add the / dev/sdd1 that did not join the volume group to the volume group to expand the volume group.

After executing the command, use the vgdisplay command to verify whether the volume group has been successfully expanded

Use the lvextend command to expand the logical volume, and use the lvs command to check whether the expansion is successful

Expand the logical volume test1 of the xfs file system

Expand the logical volume test2 of the ext file system

Check to see if files in the file system are missing

Facts have proved that expanding the file system space will not affect the file data.

Logical volume reduction because the xfs file system does not support reduction, so here, taking the ext4 file system as an example, the logical volume test2 needs to be backed up before the file system is reduced to prevent data loss.

Take the mounted devices offline before reducing them.

Reduce the space of the file system before reducing the logical volume

The message here is: you need to do a health check on the file system before reducing the file.

Reduce the space of the file system

Reduce logical volumes

Use the lvs command to view logical volume space changes

Mount the file system and check the internal data

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