Set a specific disk space size for Linux host users--ubuntu12.04 configure disk quotas actual combat configuration

Source: Internet
Author: User

Using the software: quota

Operating system: Ubuntu 12.04_x86_64

For partitions: Users under/home


First, install the quota


# Apt-get Install-y Quota


Second, configure disk quota partition


Configure the device catalog to support the appropriate quota

# Vi/etc/fstab in effect after reboot

/dev/sda7/home EXT4 Defaults,usrquota,grpquota 1 2


reproduce mount/home partition

#mount-O Remount,usrquota,grpquota/home


Test quota

#quotacheck-avug

Quotacheck-auvg

Quotacheck:quota for users are enabled on Mountpoint/home so Quotacheck might damage the file.

Turn quotas off or use-f to force checking.


#quotacheck-avug-f

Quotacheck:cannot remount filesystem mounted on/home read-only so counted values might is right.

Please stop the programs writing to filesystem or USE-M flag to force checking.


# quotacheck-auvg-f-M

Quotacheck:scanning/dev/disk/by-uuid/52bce451-c00a-4655-b7c4-4ed911361be6 [/] quotacheck:lstat Cannot stat '//var/ Lib/lightdm/.gvfs ': Permission denied

Guess you ' d better run fsck first!

Exiting ...


# fsck

Fsck from Util-linux 2.20.1

E2fsck 1.42 (29-nov-2011)

/DEV/SDA1 is mounted.


WARNING!!!   The filesystem is mounted. If you continue ***will***

Cause ***severe*** filesystem damage.


Do you really want to continue<n>? Yes


/dev/sda1:recovering Journal

Clearing orphaned inode 291185 (Uid=0, Gid=0, mode=0100640, size=1074)

Clearing orphaned inode 291988 (Uid=0, Gid=0, mode=0100640, size=62)

Clearing orphaned inode 535083 (uid=104, gid=111, mode=0100600, size=1)

Clearing orphaned inode 793605 (uid=104, gid=111, mode=0100664, size=2028)

Setting free inodes count to 1011177 (was 1011199)

Setting Free Blocks count to 3061839 (was 3061776)

/dev/sda5:clean, 234007/1245184 files, 1918641/4980480 blocks


There are two ways of doing this:

Method 1: Solve the problem quickly without affecting the use of system services

#reboot

Act 2: End the process being used

#fuser-M/home

10334rce 10665rce 10843rce

#ps-aux | grep 10334

000 4753 0.0 0.0 557828 23976? Sl 15:35 0:00/usr/bin/python/usr/lib/unity-scope-video-remote/unity-scope-video-remote


#quotacheck-avug

Quotacheck:quota for users are enabled on Mountpoint/home so Quotacheck might damage the file.

Turn quotas off or use-f to force checking.

At this point, execute the QUOTACHECK hint, plus the-f force


#quotacheck-avug-f

QUOTACHECK:SCANNING/DEV/SDA7 [Home] Done

Quotacheck:checked 236 directories and 1225 files


#ll/home/

Total 52

Drwxr-xr-x 6 root root 4096 May 11 15:39./

Drwxr-xr-x root root 4096 May 10 14:07. /

-RW-------1 root root 7168 may 15:39 Aquota.group

-RW-------1 root root 7168 may 15:39 Aquota.user


Third, open disk quotas


The following error is found after using the #quotaon-auvg command

#quotaon-AUVG

Quotaon:using/home/aquota.group On/dev/sda7 [Home]: Device or resource busy

Quotaon:using/home/aquota.user On/dev/sda7 [Home]: Device or resource busy


This closes the quota

#quotaoff-A


Replay on to show that the disk quota for the home partition has been completed

#quotaon-AUVG

/DEV/SDA7 [Home]: Group quotas turned on

/DEV/SDA7 [Home]: User quotas turned on


Iv. quotas for users


Configure the user quota_user_001 that you have created

#edquota-uquota_user_001 #配置用户磁盘配额

ISK quotas for user Qibo (UID 1001):

Filesystem blocks soft Hard inodes soft$

/DEV/SDA7 12 300000000 524288000 4 0$

Unit is KB

Where blocks is already used capacity, soft and hard are respectively, limit 287G and 500G

Ctrl+o Write

Ctrl+x exit


Copy the user's configuration information

#edquota-P quota_user_001-u quota_user_002


Modify Grace time when user files exceed large hours

#edquota-T

36500

Because there is no mandatory requirement, it is set to 36,500 days


Edit the total usage size of the MYQUOTAGRP group

Edquota-g quota_group_001


View restrictions for all disk quotas users

#repquota-AUV


#检查用户磁盘配额剩余情况

$quota-vsug quota_user_001


See if there is a warning message

$warnquota


# Quotaoff/home (cancels the disk space limit.) )

# Quotaon/home (now start the disk space limit.) )


V. Testing

You can set a limit of 50M to create files with a capacity of more than 80M

The test command is as follows

# su-quota_user_001

$ dd If=/dev/zero Of=ceshi bs=1m count=40

Recorded 40+0 read-in

Recorded the writing of 40+0.

41943040 bytes (0.0535329 seconds, 783 MB/s) replicated

[Email protected]:~$ ls

Ceshi

[Email protected]:~$ du-sh *

40M Ceshi

$ dd If=/dev/zero of=ceshi2 bs=1m count=40

DD: Writing "CESHI2": exceeding disk quota

Recorded 9+0 read-in

Recorded the writing of 8+0.

9248768 bytes (9.2 MB) Replicated, 0.0151042 sec, 612 mb/sec

$ du-sh *

40M Ceshi

8.9M Ceshi2


DD If=/dev/zero of=bigfile2 bs=1m count=40

You'll find that data is only 49.8M.


This article is from the "M-tier" blog, so be sure to keep this source http://mengix.blog.51cto.com/7194660/1774759

Set a specific disk space size for Linux host users--ubuntu12.04 configure disk quotas actual combat configuration

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.