Mittwoch, 18. April 2012

Building a playground quota system on linux

I wanted to get a bit of experience using the linux quota system. I had no extra partition or disk at hand, so I created a virtual file system image. First I needed a file for this:

dd if=/dev/zero of=disc.img bs=1k count=100000

Then I created a partition table and a partition on it (not quite shure if this is really nessessary) using fdisk:

fdisk disc.img

Then I created a filesystem on my virtual partition:

mkfs.ext3 disc.img

ignoring the warning, that my disc.img is not a block device. Note that other filesystems would be possible, but  LPIC1 (for which I am currently preparing) does not require ext4 or btrfs which would be more modern filesystems. This might change soon though. I hear new exams are comming this summer.

Then I mounted it with the option for user quotas:

mkdir mnt
sudo mount  -o loop,usrquota disc.img mnt

Then I needed to create a quota file. This is a file wich resides at the root of the filesystem for which we want to use quotas. It can be done like this:

sudo quotacheck -u mnt/

This creates a  aquota.user file, which enables quotas for users. Now I set a quota


sudo setquota -u isaac 1000 10000 100 200 mnt/

following the syntax
 setquota -u user  <block-softlimit> <block-hardlimit> <inode-softlimit> <inode-hardlimit>

Keine Kommentare:

Kommentar veröffentlichen