This article focuses on How to build a physical volume, a volume group, and finally a logical volume in Linux? How to generate disk quota files, start disk quotas, limit and use disk quotas.
Here again, I wrote my own handwritten Linux principle document has been uploaded to my download address: Linux principle Interpretation Technical documents
so about the principle in the experiment is not more said, or two days can not write an article ( The pressure mountain is big. ).
The next step is to start by adding three hard disks on the virtual machine (the same size is recommended, otherwise it will cause unnecessary waste), and a reboot is required to take effect after the addition is completed.
1. Add three hard drives. Size is 5G, click Add below to boot add on OK.
650) this.width=650; "style=" Float:none; "title=" Picture 1.png "alt=" wkiom1u_dsxanmj4aaksvfv-qmi082.jpg "src="/http S3.51cto.com/wyfs02/m02/6c/19/wkiom1u_dsxanmj4aaksvfv-qmi082.jpg "/>
2. partitions are created for each hard disk and are set to the LVM Logical volume format.
Use the command fdisk-l to see if you have just added three hard drives, if you can not understand the query results may be read the Linux I upload the principle of data.
650) this.width=650; "style=" Float:none; "title=" Picture 2.png "alt=" wkiol1u_doub1-i5aavfx1dpeey636.jpg "src="/http S3.51cto.com/wyfs02/m00/6c/15/wkiol1u_doub1-i5aavfx1dpeey636.jpg "/>
The following configuration procedures are required for three hard drives. I will explain in detail in the following piece: (In fact, there are all the principles of the data)
First: Use The FDISK/ETC/SDC command enters the partition interface of this hard disk.
Second:n Create the partition, then P is the primary partition, enter a 1~4 within the partition number, the cylinder and the size are used by default, meaning is all allocated.
Third: After the partition is built, enter P to see the meaning.
IV: Input t to change the partition file system,8e is the LVM Logical volume.
650) this.width=650; "style=" Float:none; "title=" Picture 3.png "alt=" wkiom1u_dswjbvxkaavhg3sb6fy658.jpg "src="/http S3.51cto.com/wyfs02/m00/6c/19/wkiom1u_dswjbvxkaavhg3sb6fy658.jpg "/>
when you are finished, enter P to check to make sure it is LVM format, input w Save and exit, the other two hard drives are also operating in this way, but Fdisk entered the hard drive number is not the same.
650) this.width=650; "style=" Float:none; "title=" Picture 4.png "alt=" wkiol1u_dovcr97naagdh3qjx9i075.jpg "src="/http S3.51cto.com/wyfs02/m01/6c/15/wkiol1u_dovcr97naagdh3qjx9i075.jpg "/>
This is the result of viewing again after all creation is complete.
650) this.width=650; "style=" Float:none; "title=" Picture 5.png "alt=" wkiom1u_dsabuf2xaavj4uhit_i665.jpg "src="/http S3.51cto.com/wyfs02/m01/6c/19/wkiom1u_dsabuf2xaavj4uhit_i665.jpg "/>
and then it's creating the physical volume The pvcreate command is used to create a command that can be created at a time, and can be viewed after the completion of the three blocks.
then create the volume group The vgcreate command is the primary command to create a volume group, followed by a volume group name, followed by a hard drive device that needs to be consolidated. The volume group means that several hard drives are logically integrated and can be viewed in detail .
650) this.width=650; "style=" Float:none; "title=" Picture 6.png "alt=" wkiol1u_doya4pokaasnkgvkkfc452.jpg "src="/http S3.51cto.com/wyfs02/m02/6c/15/wkiol1u_doya4pokaasnkgvkkfc452.jpg "/>
Finally, the main use command for creating logical volumes lvcreate, and see more information.
-L: Specifies the size of the logical volume. - N: Specifies the name of the logical volume. The last Face is the volume group name. You can also add them using the Lvextend command if you don't think you have enough space .
650) this.width=650; "style=" Float:none; "title=" Picture 7.png "alt=" wkiom1u_dsab5hbsaajhvxrf5qa069.jpg "src="/http S3.51cto.com/wyfs02/m02/6c/19/wkiom1u_dsab5hbsaajhvxrf5qa069.jpg "/>
format the logical volume you just created as ext4 File system, note the back path .
Then you are ready to mount to the directory you want to mount, using the automatic Mount method.
650) this.width=650; "style=" Float:none; "title=" Picture 8.png "alt=" wkiol1u_doyycsqhaap8om8xbc8685.jpg "src="/http S3.51cto.com/wyfs02/m00/6c/15/wkiol1u_doyycsqhaap8om8xbc8685.jpg "/>
Edit the automatic mount configuration information, the main thing is to support the following The Quota disk quota function needs to be added up .
650) this.width=650; "style=" Float:none; "title=" Picture 9.png "alt=" wkiom1u_dsahj-xpaamhmayhytk657.jpg "src="/http S3.51cto.com/wyfs02/m00/6c/19/wkiom1u_dsahj-xpaamhmayhytk657.jpg "/>
Use df-h to view the Mount status and re-enable the display with Mount-a if the mount point is not displayed .
650) this.width=650; "style=" Float:none; "title=" Picture 10.png "alt=" wkiol1u_doywczhvaafa_uwdy3u141.jpg "src="/http S3.51cto.com/wyfs02/m01/6c/15/wkiol1u_doywczhvaafa_uwdy3u141.jpg "/>
Direct Use Mount Command View permission configuration information for a file directory mount point.
650) this.width=650; "style=" Float:none; "title=" Picture 11.png "alt=" wkiom1u_dser5_onaag_uv-9muy161.jpg "src="/http S3.51cto.com/wyfs02/m01/6c/19/wkiom1u_dser5_onaag_uv-9muy161.jpg "/>
command " Setenforce 0 " Close SELinux security Policy.
Generate a disk quota file in the mounted directory, use the command "quotacheck" where the option- c means create,u and g indicates that user and group account quota information is detected,andv indicates that details are displayed when the command executes.
use after generating quota files ls View the directory, and then use the command " Quotaon/ directory "To open the disk quota function for the directory, use the - P option Indicates whether the view is turned on.
650) this.width=650; "style=" Float:none; "title=" Picture 12.png "alt=" wkiol1u_do3cwvifaarjguoux8u907.jpg "src="/http S3.51cto.com/wyfs02/m02/6c/15/wkiol1u_do3cwvifaarjguoux8u907.jpg "/>
You can now create an account to perform the following tests. Use the useradd command to create an accountwith thepasswd command to generate the password for the account.
Then is the disk quota limit for the user, using the command "edquota-u user name" (Group to add "G - Group name") will enter the configuration interface.
650) this.width=650; "style=" Float:none; "title=" Picture 13.png "alt=" wkiom1u_dsfqu533aahuolloksa036.jpg "src="/http S3.51cto.com/wyfs02/m02/6c/19/wkiom1u_dsfqu533aahuolloksa036.jpg "/>
Edit Zhangsan user's quota limit, only four options need to be modified.
Section 3 a the soft and the 4 hard fields represent the soft limit and rigid limit of disk capacity.
The number of I nodes for both the soft and hard limits is 6 and 7 (do not understand see the principle section).
650) this.width=650; "style=" Float:none; "title=" Picture 14.png "alt=" wkiol1u_do3yykegaafkribkelo633.jpg "src="/http S3.51cto.com/wyfs02/m00/6c/15/wkiol1u_do3yykegaafkribkelo633.jpg "/>
The above configuration is complete, after the confirmation is correct, switches to the ordinary user to carry on the experiment. Switch users can directly use the command su plus the user name, now the directory is not writable, because there is no permissions. The normal user's privileges in the system are very limited. So you have to give normal user permissions first. Use the exit command to return to the root user. Modify permissions using the command chmod.
650) this.width=650; "style=" Float:none; "title=" Picture 15.png "alt=" wkiom1u_dsfcr8ikaaigvd6xyts112.jpg "src="/http S3.51cto.com/wyfs02/m00/6c/19/wkiom1u_dsfcr8ikaaigvd6xyts112.jpg "/>
switch to the normal user again, enter the disk quota to open the directory, although the directory has permissions, but the contents of the directory is still no permissions. Then I create a aaa.txt file in this directory and write the test.
The DD command is mainly used to write tests,if is the specified input device, of The specified output file,BS is the specified data block size, Count is the number of data blocks.
650) this.width=650; "title=" Picture 16.png "alt=" wkiom1u_e1wskfnoaainc9v3fh0339.jpg "src=" http://s3.51cto.com/wyfs02/ M01/6c/19/wkiom1u_e1wskfnoaainc9v3fh0339.jpg "/>
Re-entry Zhangsan Quota edit page, this time is mainly view.
650) this.width=650; "style=" Float:none; "title=" Picture 17.png "alt=" wkiom1u_dsjsvvu7aahwumfoloe851.jpg "src="/http S3.51cto.com/wyfs02/m01/6c/19/wkiom1u_dsjsvvu7aahwumfoloe851.jpg "/>
you can see that it is now written 32KB, I set the soft limit is 30KB, hard limit 50KB,i node used one.
650) this.width=650; "title=" Picture 18.png "alt=" wkiol1u_dttaebtkaaenbavzlti061.jpg "src=" http://s3.51cto.com/wyfs02/ M00/6c/15/wkiol1u_dttaebtkaaenbavzlti061.jpg "/>
To write something again, it is important to note that another file needs to be replaced when the copy is written again, indicating that it has not been written in. But now the I node is not finished, and then Create an empty file, to test the limit of the I node, you can see that when created to the first 5 there has been a warning , but within the soft limit (can also be created) but after the creation of the first 6 , it is not possible to create .
650) this.width=650; "style=" Float:none; "title=" Picture 19.png "alt=" wkiol1u_dpdrivumaaq1fhnjf8w022.jpg "src="/http S3.51cto.com/wyfs02/m02/6c/15/wkiol1u_dpdrivumaaq1fhnjf8w022.jpg "/>
again into the user disk quota information to view, now occupies a total of 48KB of disk space and 6 i nodes .
650) this.width=650; "style=" Float:none; "title=" Picture 20.png "alt=" wkiom1u_dsrwathpaae7nanpnog912.jpg "src="/http S3.51cto.com/wyfs02/m02/6c/19/wkiom1u_dsrwathpaae7nanpnog912.jpg "/>
OK experiment completed,zhangsan User is limited by the disk quota. If you have nothing to welcome the discussion, thank you!
In addition, I would like to say that the principle is still very important. Accessories: please click here!
This article is from the "My World" blog, please be sure to keep this source http://zhang2015.blog.51cto.com/9735109/1640157
Create LVM logical volumes in Linux and limit disk quotas