Changes

Jump to: navigation, search

Disk quota, df and stat weird behaviour

1,150 bytes added, 10:37, 29 November 2006
Table of contents, incondistent quota, other
The aim of this article is to understand where the numbers that are shown by <code>stat</code>/<code>df</code> utils in [[VE]] come from.
== Conventions and Notations ==
Consider typical OpenVZ setup, where <code>ext2</code> separate filesystem is mounted on <code>/vz</code>. <code>ext2</code> is called ''underlying filesystem'' in such situation.
command to get information we need, and later discuss df output.
-->
Consider three basic scenarios, that are possible:
* == Cases ==Consider three basic scenarios, that are possible.=== '''Quota is off for VE'''===
: If quota is off for [[VE]] (DISK_QUOTA=no), the total amount of space, that [[VE]] potentially can acquire, equals amount of total space on partition. Certainly some space can be used by other [[VE]]s, but potentially [[VE]] can have all the space on device. Number of free blocks for [[VE]] equals number of free blocks on partition. Note, that it implies that [[VE]] root user, can fill all the space, including the space, that is reserved for root user of [[HN]]. This is why, you shouldn't reside [[VE]]s private areas on root filesystem of your [[HN]]. Amount of available disk space for [[VE]] equals the number of available blocks for underlying filsystem. Thus, we have the following relationships:
:: <math>total_{simfs}</math> = <math>total_{ext2}</math>
: thus in [[VE]] you obtain information about disk usage of partition, but not disk usage of [[VE]].
* === '''Quota is on for VE and there is enough space on partition'''===
: If quota is on, amount of disk space that [[VE]] potentially can acquire should be equal quota barrier:
:: <math>total_{simfs} = quota_{barrier}</math>
:: <math>free_{simfs} = quota_{barrier} - quota_{used}</math>
* === '''Quota is on for VE and there is NOT enough space on partition'''===
: This is the most interesting and difficult to explain case. Nevertheless I tried to do it. So, our assumption is that:
:: <math>quota_{barrier} - quota_{used} > free_{ext2}</math>
:: <math>avail_{simfs} = quota_{barrier} - quota_{used}</math>
The table below summarize summarizes all possible cases.
== Cases Conclusion ==
So we have three basic variants. Variant number one is not good, because [[VE]] administrator can't get information about [[VE]] disk usage and [[HN]] administrator can't limit [[VE]] disk usage. Variant three is not good 'cause we have some weird (but logical) values in <code>df</code>/<code>stat</code> output in [[VE]], e.g. total disk space can decrease. Variant two is perfect. How can we provide this varaint always take place? Here is the simple rule:
Even if you want [[VE]] to be unlimited, consider reasonable values. Use the following formula:
:: <math>\sum_{i=1}^Nq_i = \le S - s</math>(5)<math>q_i</math> - quota barrier for [[VE ]] <math>i</math>
<math>S</math> - total amount of space on underlying filesystem
<math>s</math> - amount of space used by not [[VE]]s private area: templates, locks, etc.
'''Note, that if you install template - you decrease <math>s</math>. This is bad, because, ideally, after each templateinstallation you have to check inequality (5). To avoid this I suggest to mount separate partion on /vz/private, rather thanon /vz/. In such case <math>s</math> always equals <math>0</math>. == Cases Summarizing Table ==
{| border="1" cellpadding="5" cellspacing="0" align="center"
|+'''Summarizing table'''
| colspan="2" | Quota off
| <math>total_{simfs} = total_{ext2}</math>
<math>avail_{simfs} = avail_{ext2}</math>
|}
-----TODO: add info about == Other reasons of strange numbers ==At the moment I see only two more reasons, why numbers in <code>df</code>/<code>stat</code> output can confuse you.* The quota is inconsistent . This can happen if you turned quota off for some time, if you wrote directly to private area (<code> /vz/private</code>), but not through <code>simfs</code>, etc. When you have doubts wether your quota consistent or not just drop quota (<code>vzquota drop <veid></code>, where <code><veid></code> is the id of stoped [[VE]]). While starting [[VE]] <code>vzctl</code> will automatically initalize quota.* Unsupported underlying filesystem. Currently OpenVZ quota problemssupports only <code>ext2</code>, <code>ext3</code>. With other filesystem types you can have unpredictable results. Praemonitus praemunitus! == TODO ==
TODO: Add Roma's images
 
TODO: Add table
TODO: Add examples with stat/df
172
edits

Navigation menu