How to set a file size limit for a directory? - Ask Ubuntu


i have directory on system used specific reason applications , users, don't want size allowed exceed 2gb, there way of setting sort of limit doesn't allow file size exceed or other amount decide set in future?

when size limit exceeded should undo last change (though there should option have stops operation , doesn't care if half file copied , left there) , display warning user.

i running ubuntu gnome 16.10 gnome 3.22.

usual filesystem quota on ext4 per-user/group, not per-directory. zfs can sort-of set directory quota, creating filesystem of fixed size off zfs volume. simple trick, though, create 2gb file, create filesystem on it, , mount @ desired folder:

$ touch 2gbarea $ truncate -s 2g 2gbarea $ mke2fs -t ext4 -f 2gbarea mke2fs 1.43.3 (04-sep-2016) discarding device blocks: done                             creating filesystem 524288 4k blocks , 131072 inodes filesystem uuid: bf1b2ee8-a7df-4a57-9d05-a8b60323e2bf superblock backups stored on blocks:      32768, 98304, 163840, 229376, 294912  allocating group tables: done                             writing inode tables: done                             creating journal (16384 blocks): done writing superblocks , filesystem accounting information: done   $ sudo mount 2gbarea     $ df -h filesystem      size  used avail use% mounted on /dev/loop0      2.0g  6.0m  1.8g   1% /home/muru/up 

in case, filesystem quotas (or methods this) aren't user friendly want. method one-way flexible, in can increase size online, decreasing hard.

the commands:

  • touch: touch 2gbarea creates empty file named 2gbarea.
  • truncate: truncate used resize files (in case, resize empty 2gbarea file 2 gb using -s 2g).
  • mke2fs: mke2fs creates ext2/3/4 filesystems (in case, ext4).
  • mount mounts filesystem on given directory.
  • df used list filesystem usage.

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User