LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1337|回复: 9

Quota question: how to limit each user to 100MB on /home/group1

[复制链接]
发表于 2005-10-13 01:45:21 | 显示全部楼层 |阅读模式
I understand linux's quota 只能对分区作全局限制. It can NOT be used to 直接限定一个user home目录的大小.

I also read Mr. kissingwolf's thread as how to 作一个文件,mk2fs, 然后mount -o loop到user home目录,这样就限制了, 就有了一个大小为100M的用户空间.

I have tested the above and it works fine.

Some advanced thoughts

1. If /home is a paritition that is mounted seperately (e.g. mounted /dev/hda12) instead of a local file system under root, and if users are only allowed to write in his /home/user directory (no other public shared directory under /home for this user), setup quota on /home implicitly means setup quota on /home/user. Correct me if I am wrong.....

2. I am using Michael Jiang's RHCE Study Guide. In the sample exam 2, server installation problem:

/home is a seperate partition on /dev/hda5;
add several users. set them up as a group named group1.
create a /home/group1 directory and allow them to share files.
limit each of these users to 100MB of files in this directory.

I really can't figure out how to achieve this.
Mr. Kissingwolf's way can only limit the /home/group1 directory's total space, but can't limit it for each user.

The only workaround I can think of is to create a seperate partition for /home/group1: fdisk to create partition, mkfs, mount /home/group1 on it. And then use the normal quota way to limit each user. It works, but I would like to confirm with you guys...is it correct, any better way?  

Hope you are not confused by me
发表于 2005-10-13 11:29:49 | 显示全部楼层
not sure what you mean by the first point... I think setup quota on a filesystem has nothing to do with its dirs underneath.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-13 20:44:46 | 显示全部楼层
Yes, you are right,setup quota on a filesystem has nothing to do with its dirs underneath, but I am thinking of this situation:  setup quota on /home implicitly mean setup quota on /home/user1, if user1 is not allowed to write in any other directories underneath /home.

How about the second point? Any suggestion?  Thanks in advance......
回复 支持 反对

使用道具 举报

发表于 2005-10-14 00:44:53 | 显示全部楼层
Post by zaiwen
Yes, you are right,setup quota on a filesystem has nothing to do with its dirs underneath, but I am thinking of this situation:  setup quota on /home implicitly mean setup quota on /home/user1, if user1 is not allowed to write in any other directories underneath /home.

How about the second point? Any suggestion?  Thanks in advance......

Ok I see your point. I think you can think that way... For the second one, just simply setup the user quota should work.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-14 08:51:53 | 显示全部楼层
Haha, glad I finally made myself understood...

You siad, for the second one, just simply setup the user quota should work, but you can only setup quota on /home, right?  Then you are assuming users only write under /home/group1, not in his home directory.

If you assign each user 100M on /home, it doesn't mean user will have all the 100M on /home/group1, because each user also has write permission in their own /home/user directory.  So for each user,
100M = /home/group1 + /home/user


?????? maybe I think too much....should take a break.....thank u for trying to understand my silly question
回复 支持 反对

使用道具 举报

发表于 2005-10-14 09:46:26 | 显示全部楼层
quota是限制关系,但和系统权限的限制关系不一样,系统权限以最大范围为准,quota以最小范围为准!
example:
User1's block hard quota set 10 M , and group1's block hard quota set 100M.User1 is one user of group1,that user1 can use only 10 M ! On the other hand, if other one user2 is    one user of group1 too,and user2 already used 99M ,then user1 only can use 1M in this time !
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-15 02:37:32 | 显示全部楼层
Thank u Kevin for replying to my silly question

I understand your reply, but it seems an answer to my another posting:
Quota: user and group, which go first.
http://www.linuxsir.cn/bbs/showthread.php?t=223991

Thanks anyway, especially the second point is something that never comes to mind (if other one user2 is one user of group1 too,and user2 already used 99M ,then user1 only can use 1M in this time).

但是de但是, my original question in this posting is still a question to me:

The configuration requires to give user1 and user2 each 100M under /home/group12. How could this be achieved if we don't know how much user1 and user2 will write under his /home/user1 and /home/user2 ?

for example:
Give 100M quota to user1 and user2 respectively.
Give 200M quota to group12, which consists of user1 and user2.

User1 can write 50M in /home/user1 and 50M in /home/group12
User2 can write 50M in /home/user2 and 50M in /home/group12

This is against the requirement, since user is required to be allowed 100M under /home/group12

The problem is that users have write access to both /home/user and and /home/group12, and we can't control how much they will write to each.

The user and group quota setup is applied to /HOME, not to /home/user or /home/group12  !!!!!

I think it is mission impossible.......unless as what I have suggested:  create a seperate partition and mount /home/group12 on it. And then use the normal quota way to limit each user quota under /home/group12

困惑ing.....
回复 支持 反对

使用道具 举报

发表于 2005-10-15 11:25:50 | 显示全部楼层
quota 是针对文件系统的,也就是分区,而不是目录!
当:
/home --> /dev/sda7
/home/user1 -->/dev/sda7
/home/user2 -->/dev/sda7
有区别吗 ?
回复 支持 反对

使用道具 举报

发表于 2005-10-15 23:44:32 | 显示全部楼层
Post by zaiwen
Haha, glad I finally made myself understood...

You siad, for the second one, just simply setup the user quota should work, but you can only setup quota on /home, right?  Then you are assuming users only write under /home/group1, not in his home directory.

If you assign each user 100M on /home, it doesn't mean user will have all the 100M on /home/group1, because each user also has write permission in their own /home/user directory.  So for each user,
100M = /home/group1 + /home/user


?????? maybe I think too much....should take a break.....thank u for trying to understand my silly question

I guess you probably misunderstood the requirements.
1. quota for user/group controls how many spaces/inodes the user/group can consume. There is nothing to do with the dirs. User or users in the group can write to any dirs that they are allowed under the quotaon filesystem.
2. You don't need to think it that complex. Simply, if a user has quota on, then the limit is calc'ed consecutively across that filesystem, no matter if the user writes a file or dir or what... If a group has quota on, then all users in that group will share the limit. With these two, whichever comes first will apply just like what Kevin said.
3. What is a dir? A simple inode to tell the kernel what's underneath. Itself only takes 1 block and has nothing to do with space/inode boundary, but filesystems(actually partitions) which contain inode tables (many inodes) do have space boundary. Quota is a tool to calc and limit the space and inode, so that's why it can only works on filesystem/partition but not dir.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-17 22:32:07 | 显示全部楼层
Thank u very much for the detailed reply.

I agree I might think too much and make it too complex....

But still I think the problem is misleading or confusing:

create a /home/group1 directory and allow them to share files.
limit each of these users to 100MB of files in This DIRECTORY.

As you said, "Quota is a tool to calc and limit the space and inode, so that's why it can only works on filesystem/partition but not dir"

So the sample problem is not clear...hahahaha....but I agress with u that we should think it simple.

Thanks again!!!!!!!!!!!!!!!!!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表