Created
July 6, 2017 14:04
-
-
Save turbo/1dcf08ce958636cee7cd35672636e366 to your computer and use it in GitHub Desktop.
Quickly create a size-limited directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
path=$1 | |
sizelimit=$2 | |
echo "Creating directory at $path, limited to $sizelimit MiB..." | |
mkdir "$path" 2>/dev/null || { exit; } | |
mkdir "/tmp/quotaimg" 2>/dev/null || { exit; } | |
dd if=/dev/zero of=/tmp/quotaimg/tmp.ext3 bs=1M count=$sizelimit | |
/sbin/mkfs -t ext3 -q /tmp/quotaimg/tmp.ext3 -F | |
sudo mount -o loop,rw,usrquota,grpquota /tmp/quotaimg/tmp.ext3 "$path" | |
# Delete with sudo umount "$path" && rm -rf /tmp/quotaimg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can now also optionally apply user fs quotas