🌐
Linux Man Pages
man7.org β€Ί linux β€Ί man-pages β€Ί man8 β€Ί xfs_quota.8.html
xfs_quota(8) - Linux manual page
# mount -o uquota /dev/xvm/home /home # xfs_quota -x -c 'limit bsoft=500m bhard=550m tanya' /home # xfs_quota -x -c report /home Enabling project quota on an XFS filesystem (restrict files in log file directories to only using 1 gigabyte of space). # mount -o prjquota /dev/xvm/var /var # echo 42:/var/log >> /etc/projects # echo logfiles:42 >> /etc/projid # xfs_quota -x -c 'project -s logfiles' /var # xfs_quota -x -c 'limit -p bhard=1g logfiles' /var Same as above without a need for configuration files.
🌐
Fabian Lee
fabianlee.org β€Ί 2020 β€Ί 01 β€Ί 13 β€Ί linux-using-xfs-project-quotas-to-limit-capacity-within-a-subdirectory
Linux: Using xfs project quotas to limit capacity within a subdirectory | Fabian Lee : Software Engineer
January 14, 2020 - XFS is a journaled filesystem that has excellent parallel performance, and is licensed under the GPL which means it has been included in many Linux distributions. One of the features of XFS is the ability to enforce quotas based on user, group, and project. In this article, I will show how to assign filesize quotas ...
🌐
Linux Man Pages
linux.die.net β€Ί man β€Ί 8 β€Ί xfs_quota
xfs_quota(8) - Linux man page
# mount -o uquota /dev/xvm/home /home # xfs_quota -x -c 'limit bsoft=500m bhard=550m tanya' /home # xfs_quota -x -c report /homeEnabling project quota on an XFS filesystem (restrict files in log file directories to only using 1 gigabyte of space). # mount -o prjquota /dev/xvm/var /var # echo 42:/var/log >> /etc/projects # echo logfiles:42 >> /etc/projid # xfs_quota -x -c 'project -s logfiles' /var # xfs_quota -x -c 'limit -p bhard=1g logfiles' /varSame as above without a need for configuration files.
🌐
Ubuntu Manpages
manpages.ubuntu.com β€Ί jammy β€Ί man(8)
Ubuntu Manpage: xfs_quota - manage use of quota on XFS filesystems
# rm -f /etc/projects /etc/projid # mount -o prjquota /dev/xvm/var /var # xfs_quota -x -c 'project -s -p /var/log 42' /var # xfs_quota -x -c 'limit -p bhard=1g 42' /var
🌐
NERSC
docs.nersc.gov β€Ί filesystems β€Ί quotas
Quotas - NERSC Documentation
NERSC sets quotas on file systems shown in the table below. The table shows space quota, inode quota and Consequence for Exceeding Quota for each file system. An inode quota is a limit on the number of files and directories that can be created on a system, as each file and directory has an ...
🌐
Debian Manpages
manpages.debian.org β€Ί testing β€Ί xfsprogs β€Ί xfs_quota.8.en.html
xfs_quota(8) β€” xfsprogs β€” Debian testing β€” Debian Manpages
# rm -f /etc/projects /etc/projid # mount -o prjquota /dev/xvm/var /var # xfs_quota -x -c 'project -s -p /var/log 42' /var # xfs_quota -x -c 'limit -p bhard=1g 42' /var
🌐
Linux.org
linux.org β€Ί docs β€Ί man8 β€Ί xfs_quota.html
xfs_quota - manage use of quota on XFS filesystems at Linux.org
). Option -p adds possibility to specify project paths in command line without a need for /etc/projects to exist. Note that if projects file exists then it is also used. # echo logfiles:42 >> /etc/projid # xfs_quota -x -c 'project -s logfiles' /var # xfs_quota -x -c 'limit -p bhard=1g logfiles' /var Same as above without a need for configuration files. # rm -f /etc/projects /etc/projid # mount -o prjquota /dev/xvm/var /var # xfs_quota -x -c 'project -s -p /var/log 42' /var # xfs_quota -x -c 'limit -p bhard=1g 42' /var CAVEATS XFS implements delayed allocation (aka.
Find elsewhere
🌐
Weka
docs.weka.io β€Ί weka-filesystems-and-object-stores β€Ί quota-management β€Ί quota-management
Manage quotas using the CLI | W E K A
Use the following command to set a default quota of a directory: weka fs quota set-default <path> [--soft soft] [--hard hard] [--grace grace] [--owner owner] ... Path to the directory to set the quota.
Top answer
1 of 6
9

Here's a working example with the python code you cited:

Usage: tree.py -f [file limit] <directory>

If a number is specified for -f [file limit] then ... <additional files> is printed and the other files are skipped. Additional directories should not be skipped however. If the file limit is set to 10000 (default) this acts as no limit

#! /usr/bin/env python
# tree.py
#
# Written by Doug Dahms
# modified by glallen @ StackExchange
#
# Prints the tree structure for the path specified on the command line

from os import listdir, sep
from os.path import abspath, basename, isdir
from sys import argv

def tree(dir, padding, print_files=False, limit=10000):
    print padding[:-1] + '+-' + basename(abspath(dir)) + '/'
    padding = padding + ' '
    limit = int(limit)
    files = []
    if print_files:
        files = listdir(dir)
    else:
        files = [x for x in listdir(dir) if isdir(dir + sep + x)]
    count = 0
    for file in files:
        count += 1
        path = dir + sep + file
        if isdir(path):
            print padding + '|'
            if count == len(files):
                tree(path, padding + ' ', print_files, limit)
            else:
                tree(path, padding + '|', print_files, limit)
        else:
            if limit == 10000:
                print padding + '|'
                print padding + '+-' + file
                continue
            elif limit == 0:
                print padding + '|'
                print padding + '+-' + '... <additional files>'
                limit -= 1
            elif limit <= 0:
                continue
            else:
                print padding + '|'
                print padding + '+-' + file
                limit -= 1

def usage():
    return '''Usage: %s [-f] [file-listing-limit(int)] <PATH>
Print tree structure of path specified.
Options:
-f          Print files as well as directories
-f [limit]  Print files as well as directories up to number limit
PATH        Path to process''' % basename(argv[0])

def main():
    if len(argv) == 1:
        print usage()
    elif len(argv) == 2:
        # print just directories
        path = argv[1]
        if isdir(path):
            tree(path, ' ')
        else:
            print 'ERROR: \'' + path + '\' is not a directory'
    elif len(argv) == 3 and argv[1] == '-f':
        # print directories and files
        path = argv[2]
        if isdir(path):
            tree(path, ' ', True)
        else:
            print 'ERROR: \'' + path + '\' is not a directory'
    elif len(argv) == 4 and argv[1] == '-f':
        # print directories and files up to max
        path = argv[3]
        if isdir(path):
            tree(path, ' ', True, argv[2])
        else:
            print 'ERROR: \'' + path + '\' is not a directory'
    else:
        print usage()

if __name__ == '__main__':
    main()

When run, it should produce output similar to:

user@host /usr/share/doc $ python /tmp/recipe-217212-1.py -f 2 . | head -n 40
+-doc/
  |
  +-libgnuradio-fft3.7.2.1/
  | |
  | +-copyright
  | |
  | +-changelog.Debian.gz
  |
  +-libqt4-script/
  | |
  | +-LGPL_EXCEPTION.txt
  | |
  | +-copyright
  | |
  | +-... <additional files>
  |
  +-xscreensaver-gl/
  | |
  | +-copyright
  | |
  | +-changelog.Debian.gz
  | |
  | +-... <additional files>
2 of 6
12

One can use tree --filelimit=N to limit number of subdirectories/file to display. Unfortunately, this will not open directory which has more than N sub-directories and files.

For simple cases, when you have multiple directories and most have too many(say > 100) files, you can use tree --filelimit=100.

.
β”œβ”€β”€ A1
β”‚   β”œβ”€β”€ A2
β”‚   β”œβ”€β”€ B2
β”‚   β”œβ”€β”€ C2 [369 entries exceeds filelimit, not opening dir]
β”‚   └── D2 [3976 entries exceeds filelimit, not opening dir]
β”œβ”€β”€ B1
β”‚   └── A2
β”‚       β”œβ”€β”€ A3.jpeg
β”‚       └── B3.png
└── C1.sh

Note, if A1/C2 has a sub-directory A3, it will not be shown.

P.S. This is not a complete solution but will be quicker for few.