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 management and disk quota

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

Share

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

Manage LVM logical volumes

I. Overview of LVM

LVM is the abbreviation of Logical Volume Manager (logical Volume Management). It is a mechanism for managing disk partitions in Linux environment.

A common and difficult problem encountered by Linux users when installing Linux operating system is how to correctly evaluate the size of each partition in order to allocate appropriate hard disk space. The common disk partition management method cannot change the size of a logical partition after it has been partitioned. When a logical partition cannot hold a file, the file cannot be stored across multiple partitions because of the limitations of the upper file system. So it can't be put on other disks at the same time. When a partition runs out of space, the solution is usually to use symbolic links, or use a tool to resize the partition, but this is only a temporary solution, not a fundamental solution to the problem. With the emergence of the logical volume management function of Linux, these problems are easily solved, and users can easily adjust the size of each partition without downtime.

Every Linux user will encounter this dilemma when installing Linux: when partitioning the system, how to accurately evaluate and allocate the capacity of each hard disk partition, because the system administrator should not only consider the current capacity of a partition, but also foresee the maximum capacity that may be needed in the future. Because if the estimate is not accurate, the administrator may even have to back up the entire system, clear the hard drive, repartition the hard drive, and then restore the data to the new partition when there is not enough partition.

Although there are many tools to dynamically adjust the disk, such as PartitionMagic, etc., it does not completely solve the problem, because a partition may be exhausted again On the other hand, this requires a reboot of the system, downtime is unacceptable for many critical servers, and for adding new hard drives, when you want a file system that spans multiple hard drives, the partition adjustment program cannot solve the problem.

Therefore, the perfect solution should be to adjust the size of the file system freely under the premise of zero downtime, which is convenient for the file system to span different disks and partitions. Fortunately, the logical volume management (LVM,LogicalVolumeManager) mechanism provided by Linux is a perfect solution.

1. Physical Volume (Physical Volume,PV)

A disk partition or a device that logically has the same function as a disk partition (such as RAID) 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.

two。 Volume Group (Volume Group,VG)

Similar to a physical disk in a non-LVM system, it consists of one or more physical volumes PV. You can create one or more LV (logical volumes) on a volume group.

3. Logical Volume (Logical Volume,LV)

Similar to disk partitions in non-LVM systems, logical volumes are built on top of volume group VG. You can build a file system (such as / home or / usr, etc.) on top of the logical volume LV.

II. LVM management

1. Main command

two。 Main steps

(1)。 Partition the newly added hard disk and first enter the management mode fdisk / dev/sdb

(2)。 Create partition n New p display list

(3)。 Convert to physical volume type, code 8e t conversion type 8e physical volume type code

(4)。 Save and exit after viewing

(6)。 Change the newly added sdb and sdc,sdd to the partition mode.

(5)。 Create the sdb1,sdc1,sdd1 device as a physical volume pvcreate / dev/sd {b.. d} 1

(6)。 View the created physical volume pvscan

(7)。 Create a volume group named mailbox vgcreate mailbox / dev/sd {b.. d} 1

(8)。 View the details of the volume group vgdisplay

(9)。 Create logical volume lvcreate-L 25G-n mbox01 mailbox

(10)。 View logical volume details lvdisplay

(11)。 Create the second logical volume

(12)。 Lvextend-L + 10G / dev/mailbox/mbox01 can be extended when the logical volume capacity is insufficient.

(13)。 Format logical volume mkfs-t xfs / dev/mailbox/mbox01

(14)。 Create a mount point

(15)。 Configure automatic mounting of vim / etc/fstab

(16)。 Perform mount mount-a

In this way, the logical volume is created.

three。 Disk quota

1. Conditions for achieving disk quota

(1)。 Need the support of linux kernel

(2)。 Install xfsprogs and quota packages

Characteristics of 2.Linux disk quota

(1)。 Scope: for the specified file system (partition)

(2)。 Restricted object: user account, group account

(3)。 Type of limit: disk capacity, number of files

(4)。 Restriction method: soft limit, hard limit

3. Steps for disk quota

(1)。 First check whether the kernel meets the quota function rpm-qa | grep xfsprogs

Rpm-ql xfsprogs | grep quota

(2)。 Turn off the enhanced security feature setenforce 0

(3)。 Mount vim / etc/fstab

Enter the command mount to see if the quota function is supported

(4)。 Edit quota settings xfs_quota-x-c''/ opt/mbox2/

(5)。 Change user rights chmod 777 / opt/mbox2/

(6)。 Use su-zhangsan to switch users for node authentication

(7)。 Capacity verification

4. View quota usage xfs_quota-x-c 'report-aib'/opt/mbox2/

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