Set quota to User Group on Ubuntu Debian Linux Mint

Set quota to User Group on Ubuntu Debian Linux Mint

User Quota

 

  • Quotas keep users or groups from taking all the hard disk space on a partition. Linux Admininistrators commonly use disk quatos to regulate the amount of space occupied by any user for data, email, database …. It will help Linux not be crashed because of full hard disk.
  • We can configure Quotas to limit on the number of inodes.

Quota on Centos – Redhat RHEL – Fedora

http://ithelpblog.com/os/linux/redhat/centos-redhat/howto-set-quotas-user-centos-redhat-rhel-fedora/

Step 1: Install quota and quotatool on Ubuntu – Debian – Linux Mint

root@ubuntu:~# apt-get install quota quotatool
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
apache2-mpm-worker apache2-utils apache2.2-common
Use ‘apt-get autoremove’ to remove them.
Suggested packages:
libnet-ldap-perl rpcbind portmap default-mta mail-transport-agent
The following NEW packages will be installed:
quota quotatool
0 upgraded, 2 newly installed, 0 to remove and 261 not upgraded.
Need to get 576 kB of archives.
After this operation, 1,516 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ raring/main quota i386 4.01-3 [558 kB ]
Get:2 http://us.archive.ubuntu.com/ubuntu/ raring/universe quotatool i386 1.4.12-1 [17.1 kB]
Fetched 576 kB in 10s (54.3 kB/s)
Preconfiguring packages …
Selecting previously unselected package quota.
(Reading database … 175351 files and directories currently installed.)
Unpacking quota (from …/archives/quota_4.01-3_i386.deb) …
Selecting previously unselected package quotatool.
Unpacking quotatool (from …/quotatool_1.4.12-1_i386.deb) …
Processing triggers for man-db …
Processing triggers for ureadahead …
ureadahead will be reprofiled on next reboot
Setting up quota (4.01-3) …
Setting up quotatool (1.4.12-1) …
Processing triggers for ureadahead …
root@ubuntu:~#

 

Step 2: Activate User and Group Quota on filesystem

root@ubuntu:~# vi /etc/fstab
# /etc/fstab: static file system information.
#
# Use ‘blkid’ to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=9ee93e09-6a39-41e6-af45-01789b992a8f / ext4 errors=remount-ro,usrquota,grpquota 0 1
# swap was on /dev/sda5 during installation
UUID=d75cbc7b-e74b-4666-95ba-adf059028805 none swap sw 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
root@ubuntu:~#

Step 3: Create quota file

root@ubuntu:/# cd /
root@ubuntu:/# touch aquota.user aquota.group
root@ubuntu:/# chmod 600 aquota.*

Step 4:  Remount a  filesystem with new configuration

root@ubuntu:~# mount -o remount /

Step 5: Checking if remount command work or not.
If it worked, it will have usrquota and grpquota in mtab configuration file.

root@ubuntu:~# cat /etc/mtab
/dev/sda1 / ext4 rw,errors=remount-ro,usrquota,grpquota 0 0
proc /proc proc rw,noexec,nosuid,nodev 0 0
sysfs /sys sysfs rw,noexec,nosuid,nodev 0 0
none /sys/fs/cgroup tmpfs rw 0 0
none /sys/fs/fuse/connections fusectl rw 0 0
none /sys/kernel/debug debugfs rw 0 0
none /sys/kernel/security securityfs rw 0 0
udev /dev devtmpfs rw,mode=0755 0 0
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=0620 0 0
tmpfs /run tmpfs rw,noexec,nosuid,size=10%,mode=0755 0 0
none /run/lock tmpfs rw,noexec,nosuid,nodev,size=5242880 0 0
none /run/shm tmpfs rw,nosuid,nodev 0 0
none /run/user tmpfs rw,noexec,nosuid,nodev,size=104857600,mode=0755 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,noexec,nosuid,nodev 0 0
vmware-vmblock /run/vmblock-fuse fuse.vmware-vmblock rw,nosuid,nodev,default_permissions,allow_other 0 0
gvfsd-fuse /run/user/ubuntu/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,user=ubuntu 0 0
/dev/sr0 /media/ubuntu/CentOS_5.8_Final iso9660 ro,nosuid,nodev,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2 0 0
root@ubuntu:~#

Step 6: Do quotacheck for your system

root@ubuntu:~# quotacheck -avugm
quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.
quotacheck: WARNING – Quotafile //quota.user was probably truncated. Cannot save quota settings…
quotacheck: WARNING – Quotafile //quota.group was probably truncated. Cannot save quota settings…
quotacheck: Scanning /dev/disk/by-uuid/9ee93e09-6a39-41e6-af45-01789b992a8f [/] done
quotacheck: Checked 17883 directories and 180060 files
root@ubuntu:~#

Step 7:  Enable User and Group quota on Disk

root@ubuntu:/# quotaon -avug
/dev/disk/by-uuid/9ee93e09-6a39-41e6-af45-01789b992a8f [/]: group quotas turned on
/dev/disk/by-uuid/9ee93e09-6a39-41e6-af45-01789b992a8f [/]: user quotas turned on
root@ubuntu:/#

Step 8:  Set quota to user Kevin with 1GB

root@ubuntu:/# edquota kevin
Disk quotas for user kevin (uid 1002):
Filesystem blocks soft hard inodes soft hard
/dev/disk/by-uuid/9ee93e09-6a39-41e6-af45-01789b992a8f 8 1000000 1000000 2 0 0

Step 9: Report Quota

root@ubuntu:/# repquota /
*** Report for user quotas on device /dev/disk/by-uuid/9ee93e09-6a39-41e6-af45-01789b992a8f
Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
———————————————————————-
root — 4142236 0 0 195435 0 0
man — 3068 0 0 364 0 0
www-data — 8 0 0 2 0 0
nobody — 0 0 0 1 0 0
libuuid — 24 0 0 2 0 0
syslog — 5788 0 0 26 0 0
avahi-autoipd — 8 0 0 2 0 0
speech-dispatcher — 4 0 0 1 0 0
lightdm — 500 0 0 62 0 0
colord — 20 0 0 4 0 0
ubuntu — 289568 0 0 2006 0 0
kevin — 8 1000000 1000000 2 0 0
apacheds — 11304 0 0 23 0 0
gdm — 24 0 0 6 0 0
#501 — 8 0 0 2 0 0
root@ubuntu:/#

Thanks for using IThelpblog.com.

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>