If I move the /home/... folders to a btrfs partition, can I still enable per user quota? That is, each user should be able to use a limited amount of storage.
Does btrfs support per user quota?
No, it doesn't.
If I move the /home/... folders to a btrfs partition, can I still enable per user quota? That is, each user should be able to use a limited amount of storage.
Yes, the trick is to use a subvolume for each home.
Btrfs supports subvolume quotas since Linux Kernel 3.6.
(Note that Ubuntu Precise has 3.2, Quantal has 3.5, Raring has 3.8, and note that you can install the Raring Hardware Enablement Stack on Precise, to have an updated kernel.)
Instructions to enable quotas are in the Btrfs FAQ, "How do we implement quota in BTRFS?". Subvolumes created after btrfs quota enable
support quotas automatically. Subvolumes created before btrfs quota enable
need manual intervention to support quotas.
- Mount the btrfs filesystem
- Enable quota:
btrfs quota enable mountpoint
- (If the filesystem already contains subvolumes, enable their quota support:)
- List the subvolume IDs with
btrfs subvolume list
. The number that followsID
(at the beginning of each line) is the subvolume's id. - Create a qgroup with
btrfs qgroup create 0/subvolume-id path-to-subvolume
(don't forget to replace thesubvolume-id
with the correct id) - Rescan the subvolumes, since the quota settings have been changed:
btrfs quota rescan
- List the subvolume IDs with
- Create new subvolumes that you need:
btrfs subvolume create mountpoint/subvolume-name
- Limit the subvolume usage:
btrfs qgroup limit 100G path-to-subvolume
- Profit.
Finally, set up /etc/fstab
to mount the subvolumes automatically at boot:
UUID=uuid-of-the-filesystem /home/mountpoint btrfs defaults,subvolid=subvolume-id 0 0
Alternatively, you may use LABEL=label
or /dev/sdxn
to refer to the btrfs filesystem.
To apply the changes to fstab
without rebooting: mount -a
No, Btrfs doesn't support user quota, It supports directory quota. So you can add quota for each user directory, but if you have shared directory with multiple users/groups then you can't set/count space for every user separately.
So you can't limit userX to be able to put 1MB of files in /home/shared
and another userY to be able to put 10MB of files in the same /home/shared
folder. But you can set different limits for /home/userX
and /home/userY
.
This is not user quota, but sub-volume quota. You can put multiple sub-volumes in single limit (for example user have /home/userX/
and /backups/userX/
then both can be under single limit.