当前位置:网站首页>LVM and disk quota
LVM and disk quota
2022-07-24 06:28:00 【Aka · Brooklyn Fairy】
Catalog
LVM The basic concept of mechanism
PV(physical volime Physical volume )
Two , LVM Command management of
3、 ... and ,LVM Application example
1, What is disk quota , What is the use of disk quotas
3, Characteristics of disk quota
1 Start quota support for the file system
2, Edit quota settings for user and group accounts
6、 ... and , Disk quota instance
One ,LVM summary
Logical volume management
It can dynamically adjust the disk capacity while keeping the existing data unchanged , So as to improve the flexibility of disk management
/boot Partitions are used to store boot files , Cannot be based on LVM establish
LVM The basic concept of mechanism
PV ( Physical volume )
VG ( The volume group )
LV ( Logic volume )
PV(physical volime Physical volume )
The physical volume is LVM The basic storage device of the mechanism , It usually corresponds to an ordinary partition or the whole disk . When creating a physical volume , A reserved partition will be created at the head of the partition or hard disk , Used to record LVM Properties of , And divide the storage space into the default size of 4MB The basic unit of . To form a physical volume , Physical volumes generally use the device file name directly , Such as /dev/sdb1./dev/sdb2./dev/sdd etc.
VG ( The volume group )
An entity consisting of one or more physical volumes , Volume group , Dynamically add or remove physical volumes from each volume group . Many physical volumes can be grouped into different volume groups , The name of the volume group is user-defined .
LV( Logic volume )
Logical volumes are built on top of volume groups , Not directly related to physical volumes , Each volume group is a whole , Cut out a small space from the whole as the basis for users to create file systems , This small space is called logical volume usage .
Two , LVM Command management of
| function | Physical volume management | Volume group management | Logical volume management |
| Scan scanning | pvscan | vgscan | lvscan |
| Create establish | pvcreate | vgcreate | lvcreate |
| Display Show | pvdisplay | vgdisplay | lvdisplay |
| Remove Delete | pvremove | vgremove | lvremove |
| Extend Expand | vgextend | lvextend | |
| Reduce Reduce | vgreduce | lvreduce |
pvcreate Equipment I Equipment II
vgcreate Volume group name Equipment I Equipment II
lvcreate -L Capacity size -n Logical volume name Volume group name
lvextend -L Capacity size /dev/ Volume group name / Logical volume name
technological process
1, Hard disk partition
fidsk dev/sdb fdisk .dev/sdc2, Create a physical volume
Create a physical volume sdb1,sdc1
pvcreate /dev/sdb1 /dev/sdc13, Create a volume group
vgcreate web_kgc /dev/sdb1 /dev/sdc14, Create logical partitions
lvcreate -L Capacity size -n Logical volume name Volume group name
lvcreate -L +10G -n mail——store web—kgc
5, Create file system
mkfs -t xfs /dev/web_kgc/nizb6, Mount Directory
mount /dev/web_kgc/nizb/home7, Permanently mount
echo "dev/web_kgc/nizb /home xfs defaults 0 0 " >> etc/fstab
3、 ... and ,LVM Application example
Shut down and add two pieces 20G Of disks , be used for LVM Partition

Partition the disk , And change it to LVM Format .

Create a physical volume

Set up a volume group
![]()
Create logical volumes

pvdisplay Check the information

Create file system Format file

Mount


Expand logical volume space ( add to 5G)

Refresh xfs file system

df -hT Check whether it has been added

Four , Disk quota overview
1, What is disk quota , What is the use of disk quotas
When Linux When the root partition runs out of disk space ,Linux The operating system will no longer be able to create new files , At the same time, the service program may crash , Failure of system startup .
In order to avoid the problem of insufficient disk space in the server , The disk quota function can be enabled , For the user in the specified file system ( Partition ) Disk space used in 、 Limit the number of files , To prevent individual users from occupying a large amount of disk space maliciously or unintentionally , So as to maintain the stability and sustainability of the system storage space
stay cento8 In the system , Different file systems use different disk quota configuration management T have . for example ,XFS File system pass xfs__quota Tools to manage ;ExT3/4 The document is passed quotaT Tools for management .
2, Disk quota
Conditions for achieving disk quota
need Linux The kernel support
install xfsprogs and quota software package
Linux Characteristics of disk quota
Scope of action : For the specified partition
Restricted objects : The user account , Group account number
Type of restriction : Disk capacity , Number of documents
Limiting method : Soft limit , Hard limit
3, Characteristics of disk quota
1. The role of disk quotas xfs_quota
Set the disk quota function , Only on the specified file system ( Partition ) Effective within , When users use other file systems without quotas , There will be no restrictions .
2. disk f The quota t Restricted objects for xfs_quota
Mainly for the user account specified in the system 、 Group account restrictions , Users or groups without quotas will not be affected . After setting the quota for the group account , The base disk capacity used by all users in the Group 、 The total number of files cannot exceed the limit .
3. The restriction type of the disk
Disk capacity : Limit the disk data blocks that users can use (Elock) size , That is, limit the size of disk space , The default unit is KB Number of documents : Limit the number of files that users can have . stay Linux Operating system , Each file has a corresponding Suning mark . be called i node (Inode) Number , This number is unique in the same file system , therefore xfs_quota Pass restrictions i To limit the number of files .
4. How to limit disk quota
Soft limit : Specify a soft quota value, such as ( 480MB disk space 、180 File )), During the grace period set by the week ( The default is seven days ) It is allowed to temporarily exceed this limit , But the system will give a warning message .
Hard limit : Specify a hard quota value ( Such as 500MB Disk room 、200 File ), Is the limit that users are absolutely forbidden to exceed , When the hard limit is reached , The system will also give a warning and prohibit further writing data . The quota value of hard limit should be greater than the corresponding soft limit value , Otherwise, the soft limit will fail .
As can be seen from the above description , In the actual process of implementing disk quotas , Only with ( Or group )、 file system ( Partition ) And quota values meet the quota conditions , xfs_quota Will limit the operation
5, Start disk quota support
1 Start quota support for the file system
add to usrquota,grpquota Mount parameters
2, Edit quota settings for user and group accounts
Use xfs_quota Command to edit quota settings
[[email protected] /]# xfs_quota -x -c 'limit -u bsoft=40M bhard=80M isoft=8 ihard=10 jie' /saryn/
Common options
| -x | Indicates start expert mode , In the current mode, it is allowed to modify the quota system, so the management commands are available |
| -c | Means to directly call the management command |
| -u | Specify user account and object |
| -g | Specify the group account object |
Limit field
| bsoft | Set the soft limit value of disk capacity ( The default is KB) |
| bhard | Set the hard limit value of disk capacity ( The default is KB) |
| isoft | Set the soft limit value for the number of disk files |
| ihard | Set the hard limit value for the number of disk files |
3, Disk quota steps
1 Check if it is installed xfsprogs and quota software package
yum -y install quota
yum -y install xfsprogs2 Mount the file system in a way that supports quota function
Add mount parameters “usequota,grpquota” Used to increase users , Group quota function support or

3 Edit quota settings for user and group accounts
[[email protected] /]# useradd jie
[[email protected] /]# echo "123123" | passwd --stdin jie
Change user jie Password .
passwd: All authentication tokens have been successfully updated .
4, Verify the disk quota function
chmod 777 /njzb_xm
su jie
cd /njzb_xm Verify disk capacity permissions
dd if=/dev/zero of=/njzb_xm/kgc.txt bs=10M count=12 Verify that the number of disk files exceeds the limit
touch {1..7}.txt
touch test{1..9}.txt
dd The command is a device conversion and continuous replication command
“if=” Specify the output device ( Or document )
“of=” Specify the output device ( Or document )
“bs=” Specifies the size of the read data block
“count=” Specify the number of read data blocks
/dev/zero" zero " Device file , You can provide empty characters indefinitely . It is often used to generate a file of a specific size
5, View disk quota
xfs_quota -x -c 'report - abih'
View disk quota
report Common options :
-u: View for users
-g: View groups
-a: View quota usage reports for all available partitions
-b: Check disk capacity
-i: View the number of files
6、 ... and , Disk quota instance
First installation xfsprogs and quota Two quota tools 
Mount the file system in the way of the previous quota function ,
Add mount parameters “usrquota,grpquota” Used to add support to users , Support for group quota function [[email protected] /]# xfs_quota -x -c 'limit -u bsoft=40M bhard=80M isoft=8 ihard=10 jie' /saryn/
![]()

Create user 
Set quotas for user and group accounts 
Verify the disk quota function
Give permissions and change users 
Go to this directory , Because the soft link for creating files is set to 8, The hard link is 10, So the first 11 Cannot create 
The next experiment , disk space , I need to use ddif Write something into it , First write 10M Write three times , No problem found 
Next , direct 90M More hard links than this disk 
Next, let's experiment with creating folders , It is found that the quota has been reached , could not be built 
View disk quota 
test
useradd lisi
echo "123456" | passwd --stdin lisi
xfs_quota -x -c "limit -u bsoft=80M bhard=100M isoft=8 ihard=10 lisi" /home/ky21
xfs_quota -x -c "report -aibh"
chmod -R 777 /home/ky21/
su lisi
cd /home/ky21
dd if=/dev/zero of=/home/ky17/njzb.txt bs=10M count=12
touch ky21,.txt
rm -rf ./*
touch {1..10}.txt
touch 11.txt
7, summary
Physical volume management
Volume group management
Logical volume management
Scope of disk quota 、 Restricted objects 、 Type of restriction 、 Limiting method
Disk quota management
边栏推荐
- MySQL从基础到入门到高可用
- RAID5和LVM组合使用
- Flink function (1): rich function
- UE4 reload system 1. basic principle of reload system
- Ia note 1
- 手动安装Apache
- Leetcode sword finger offer jz25 merges two sorted linked lists
- jz47 礼物的最大价值(动态规划思路)
- TensorFlow-GPU 安装 -- 056
- The public network uses Microsoft Remote Desktop remote desktop to work remotely at any time
猜你喜欢
![[218] what are the advantages and disadvantages of CS architecture and BS architecture and data on the server and client?](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[218] what are the advantages and disadvantages of CS architecture and BS architecture and data on the server and client?

Use and principle of spark broadcast variable and accumulator

XML parsing

Do not rent a server, build your own personal business website (how to buy a domain name)

MySQL from basic to entry to high availability

List of problems in the re disk guidance of the project

Heap overflow of kernel PWN basic tutorial

ip作业(1)

Ia class summary (2)

【218】CS架构和BS架构以及数据放在服务端和客户端的利与弊?
随机推荐
Ia class summary (1)
Do not rent servers, build your own personal business website (3)
Machine learning & deep learning introduction information sharing summary
不租服务器,自建个人商业网站(3)
Work summary of a test Manager / Test Supervisor / test director
公网访问内网IIS网站服务器【无需公网IP】
[226] instructions for Wireshark parameters
NTP error: no server suitable for synchronization found
Unity (II) more APIs and physical engines
测试经理/测试组长/测试主管面试题
LuckyFrameWeb测试平台(一款支持接口自动化、WEB UI自动化、APP自动化,并且支持分布式测试的全纬度免费开源测试平台)
List of problems in the re disk guidance of the project
Data warehouse and data warehouse modeling
[251] common test tools
三分钟记住20道性能测试经典面试题
力扣986.区间列表的交集
IP作业(6)
Homework in the second week
Heap overflow of kernel PWN basic tutorial
TensorFlow-GPU 安装 -- 056