]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - man/man8/xfs_quota.8
4ec575fd12caec5d808e21bf89231c4022a21bf3
[thirdparty/xfsprogs-dev.git] / man / man8 / xfs_quota.8
1 .TH xfs_quota 8
2 .SH NAME
3 xfs_quota \- manage use of quota on XFS filesystems
4 .SH SYNOPSIS
5 .B xfs_quota
6 [
7 .B \-x
8 ] [
9 .B \-f
10 ] [
11 .B \-p
12 .I prog
13 ] [
14 .B \-c
15 .I cmd
16 ] ... [
17 .B \-d
18 .I project
19 ] ... [
20 .B \-D
21 .I projects_file
22 ] [
23 .B \-P
24 .I projid_file
25 ] [
26 .IR path " ... ]"
27 .br
28 .B xfs_quota \-V
29 .SH DESCRIPTION
30 .B xfs_quota
31 is a utility for reporting and editing various aspects of filesystem quota.
32 .PP
33 The options to
34 .B xfs_quota
35 are:
36 .TP 1.0i
37 .BI \-c " cmd"
38 .B xfs_quota
39 commands may be run interactively (the default) or as arguments on
40 the command line. Multiple
41 .B \-c
42 arguments may be given.
43 The commands are run in the sequence given, then the program exits.
44 .TP
45 .BI \-p " prog"
46 Set the program name for prompts and some error messages,
47 the default value is
48 .BR xfs_quota .
49 .TP
50 .B \-x
51 Enable expert mode.
52 All of the administrative commands (see the ADMINISTRATOR COMMANDS
53 section below) which allow modifications to the quota system are
54 available only in expert mode.
55 .TP
56 .B \-f
57 Enable foreign filesystem mode.
58 A limited number of user and administrative commands are available for
59 use on some foreign (non-XFS) filesystems.
60 .TP
61 .BI \-d " project"
62 Project names or numeric identifiers may be specified with this option,
63 which restricts the output of the individual
64 .B xfs_quota
65 commands to the set of projects specified. Multiple
66 .B \-d
67 arguments may be given.
68 .TP
69 .BI \-D " projects_file"
70 Specify a file containing the mapping of numeric project identifiers
71 to directory trees.
72 .I /etc/projects
73 as default, if this option is none.
74 .TP
75 .BI \-P " projid_file"
76 Specify a file containing the mapping of numeric project identifiers
77 to project names.
78 .I /etc/projid
79 as default, if this option is none.
80 .TP
81 .B \-V
82 Prints the version number and exits.
83 .PP
84 The optional
85 .I path
86 argument(s) can be used to specify mount points or device files
87 which identify XFS filesystems. The output of the individual
88 .B xfs_quota
89 commands will then be restricted to the set of filesystems specified.
90 .PP
91 This manual page is divided into two sections \- firstly,
92 information for users of filesystems with quota enabled, and the
93 .B xfs_quota
94 commands of interest to such users; and then information which is
95 useful only to administrators of XFS filesystems using quota and the
96 quota commands which allow modifications to the quota system.
97 .PP
98 Note that common to almost all of the individual commands described
99 below are the options for specifying which quota types are of interest
100 \- user quota
101 .RB ( \-u ),
102 group quota
103 .RB ( \-g ),
104 and/or project quota
105 .RB ( \-p ).
106 Also, several commands provide options to operate on "blocks used"
107 .RB ( \-b ),
108 "inodes used"
109 .RB ( \-i ),
110 and/or "realtime blocks used"
111 .RB ( \-r ).
112 .PP
113 Many commands also have extensive online help. Use the
114 .B help
115 command for more details on any command.
116 .SH QUOTA OVERVIEW
117 .PP
118 In most computing environments, disk space is not infinite.
119 The quota subsystem provides a mechanism to control usage of disk space.
120 Quotas can be set for each individual user on any/all of the local
121 filesystems.
122 The quota subsystem warns users when they exceed their allotted limit,
123 but allows some extra space for current work (hard limit/soft limit).
124 In addition, XFS filesystems with limit enforcement turned off can be
125 used as an effective disk usage accounting system.
126 .SS Users' View of Disk Quotas
127 To most users, disk quotas are either of no concern or a fact of life
128 that cannot be avoided.
129 There are two possible quotas that can be imposed \- a limit can be set
130 on the amount of space a user can occupy, and there may be a limit on
131 the number of files (inodes) he can own.
132 .PP
133 The
134 .B quota
135 command provides information on the quotas that have been
136 set by the system administrators and current usage.
137 .PP
138 There are four numbers for each limit: current usage, soft limit
139 (quota), hard limit, and time limit.
140 The soft limit is the number of 1K-blocks (or files) that the user is
141 expected to remain below.
142 The hard limit cannot be exceeded.
143 If a user's usage reaches the hard limit, further requests for space
144 (or attempts to create a file) fail with the "Quota exceeded" (EDQUOT)
145 error.
146 .PP
147 When a user exceeds the soft limit, the timer is enabled.
148 Any time the quota drops below the soft limits, the timer is disabled.
149 If the timer pops, the particular limit that has been exceeded is treated
150 as if the hard limit has been reached, and no more resources are allocated
151 to the user.
152 The only way to reset this condition, short of turning off limit
153 enforcement or increasing the limit, is to reduce usage below quota.
154 Only the superuser (i.e. a sufficiently capable process) can set the
155 time limits and this is done on a per filesystem basis.
156 .SS Surviving When the Quota Limit Is Reached
157 In most cases, the only way for a user to recover from over-quota
158 conditions is to abort whatever activity is in progress on the filesystem
159 that has reached its limit, remove sufficient files to bring the limit
160 back below quota, and retry the failed program.
161 .br
162 However, if a user is in the editor and a write fails because of an over
163 quota situation, that is not a suitable course of action.
164 It is most likely that initially attempting to write the file has truncated
165 its previous contents, so if the editor is aborted without correctly writing
166 the file, not only are the recent changes lost, but possibly much, or even
167 all, of the contents that previously existed.
168 .br
169 There are several possible safe exits for a user caught in this situation.
170 He can use the editor shell escape command to examine his file space
171 and remove surplus files. Alternatively, using
172 .BR sh (1),
173 he can suspend
174 the editor, remove some files, then resume it.
175 A third possibility is to write the file to some other filesystem (perhaps
176 to a file on
177 .IR /tmp )
178 where the user's quota has not been exceeded.
179 Then after rectifying the quota situation, the file can be moved back to the
180 filesystem it belongs on.
181 .SH USER COMMANDS
182 .TP
183 .B print
184 Lists all paths with devices/project identifiers.
185 The path list can come from several places \- the command line,
186 the mount table, and the
187 .I /etc/projects
188 file.
189 .TP
190 .B df
191 See the
192 .B free
193 command.
194 .HP
195 .B quota
196 [
197 .BR \-g " | " \-p " | " \-u
198 ] [
199 .B \-bir
200 ] [
201 .B \-hnNv
202 ] [
203 .B \-f
204 .I file
205 ] [
206 .I ID
207 |
208 .I name
209 ] ...
210 .br
211 Show individual usage and limits, for a single user
212 .I name
213 or numeric user
214 .IR ID .
215 The
216 .B \-h
217 option reports in a "human-readable" format similar to the
218 .BR df (1)
219 command. The
220 .B \-n
221 option reports the numeric IDs rather than the name. The
222 .B \-N
223 option omits the header. The
224 .B \-v
225 option outputs verbose information. The
226 .B \-f
227 option sends the output to
228 .I file
229 instead of stdout.
230 .HP
231 .B
232 free
233 [
234 .B \-bir
235 ] [
236 .B \-hN
237 ] [
238 .B \-f
239 .I file
240 ]
241 .br
242 Reports filesystem usage, much like the
243 .BR df (1)
244 utility.
245 It can show usage for
246 .BR b locks,
247 .BR i node,
248 and/or
249 .BR r ealtime
250 block space, and shows used, free, and total available.
251 If project quota are in use (see the DIRECTORY TREE QUOTA section below),
252 it will also report utilisation for those projects (directory trees). The
253 .B \-h
254 option reports in a "human-readable" format. The
255 .B \-N
256 option omits the header. The
257 .B \-f
258 option outputs the report to
259 .I file
260 instead of stdout.
261 .HP
262 .B help
263 [
264 .I command
265 ]
266 .br
267 Online help for all commands, or one specific
268 .IR command .
269 .TP
270 .B quit
271 Exit
272 .BR xfs_quota .
273 .TP
274 .B q
275 See the
276 .B quit
277 command.
278 .SH QUOTA ADMINISTRATION
279 The XFS quota system differs to that of other filesystems
280 in a number of ways.
281 Most importantly, XFS considers quota information as
282 filesystem metadata and uses journaling to provide a higher level
283 guarantee of consistency.
284 As such, it is administered differently, in particular:
285 .IP 1.
286 The
287 .B quotacheck
288 command has no effect on XFS filesystems.
289 The first time quota accounting is turned on (at mount time), XFS does
290 an automatic quotacheck internally; afterwards, the quota system will
291 always be completely consistent until quotas are manually turned off.
292 .IP 2.
293 There is no need for quota file(s) in the root of the XFS filesystem.
294 .IP 3.
295 XFS distinguishes between quota accounting and limit enforcement.
296 Quota accounting must be turned on at the time of mounting the XFS
297 filesystem.
298 However, it is possible to turn on/off limit enforcement any time
299 quota accounting is turned on.
300 The "quota" option to the
301 .B mount
302 command turns on both (user) quota accounting and enforcement.
303 The "uqnoenforce" option must be used to turn on user accounting with
304 limit enforcement disabled.
305 .IP 4.
306 Turning on quotas on the root filesystem is slightly different from
307 the above.
308 For IRIX XFS, refer to
309 .BR quotaon (1M).
310 For Linux XFS, the quota mount flags must be passed in with the
311 "rootflags=" boot parameter.
312 .IP 5.
313 It is useful to use the
314 .B state
315 to monitor the XFS quota subsystem
316 at various stages \- it can be used to see if quotas are turned on,
317 and also to monitor the space occupied by the quota system itself..
318 .IP 6.
319 There is a mechanism built into
320 .B xfsdump
321 that allows quota limit information to be backed up for later
322 restoration, should the need arise.
323 .IP 7.
324 Quota limits cannot be set before turning on quotas on.
325 .IP 8.
326 XFS filesystems keep quota accounting on the superuser (user ID zero),
327 and the tool will display the superuser's usage information.
328 However, limits are never enforced on the superuser (nor are they
329 enforced for group and project ID zero).
330 .IP 9.
331 XFS filesystems perform quota accounting whether the user has quota
332 limits or not.
333 .IP 10.
334 XFS supports the notion of project quota, which can be used to
335 implement a form of directory tree quota (i.e. to restrict a
336 directory tree to only being able to use up a component of the
337 filesystems available space; or simply to keep track of the
338 amount of space used, or number of inodes, within the tree).
339 .SH ADMINISTRATOR COMMANDS
340 .HP
341 .B path
342 [
343 .I N
344 ]
345 .br
346 Lists all paths with devices/project identifiers or set the current
347 path to the
348 .IR N th
349 list entry (the current path is used by many
350 of the commands described here, it identifies the filesystem toward
351 which a command is directed).
352 The path list can come from several places \- the command line,
353 the mount table, and the
354 .I /etc/projects
355 file.
356 .HP
357 .B report
358 [
359 .B \-gpu
360 ] [
361 .B \-bir
362 ] [
363 .B \-ahntlLNU
364 ] [
365 .B \-f
366 .I file
367 ]
368 .br
369 Report filesystem quota information.
370 This reports all quota usage for a filesystem, for the specified
371 quota type
372 .RB ( u / g / p
373 and/or
374 .BR b locks/ i nodes/ r ealtime).
375 It reports blocks in 1KB units by default. The
376 .B \-h
377 option reports in a "human-readable" format similar to the
378 .BR df (1)
379 command. The
380 .B \-f
381 option outputs the report to
382 .I file
383 instead of stdout. The
384 .B \-a
385 option reports on all filesystems. By default, outputs the name of
386 the user/group/project. If no name is defined for a given ID, outputs
387 the numeric ID instead. The
388 .B \-n
389 option outputs the numeric ID instead of the name. The
390 .B \-L
391 and
392 .B \-U
393 options specify lower and upper ID bounds to report on. If upper/lower
394 bounds are specified, then by default only the IDs will be displayed
395 in output; with the
396 .B \-l
397 option, a lookup will be performed to translate these IDs to names. The
398 .B \-N
399 option reports information without the header line. The
400 .B \-t
401 option performs a terse report.
402 .HP
403 .B
404 state
405 [
406 .B \-gpu
407 ] [
408 .B \-av
409 ] [
410 .B \-f
411 .I file
412 ]
413 .br
414 Report overall quota state information.
415 This reports on the state of quota accounting, quota enforcement,
416 and the number of extents being used by quota metadata within the
417 filesystem. The
418 .B \-f
419 option outputs state information to
420 .I file
421 instead of stdout. The
422 .B \-a
423 option reports state on all filesystems and not just the current path.
424 .HP
425 .B
426 limit
427 [
428 .BR \-g " | " \-p " | " \-u
429 ]
430 .BI bsoft= N
431 |
432 .BI bhard= N
433 |
434 .BI isoft= N
435 |
436 .BI ihard= N
437 |
438 .BI rtbsoft= N
439 |
440 .BI rtbhard= N
441 .B \-d
442 |
443 .I id
444 |
445 .I name
446 .br
447 Set quota block limits (bhard/bsoft), inode count limits (ihard/isoft)
448 and/or realtime block limits (rtbhard/rtbsoft). The
449 .B \-d
450 option (defaults) can be used to set the default value
451 that will be used, otherwise a specific
452 .BR u ser/ g roup/ p roject
453 .I name
454 or numeric
455 .IR id entifier
456 must be specified.
457 .HP
458 .B timer
459 [
460 .BR \-g " | " \-p " | " \-u
461 ] [
462 .B \-bir
463 ]
464 .I value
465 .br
466 Allows the quota enforcement timeout (i.e. the amount of time allowed
467 to pass before the soft limits are enforced as the hard limits) to
468 be modified. The current timeout setting can be displayed using the
469 .B state
470 command. The value argument is a number of seconds, but units of
471 \&'minutes', 'hours', 'days', and 'weeks' are also understood
472 (as are their abbreviations 'm', 'h', 'd', and 'w').
473 .HP
474 .B warn
475 [
476 .BR \-g " | " \-p " | " \-u
477 ] [
478 .B \-bir
479 ]
480 .I value
481 .B -d
482 |
483 .I id
484 |
485 .I name
486 .br
487 Allows the quota warnings limit (i.e. the number of times a warning
488 will be send to someone over quota) to be viewed and modified. The
489 .B \-d
490 option (defaults) can be used to set the default time
491 that will be used, otherwise a specific
492 .BR u ser/ g roup/ p roject
493 .I name
494 or numeric
495 .IR id entifier
496 must be specified.
497 .B NOTE: this feature is not currently implemented.
498 .TP
499 .BR enable " [ " \-gpu " ] [ " \-v " ]"
500 Switches on quota enforcement for the filesystem identified by the
501 current path.
502 This requires the filesystem to have been mounted with quota enabled,
503 and for accounting to be currently active. The
504 .B \-v
505 option (verbose) displays the state after the operation has completed.
506 .TP
507 .BR disable " [ " \-gpu " ] [ " \-v " ]"
508 Disables quota enforcement, while leaving quota accounting active. The
509 .B \-v
510 option (verbose) displays the state after the operation has completed.
511 .TP
512 .BR off " [ " \-gpu " ] [ " \-v " ]"
513 Permanently switches quota off for the filesystem identified by the
514 current path.
515 Quota can only be switched back on subsequently by unmounting and
516 then mounting again.
517 .TP
518 .BR remove " [ " \-gpu " ] [ " \-v " ]"
519 Remove any space allocated to quota metadata from the filesystem
520 identified by the current path.
521 Quota must not be enabled on the filesystem, else this operation will
522 report an error.
523 .HP
524 .B
525 dump
526 [
527 .BR \-g " | " \-p " | " \-u
528 ] [
529 .B \-f
530 .I file
531 ]
532 .br
533 Dump out quota limit information for backup utilities, either to
534 standard output (default) or to a
535 .IR file .
536 This is only the limits, not the usage information, of course.
537 .HP
538 .B restore
539 [
540 .BR \-g " | " \-p " | " \-u
541 ] [
542 .B \-f
543 .I file
544 ]
545 .br
546 Restore quota limits from a backup
547 .IR file .
548 The file must be in the format produced by the
549 .B dump
550 command.
551 .HP
552 .B
553 quot
554 [
555 .BR \-g " | " \-p " | " \-u
556 ] [
557 .B \-bir
558 ] [
559 .B \-acnv
560 ] [
561 .B \-f
562 .I file
563 ]
564 .br
565 Summarize filesystem ownership, by user, group or project.
566 This command uses a special XFS "bulkstat" interface to quickly scan
567 an entire filesystem and report usage information.
568 This command can be used even when filesystem quota are not enabled,
569 as it is a full-filesystem scan (it may also take a long time...). The
570 .B \-a
571 option displays information on all filesystems. The
572 .B \-c
573 option displays a histogram instead of a report. The
574 .B \-n
575 option displays numeric IDs rather than names. The
576 .B \-v
577 option displays verbose information. The
578 .B \-f
579 option send the output to
580 .I file
581 instead of stdout.
582 .HP
583 .B project
584 [
585 .B \-cCs
586 [
587 .B \-d
588 .I depth
589 ]
590 [
591 .B \-p
592 .I path
593 ]
594 .I id
595 |
596 .I name
597 ]
598 .br
599 The
600 .BR \-c ,
601 .BR \-C ,
602 and
603 .B \-s
604 options allow the directory tree quota mechanism to be maintained.
605 .BR \-d
606 allows one to limit recursion level when processing project directories
607 and
608 .BR \-p
609 allows one to specify project paths at command line ( instead of
610 .I /etc/projects
611 ). All options are discussed in detail below.
612 .SH DIRECTORY TREE QUOTA
613 The project quota mechanism in XFS can be used to implement a form of
614 directory tree quota, where a specified directory and all of the files
615 and subdirectories below it (i.e. a tree) can be restricted to using
616 a subset of the available space in the filesystem.
617 .PP
618 A managed tree must be setup initially using the
619 .B \-s
620 option to the
621 .B project
622 command. The specified project name or identifier is matched to one
623 or more trees defined in
624 .IR /etc/projects ,
625 and these trees are then recursively descended
626 to mark the affected inodes as being part of that tree.
627 This process sets an inode flag and the project identifier on every file
628 in the affected tree.
629 Once this has been done, new files created in the tree will automatically
630 be accounted to the tree based on their project identifier.
631 An attempt to create a hard link to a file in the tree will only succeed
632 if the project identifier matches the project identifier for the tree.
633 The
634 .B xfs_io
635 utility can be used to set the project ID for an arbitrary file, but this
636 can only be done by a privileged user.
637 .PP
638 A previously setup tree can be cleared from project quota control through
639 use of the
640 .B project \-C
641 option, which will recursively descend
642 the tree, clearing the affected inodes from project quota control.
643 .PP
644 Finally, the
645 .B project \-c
646 option can be used to check whether a
647 tree is setup, it reports nothing if the tree is correct, otherwise it
648 reports the paths of inodes which do not have the project ID of the rest
649 of the tree, or if the inode flag is not set.
650 .PP
651 Option
652 .B \-d
653 can be used to limit recursion level (\-1 is infinite, 0 is top level only,
654 1 is first level ... ).
655 Option
656 .B \-p
657 adds possibility to specify project paths in command line without a need
658 for
659 .I /etc/projects
660 to exist. Note that if projects file exists then it is also used.
661
662 .SH EXAMPLES
663 Enabling quota enforcement on an XFS filesystem (restrict a user
664 to a set amount of space).
665 .nf
666 .sp
667 .in +5
668 # mount \-o uquota /dev/xvm/home /home
669 # xfs_quota \-x \-c 'limit bsoft=500m bhard=550m tanya' /home
670 # xfs_quota \-x \-c report /home
671 .in -5
672 .fi
673 .PP
674 Enabling project quota on an XFS filesystem (restrict files in
675 log file directories to only using 1 gigabyte of space).
676 .nf
677 .sp
678 .in +5
679 # mount \-o prjquota /dev/xvm/var /var
680 # echo 42:/var/log >> /etc/projects
681 # echo logfiles:42 >> /etc/projid
682 # xfs_quota \-x \-c 'project \-s logfiles' /var
683 # xfs_quota \-x \-c 'limit \-p bhard=1g logfiles' /var
684 .in -5
685 .fi
686 .PP
687 Same as above without a need for configuration files.
688 .nf
689 .sp
690 .in +5
691 # rm \-f /etc/projects /etc/projid
692 # mount \-o prjquota /dev/xvm/var /var
693 # xfs_quota \-x \-c 'project \-s \-p /var/log 42' /var
694 # xfs_quota \-x \-c 'limit \-p bhard=1g 42' /var
695 .in -5
696 .fi
697 .SH CAVEATS
698 XFS implements delayed allocation (aka. allocate-on-flush) and this
699 has implications for the quota subsystem.
700 Since quota accounting can only be done when blocks are actually
701 allocated, it is possible to issue (buffered) writes into a file
702 and not see the usage immediately updated.
703 Only when the data is actually written out, either via one of the
704 kernels flushing mechanisms, or via a manual
705 .BR sync (2),
706 will the usage reported reflect what has actually been written.
707 .PP
708 In addition, the XFS allocation mechanism will always reserve the
709 maximum amount of space required before proceeding with an allocation.
710 If insufficient space for this reservation is available, due to the
711 block quota limit being reached for example, this may result in the
712 allocation failing even though there is sufficient space.
713 Quota enforcement can thus sometimes happen in situations where the
714 user is under quota and the end result of some operation would still
715 have left the user under quota had the operation been allowed to run
716 its course.
717 This additional overhead is typically in the range of tens of blocks.
718 .PP
719 Both of these properties are unavoidable side effects of the way XFS
720 operates, so should be kept in mind when assigning block limits.
721 .SH BUGS
722 Quota support for filesystems with realtime subvolumes is not yet
723 implemented, nor is the quota warning mechanism (the Linux
724 .BR warnquota (8)
725 tool can be used to provide similar functionality on that platform).
726 .SH FILES
727 .PD 0
728 .TP 20
729 .I /etc/projects
730 Mapping of numeric project identifiers to directories trees.
731 .TP
732 .I /etc/projid
733 Mapping of numeric project identifiers to project names.
734 .PD
735 .SH IRIX SEE ALSO
736 .BR quotaon (1M),
737 .BR xfs (4).
738
739 .SH LINUX SEE ALSO
740 .BR warnquota (8),
741 .BR xfs (5).
742
743 .SH SEE ALSO
744 .BR df (1),
745 .BR mount (1),
746 .BR sync (2),
747 .BR projid (5),
748 .BR projects (5).