Disk quotas and online extensions in Linux

Source: Internet
Author: User
Tags set time disk usage

Operating Environment: CENTOS7

One, disk quotas

(1) Introduction

Disk quotas are the limits that administrators set to use disks for normal users, and each user can only use limited disk space and the administrator sets the disk quota. You can clearly understand the disk usage of each ordinary user, to prevent some users from wasting disk space causing other users to not work properly, in the LIUNX system we use the Super Administrator root user to configure the disk quota, you can do the user or group file size limit or limit the number of files.

Restrictions can be divided into two types:

    • Soft limit: When a user or group allocates more space than the current capacity can be exceeded within a certain grace period, the system will issue a warning, but the system will force the space to be reclaimed after the time has expired.

    • Hard limit: Data can no longer be stored when a user or group has allocated a full space.

(2) Enable and use disk quotas

Because the file system is different, the way to enable disk quotas is different, so say it separately here.

    • EXT4 File System

1, new partition, formatted as EXT4 file system, mount to/myquota this directory

FDISK/DEV/SDB (partition the SDB hard drive)

2, open quota, generate quota database

Vim/etc/fstab (Modify configuration file, add Usrquota and Grpquota) after modifying the configuration file requires a re-mount to take effect, can be mounted after the Mount command to see if it takes effect.

Quotacheck-cugm/myquota (Generate quota database)

Quotaon/myquota (Open quota)

3, configuration Quota

Edquota-u Libai (Configure user's disk quota)

Quota-v Libai (View user's limits)

Repquota-v/myquota (View the limit set by the current directory where the user created the file to be displayed)

Quota-g Tangchao (disk quota for groups, set quota for group, additional group settings should be set, while the directory to set Sgid permissions only makes sense)

    • XFS File System

      Initialize the file system by command MKFS.XFS/DEV/SDX, configure it in the/etc/fstab file, and mount it (basically the same as the EXT4 system configuration)

Xfs_quota-x-C "xxxx" (-X Start admin mode-C followed by command) Xfs_quota-x-C "limit-u bsoft=60m bhard=100m Lihei"/myquota (set disk limit for user Lihei)

Xfs_quota-x-C "print" (see which quota are turned on in the current XFS system)

Xfs_quota-x-C "Report-ugibh"/myquota (view quota configuration in this directory, U: User g: Group I:inode B: Block device H: Human readable language)

Xfs_quota-x-C "Timer-u-B 10days"/myquota (set time)

Xsf_quota-x-C "State" (View set time)

Second, online expansion

When the size of the company is getting bigger and bigger, the hard disk occupies more and more big, this time we need to expand the hard disk capacity, but the actual mountain most companies are not allowed to expand offline, so the emergence of logical volume solves this problem.

1, the creation of LVM

(1) Prepare the hard disk or hard disk partition (set to 8e).

(2) Create physical volume PV (can be easily viewed via PVS, pvdispliy detailed view)


(3) Create a volume group VG

Vgcreate vgfan/dev/sdb1/dev/sdb2 (VGs vgdisplay Simple View and Detailed view)

(4) Creating a logical volume LV

Lvcreate-l 500m-n Lvfan Vgfan

(5) Initialize the file system and mount it

2 Online Extensions

    • when the VG volume group capacity is sufficient

Lvextend-l +2g/dev/vgfan/lvfan

The file system needs to be extended by the DF command to see whether the current mount size or the original size

Resize2fs/dev/vgfan/lvfan (You can also add-r directly in the previous step)

    • When VG capacity is not enough

      You need to expand the volume group VG before you expand the LV


Disk quotas and online extensions in Linux

Related Article

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.