LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-20-2007, 09:29 AM   #1
rcm
LQ Newbie
 
Registered: Sep 2007
Posts: 11

Rep: Reputation: 0
directory quota


Hi

Can we have directory quota on Linux
 
Old 11-20-2007, 09:37 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Disk quota at least, so I guess it's what you're asking, right?
Code:
man quota
 
Old 11-20-2007, 09:43 AM   #3
rcm
LQ Newbie
 
Registered: Sep 2007
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by b0uncer View Post
Disk quota at least, so I guess it's what you're asking, right?
Code:
man quota
In linux we have user & group quota

can we also have quota only for directory which only look for users 0r group space

But will only refer to directory
 
Old 11-20-2007, 11:31 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quota is based upon filesystems, but you can always create a virtual filesystem and mount it on a specific (empty) directory with the usrquota and/or grpquota flags. In steps this will be:
1. create the mount point
2. create a file full of /dev/zero, large enough to the maximum size you want to reserve for the virtual filesystem
3. format this file with an ext3 filesystem (you can format a disk space even if it is not a block device, but double check the syntax of every - dangerous - formatting command)
4. mount the newly formatted disk space in the directory you've created as mount point, e.g.
Code:
mount -o loop,rw,usrquota,grpquota /path/to/the/formatted/disk/space /path/of/mount/point
5. Set proper permissions
6. Set quotas
and the trick is done.
 
Old 11-20-2007, 07:06 PM   #5
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
To answer your question, you could have a quota on a specific directory, but you would need to create a new partition specifically for that directory. Otherwise, the quotas apply to users and groups on a specific volume.

(someone correct me if I'm wrong)
 
Old 11-21-2007, 03:35 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by Micro420 View Post
To answer your question, you could have a quota on a specific directory, but you would need to create a new partition specifically for that directory. Otherwise, the quotas apply to users and groups on a specific volume.
Actually the filesystem with quota can be either a block device (like a partition) or a reserved disk space (pseudo-device). If you don't want to re-partition the hard disk, the latter can be a solution.
 
Old 11-21-2007, 09:55 AM   #7
rcm
LQ Newbie
 
Registered: Sep 2007
Posts: 11

Original Poster
Rep: Reputation: 0
Thankal for your solution i will try it but i have one more query regarding the same

Once the virtual filesystem is created after that can i increase the size of filesystem.
 
Old 11-21-2007, 10:46 AM   #8
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by rcm View Post
Once the virtual filesystem is created after that can i increase the size of filesystem.
Yes. Once I increased the size of a virtual filesystem on a Fedora Core 5 machine and never experienced any problem with it. I had a filesystem of 150 Mb in /usr/virtual-disk/data.ext3 and I mounted it on /data. The following commands worked for me
Code:
umount /usr/virtual-disk/data.ext3
cd /usr/virtual-disk
e2fsck -f data.ext3
resize2fs -p data.ext3 300M
mount -o loop,rw,usrquota,grpquota /usr/virtual-disk/data.ext3 /data
I doubled the size of the filesystem and no data was lost. Anyway, better to do a backup of any valuable data when performing filesystem operations.
 
Old 03-14-2008, 10:53 AM   #9
^dj^
LQ Newbie
 
Registered: Aug 2006
Posts: 1

Rep: Reputation: 1
Great solution for a quick creation of quoted directories (for samba shares for example). This even allows for free space monitoring in the directories by Nagios or alike if needed. Thanks a lot folks!

Just wanted to sum things up, I had to dig around a bit to find the right commands.

1. create the mount point
Code:
# mkdir /var/virtual_disks/directory_with_size_limit
2. create a file full of /dev/zero, large enough to the maximum size you want to reserve for the virtual file-system
Code:
# touch /var/virtual_disks/directory_with_size_limit.ext3
# dd if=/dev/zero of=/var/virtual_disks/directory_with_size_limit.ext3 bs=QUOTA_SIZE count=1
3. format this file with an ext3 file-system (you can format a disk space even if it is not a block device, but double check the syntax of every - dangerous - formatting command)
Code:
# mkfs.ext3 /var/virtual_disks/directory_with_size_limit.ext3
4. mount the newly formatted disk space in the directory you've created as mount point, e.g.
Code:
# mount -o loop,rw,usrquota,grpquota /var/virtual_disks/directory_with_size_limit.ext3 /path/of/mount/point
As a result you now have a directory in /path/of/mount/point with a size limitation.

If you wish to add more space to (trim the size of) the directory:
Code:
# umount /path/of/mount/point

# e2fsck -f /var/virtual_disks/directory_with_size_limit.ext3

# resize2fs -p /var/virtual_disks/directory_with_size_limit.ext3 NEW_SIZE

# mount -o loop,rw,usrquota,grpquota /var/virtual_disks/directory_with_size_limit.ext3 /path/of/mount/point
I also found a similar set of tools for reiserfs, couldn't find a resize tool for jfs.

In this solution the space gets eaten away from the host partition(s), use with caution, be sure to save some space for future expansions.

Last edited by ^dj^; 03-14-2008 at 11:01 AM. Reason: Addition
 
1 members found this post helpful.
Old 06-14-2011, 09:15 AM   #10
izoguitar
LQ Newbie
 
Registered: May 2011
Posts: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by ^dj^ View Post
Great solution for a quick creation of quoted directories (for samba shares for example). This even allows for free space monitoring in the directories by Nagios or alike if needed. Thanks a lot folks!

Just wanted to sum things up, I had to dig around a bit to find the right commands.

1. create the mount point
Code:
# mkdir /var/virtual_disks/directory_with_size_limit
2. create a file full of /dev/zero, large enough to the maximum size you want to reserve for the virtual file-system
Code:
# touch /var/virtual_disks/directory_with_size_limit.ext3
# dd if=/dev/zero of=/var/virtual_disks/directory_with_size_limit.ext3 bs=QUOTA_SIZE count=1
3. format this file with an ext3 file-system (you can format a disk space even if it is not a block device, but double check the syntax of every - dangerous - formatting command)
Code:
# mkfs.ext3 /var/virtual_disks/directory_with_size_limit.ext3
4. mount the newly formatted disk space in the directory you've created as mount point, e.g.
Code:
# mount -o loop,rw,usrquota,grpquota /var/virtual_disks/directory_with_size_limit.ext3 /path/of/mount/point
As a result you now have a directory in /path/of/mount/point with a size limitation.

If you wish to add more space to (trim the size of) the directory:
Code:
# umount /path/of/mount/point

# e2fsck -f /var/virtual_disks/directory_with_size_limit.ext3

# resize2fs -p /var/virtual_disks/directory_with_size_limit.ext3 NEW_SIZE

# mount -o loop,rw,usrquota,grpquota /var/virtual_disks/directory_with_size_limit.ext3 /path/of/mount/point
I also found a similar set of tools for reiserfs, couldn't find a resize tool for jfs.

In this solution the space gets eaten away from the host partition(s), use with caution, be sure to save some space for future expansions.

Hi friends... thanks for the steps to create virtual disks. I'm still new and need your support. I've created the above directory successfully. I wish to know where to configure should i need to mount the directory once the machine start. Please guide me. Thanks...
 
Old 12-09-2017, 09:52 AM   #11
pbalm
LQ Newbie
 
Registered: Jul 2014
Posts: 5

Rep: Reputation: Disabled
Post

Quote:
Originally Posted by izoguitar View Post
I wish to know where to configure should i need to mount the directory once the machine start.
You add a line to the /etc/fstab file. For example:

Code:
/var/virtual_disks/directory_with_size_limit.ext3  /path/of/mount/point  ext3   0  1
Here,

* /var/virtual_disks/directory_with_size_limit.ext3 is the file you created containing the new file system
* /path/of/mount/point is the directory that you want to use and that should have limited size.

So for example if you wanted to limited the size that /var/log can use to 1 GB, then /path/of/mount/point should be replaced with /var/log and /var/virtual_disks/directory_with_size_limit.ext3 should be a 1 GB file.

Last edited by pbalm; 12-09-2017 at 09:53 AM. Reason: fix quote
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Quota help! dlc2000 Linux - Newbie 7 12-23-2006 06:48 PM
procmail+quota+bounch mail+but no quota full msg to receipent mickyman Linux - General 3 03-02-2006 03:32 AM
ftp quota probs - 0kb files at quota limit ph_xm Linux - Newbie 0 02-02-2005 11:13 AM
Directory Quota? j_miguel_y Debian 1 06-19-2004 08:12 PM
directory size & QUOTA questions... hct224 Linux - Newbie 4 04-23-2004 06:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration