LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-15-2008, 10:07 AM   #1
carlmarshall
Member
 
Registered: Jan 2004
Location: North Yorkshire, UK
Distribution: Centos 5
Posts: 133

Rep: Reputation: 16
Limit size of a subdirectory


Sorry if this sound a bit basic, but is it possible to limit the size of a subdirectory rather than a filesystem?

I've figured out that I can limit individual users by using quota to restrict usage per mounted filesystem, but I need two shared areas for a whole bunch of users who will be accessing these areas via guest logins under Samba. As such they'll all appear to be the same user.

Current structure is:

data
|
---> general
|
---> special

I need to make it so that there is a limit of 70GB under the special directory whilst allowing the general directory to use as much space as is left over.

Any ideas?

Cheers,
Carl.
 
Old 07-15-2008, 10:21 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
Usually Samba will use the system quotas but you're probably looking for this that can be used within Samba when no system API can be used:

From the man page:

Code:
       set quota command (G)

           The set quota command should only be used whenever there is no operating system API available from the OS that samba can use.

           This option is only available if Samba was configured with the argument --with-sys-quotas or on linux when was used and a working quota
           api was found in the system. Most packages are configured with these options already.

           This parameter should specify the path to a script that can set quota for the specified arguments.

           The specified script should take the following arguments:

              1 - quota type

                  1 - user quotas

                  2 - user default quotas (uid = -1)

                  3 - group quotas

                  4 - group default quotas (gid = -1)

              2 - id (uid for user, gid for group, -1 if N/A)

              3 - quota state (0 = disable, 1 = enable, 2 = enable and enforce)

              4 - block softlimit

              5 - block hardlimit

              6 - inode softlimit

              7 - inode hardlimit

              8(optional) - block size, defaults to 1024

           The script should output at least one line of data on success. And nothing on failure.

           Default: set quota command =

           Example: set quota command = /usr/local/sbin/set_quota
I've never used this type of quota, so not that familiar with it myself.
 
Old 07-15-2008, 11:42 AM   #3
smoked kipper
Member
 
Registered: May 2008
Location: UK
Distribution: Slackware,Slamd64
Posts: 81

Rep: Reputation: 15
In short, no, because there is no such thing as the "size" of a directory (except the size of the actual directory blocks, which is of little concern). The directory structure is merely an indexation system, not a set of containers.
 
Old 07-15-2008, 12:23 PM   #4
carlmarshall
Member
 
Registered: Jan 2004
Location: North Yorkshire, UK
Distribution: Centos 5
Posts: 133

Original Poster
Rep: Reputation: 16
Thanks for that both of you.

I suppose I should have phrased this a little better rather than referring to the "size of a directory", I should have said "size of the total file contents indexed within that directory".

I didn't think there was any support for this, but it's been a while since I used Samba and it may have been something added recently (not that I could find it @ samba.org).

Carl.
 
Old 07-15-2008, 04:09 PM   #5
smoked kipper
Member
 
Registered: May 2008
Location: UK
Distribution: Slackware,Slamd64
Posts: 81

Rep: Reputation: 15
I gathered what you meant, but the "total size of the file contents" doesn't really have a definitive meaning. Think about hardlinked files for example, if a file is hardlinked in two directories, which directory should count the size? The first one alphabetically? The directory with the lower inode number? Both (but then the parent directory whould have the wrong size...)?
 
Old 07-15-2008, 09:48 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
You could try this;
make the 'special' dir owned by another user and limit him using Linux or Samba quotas.
Give the other REAL users group rw access to that dir.
 
Old 07-16-2008, 12:52 AM   #7
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Or you could create a container file that is the size that you want to limit file usage, mount it via a loop device, format it, and mount it on that directory.

Do these steps one time.
Code:
dd if=/dev/zero of=/container.file bs=4K count=4K

losetup /container.file /dev/loop0

mkfs -t ext3 /dev/loop0
Then put this in /etc/fstab
Code:
/container.file /data/special ext3 defaults,loop 1 1

Last edited by stress_junkie; 07-16-2008 at 12:53 AM.
 
  


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
Size limit for folder gubak Linux - Newbie 3 11-11-2004 10:09 AM
~/ size limit bm1 Slackware 5 09-23-2004 08:10 AM
MySQL size limit Robert0380 Linux - General 2 09-05-2003 04:36 AM
2.1 Gb size limit?? pk21 Linux - General 5 08-30-2003 03:40 PM
Size limit? pyropenguin Linux - Networking 1 12-18-2002 01:48 PM


All times are GMT -5. The time now is 11:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration