LVM and disk quota management experiments in Linux

Source: Internet
Author: User

Introduction to LVM
LVM is the short name of the Logical Disk volume management (Logical Volume Manager), which is a mechanism for managing disk partitions in a Linux environment, and LVM is a logical layer on top of hard disks and partitions to improve the flexibility of disk partition management.
Introduction to disk quota management
Disk quotas can limit the amount of disk space that a specified user or group of users can use, which is important in Linux server management by avoiding the excessive use of disk space by a user that prevents other users from working properly or even affecting the system's operation.
First , the preparation before the experiment:
First we need to add two hard drives to Linux, it's easy to operate,
1. Double-click the small disc area in the lower-right corner of the virtual machine. Such as

2. In the Virtual Machine Settings window, locate "Hard disk", click "Add",
3. In the Add Hardware wizard window that opens, select Hard disk, click Next,
4. Next, we will select "Next" directly by default, until we finally select "Done", after successfully adding a disk, repeat the above operation and add a hard disk. It is important to note that although we have already completed the operation of adding the hard drive, the hard drive will not be added to the system immediately, it must be restarted for Linux to take effect, and we can restart the system with the Init 6 command.

5. After the reboot is complete, use Fdisk–l to view the disk information, at which point we can see that there are three hard drives in the system.
Although there are two hard disks in the system, they cannot be used directly, and they need to be formatted. Next is the formatted action:
6. The interactive mode command to enter the second disk is Fdisk/dev/sdb

The commonly used directives in interactive mode are n,p,t,w, where n is the new partition, p indicates that the list views the partition information, T represents the change partition type, and w means that the partition setting is saved and exited.
7. Create a new partition and change the partition type

8. View the partition and save the exit

9. Repeat the above steps to perform the same operation on the/DEV/SDC. Enter Fdisk–l to view the disk information, and you can see that disk 2 and disk 3 are partitioned.

Once the preparation is complete, we will be able to perform dynamic reel management and disk quota management operations on the disk. Next is the operation of dynamic reel management.
Ii. Dynamic Reel Management (LVM)
Dynamic Reels: The ability to dynamically adjust disk capacity to improve disk management flexibility. It is important to note that the/boot partition is used for boot files and cannot be created based on LVM. The steps to create dynamic reel management are as follows:
2.1 Creating a physical volume (PV)
Convert Disk 2 and disk 3 partitions to physical volumes

2.2 Creating a Volume group (VG)
A volume group is a combination of one or more physical volumes, and we create the/DEV/SDB1,/DEV/SDC1 2 physical volumes as a volume group with the volume group named Yun

2.3 Creating a logical Volume (LV)
A logical volume is a piece of space that is split from a volume group, used to establish a file system, and you can create a logical volume using the lvcreate command.
Create a logical volume Loga and 15G space from the volume group Yun to Loga,

2.4 Mounting Logical volumes
mount a boot automatically mounted with a manual mount two, automatically mount the partition so that the restart can automatically mount, manual is not. Here we use the automatic mount to implement the logical volume mount, the steps are as follows:
Use the MKFS command to create a EXT4 file system (format operation), then create a mount point, and then edit the/etc/fstab with the Vim editor. The operation of the editor is as follows: First press "G" key in command mode to move the cursor to the last line, then press "O" key to move the cursor to the next line of the cursor, enter "/dev/yun/loga/loga ext4 defaults, 0 0" In this line, press "ESC" key to switch to command mode, then press ":" Key to enter "Wq" Save exit, at this time to implement automatic mount.



After the above steps are completed, enter the Mount–a command to reload the Fatab configuration file, and then enter the DF–H command to view the Mount status

This is where our LVM is created! Next is the disk quota operation.
third, disk quota management
Disk quota management is the management of the specified file system (partition), and his restricted objects are user accounts and group accounts. Here we demonstrate the management of disk quotas for user accounts.
1. Start quota support for the file system, the boot quota support value needs to add Usrquota (user quota), Grpguota (group account quota) Mount parameters.
Modify the/etc/fstab profile information, add Usrquota,grpquota mount parameters,

Enter the Mount–a command to make the configuration file effective, and finally enter the Mount command to see if the Usrquota,grpquota mount parameter is mounted successfully.

2. Detect disk quotas and create quota files
Use the Quotacheck–uvgc/dev/loga command to generate a database file that configures the disk configuration.

At this point we will see the creation failed, because the permissions are not enough, by Setenforce 0 to turn off SELinux, and then use the Quotacheck–uvgc/dev/loga command again to generate the configuration disk configuration database file, the old file is not found, When you view the Mount directory/loga, you can see that there are two more files under the Mount directory, which means that the disk quota file has been created successfully.

2. Create a user test to Loga disk quota management for this user's logical volume group

Use the EDQUOTA-U Test command to configure the user test to use quotas for this disk partition.
The limit type for disk quotas is disk capacity (the default is KB) and the number of files, and there are two limiting methods for each type of restriction, which are soft limit and hard limit. Note that when setting the soft-hard limit, the soft limit value is less than or equal to the hard limit.

3. Use the Quotaon-uvg/loga command to turn on the quota feature

4. To mount directory/loga directory Read and write execute permissions, set file permissions, there are many ways, here we use chmod 777/loga command to set permissions to the file, 777 means that the user, the user belongs to the group, other users have readable, writable, executable permissions

The completion of the above steps indicates that the experiment has been completed, followed by the testing process.
5. Switch user, go to mount directory/loga test

Now start testing the number of files quota, we just set the number of files soft limit is 5, the hard limit is 6, so when we create 6 files there will be a warning prompt, when we create 2 more files will be prompted to exceed the disk quota, and file creation failed.

Delete the file you just created with the RM–RF command.

For the final disk capacity quota test,

Because we just set the disk capacity soft limit is 50k, the hard limit is 100k, so when we create a file size more than 50k there will be a soft limit warning, when our file size exceeds 100k, we will be prompted to exceed the disk quota hard limit warning.
At this point, our experiment has been successfully completed!

LVM and disk quota management experiments in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.