LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 10: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, 10:37 AM   #2
b0uncer
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, 10: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, 12:31 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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, 08: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, 04:35 AM   #6
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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, 10: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, 11:46 AM   #8
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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, 11:53 AM   #9
^dj^
LQ Newbie
 
Registered: Aug 2006
Posts: 1

Rep: Reputation: 0
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 12:01 PM. Reason: Addition
 
Old 06-14-2011, 10: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...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 07:48 PM
procmail+quota+bounch mail+but no quota full msg to receipent mickyman Linux - General 3 03-02-2006 04:32 AM
ftp quota probs - 0kb files at quota limit ph_xm Linux - Newbie 0 02-02-2005 12:13 PM
Directory Quota? j_miguel_y Debian 1 06-19-2004 09:12 PM
directory size & QUOTA questions... hct224 Linux - Newbie 4 04-23-2004 07:41 PM


All times are GMT -5. The time now is 05:40 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration