LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Limit size of a subdirectory (https://www.linuxquestions.org/questions/linux-newbie-8/limit-size-of-a-subdirectory-655886/)

carlmarshall 07-15-2008 09:07 AM

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.

trickykid 07-15-2008 09:21 AM

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.

smoked kipper 07-15-2008 10:42 AM

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.

carlmarshall 07-15-2008 11:23 AM

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.

smoked kipper 07-15-2008 03:09 PM

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...)?

chrism01 07-15-2008 08:48 PM

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.

stress_junkie 07-15-2008 11:52 PM

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


All times are GMT -5. The time now is 09:03 AM.