LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Disk Quota... in MB? (https://www.linuxquestions.org/questions/linux-newbie-8/disk-quota-in-mb-515344/)

just_me_then 01-01-2007 10:24 AM

Disk Quota... in MB?
 
Hi,
I have set a system up so i can limit the amout of space a user can use. The question i have is this. What numbers do i put in!

I know for example that i want this user to have a hard limit of 250MB. So do i just put 250 under hard, or does it need to be in a diffrent format?

Disk quotas for user localtest (uid 503):
Filesystem blocks soft hard inodes soft hard
/dev/sdb2 0 0 0 0 0 0


Many thanks

xjlittle 01-01-2007 10:36 AM

disk quotas are set using blocks and are set on a per file system (partition) basis. /home should be on it's own partition. Divide the number of blocks by the number of users if you want all users to have the same amount of disk space.

You can use the command
Code:

fdisk -l
to view the number of blocks

just_me_then 01-01-2007 10:40 AM

thanks... Is there a way that i can work out how many blocks there are to a single MB?

xjlittle 01-01-2007 11:16 AM

This should get you close. Divide the number of blocks on the partition by the 1024. This will give you the blocks per megabyte. Multiply the blocks per megabyte times the number of megabytes that you want a user to have. This will give you the number of blocks to use.

For instance I have a partition with 12586896 blocks. I know this by using the fdisk -l command I mentioned earlier. Now divide that by 1024:
Code:

[root@john-fc6 jslittl]# expr 12586896 \/ 1024
12291

So I have 12291 blocks per MB. If I want a user to have 20 MB I multiply that by 20:
Code:

[root@john-fc6 jslittl]#  expr 20 \* 12291
245820

I would give that user 245820 blocks as a hard limit.

hth

just_me_then 01-01-2007 02:05 PM

Fantastic! Many Thanks.

jschiwal 01-01-2007 06:22 PM

The "df" or "fdisk -l" listings assume the blocks are 1K blocks. So there are 1024 1-k blocks per Megabyte.

Double check that your file-system uses 1K blocks. According to the Coreutils manual:
Quote:

2.3 Block size
Some gnu programs (at least df, du, and ls) display sizes in “blocks”. You can adjust
the block size and method of display to make sizes easier to read. The block size used for
display is independent of any file system block size. Fractional block counts are rounded up
to the nearest integer.
I think that the blocksize is determined by the filesystem used and how it was formatted. The blocksize used by df and du are conveniences. On my system, "stat -f %B" displays 512 byte blocks regardless of what I am checking.

Check your own documentation on what blocksize quota uses on your own system. I don't know offhand if quota uses an arbitrary blocksize or gets it from the filesystem. And I won't assume an answer for me is the correct answer for you.

The ext2 filesystem can have 1024, 2048, and 4096 bytes per block as an option to mkefs. You can check on the blocksize of a fileystem with the debugfs program.


All times are GMT -5. The time now is 04:30 PM.