• No se han encontrado resultados

Capítulo 1. La llegada del post-rock a España (1992-1996)

1.3. Primeros indicios de un post-rock español

1.3.1. El presentismo de la electrónica: Silvania

9.3.1 Understanding Disk Quotas

Quotas are used to limit a user's or a group of users' ability to consume disk space. This prevents a small group of users from monopolizing disk capacity and potentially interfering with other users or the entire system. Disk quotas are often used by ISPs, Web Hosting companies, on FTP sites, or on corporate file servers to ensure continued availability of their systems. Users can compromise availability by uploading files to the point of filling a file system (by default, there is nothing stopping this from happening). Once the file system is full, other users are effectively denied upload access to the disk (a denial of service). If the file system that fills is the root file system (/), this could also result in system instability or even a crash.

There are two limitations you can set up to manage disk consumption. You can limit the number of inodes a user may have, and you can also limit the number of disk blocks a user's files may consume. Linux uses one inode for each file a user has on a file system. Setting a maximum on the number of inodes a user may consume prevents

Linux Administration – Account Management Page 50 of 167

www.wilshiresoft.com Wilshire Software Technologies Rev Dt: 15-Oct-08 a user from creating an excessive number of files. By limiting the number of disk blocks a user may consume, you limit the total amount of storage a user may have regardless of how many files they may have (i.e., either a small number of large files, or a large number of small files).

We can use the following commands and their associated man pages:

quotaon /fs Enables quotas for the /fs file system.

quotaoff Disables quota tracking.

edquota name Edits the quota settings for user name. Can also be used to set defaults.

quota Allows users to see their current resource consumption and limits.

repquota Generates a report of disk consumption by all users for a quota-enabled file system.

quotacheck Scans a file system

9.3.2 Settingup and configuring the Quotas

Enter Single User Mode As we'll need to remount the /home filesystem it's best to ensure that no other users or processes are using it. This is best achieved by entering single user mode from the console. This may be unnecessary if you are certain that you're the only user on the system.

Entering single user mode will automatically log off all users and stop cron jobs. It is best to do this after hours in a business environment. Here is a quick procedure to do this:

1. Use the "who" command to see who's logged in. If there are any, besides yourself, send a message informing them that the system is about to shutdown with the "wall" command.

[root@skynet tmp]# who

root pts/0 Nov 6 14:46 (192-168-1-242.my-site.com) bob pts/0 Nov 6 12:01 (192-168-1-248.my-site.com) bunny pts/0 Nov 6 16:25 (192-168-1-250.my-site.com) [root@skynet tmp]# wall The system is shutting down now!

Broadcast message from root (pts/0) (Sun Nov 7 15:04:27 2004):

The system is shutting down now!

2. The next step is to log into the VGA console and enter single user mode.

[root@skynet tmp]# init 1 Edit your /etc/fstab File

The /etc/fstab file lists all the partitions that need to be auto-mounted when the system boots. You have to alert Linux that quotas are enabled on the filesystem by editing the /etc/fstab file and modifying the options for the /home directory. You'll need to add the usrquota option. In case you forget the name, the usrquota option is mentioned in the fstab man pages.

Old fstab

LABEL=/home /home ext3 defaults 1 2 New fstab

LABEL=/home /home ext3 defaults,usrquota 1 2

Remount The Filesystem

Editing the /etc/fstab file isn't enough, Linux needs to reread the file to get its instructions for /home. This can be done using the mount command with the "-o remount" qualifier.

[root@skynet tmp]# mount -o remount /home Get Out Of single user mode

Linux Administration – Account Management Page 51 of 167 Return to your original run state by using either the "init 3" or "init 5" commands. Continue to the next step once the system is back to its normal state.

Create The Partition Quota Configuration Files

The topmost directory of the filesystem needs to have an aquota.user file (Defines quotas by user) and/or a aquota.group file (Defines quotas by group). The man page for "quota" lists them at the bottom.

In this case we'll just enable "per user " quotas.

[root@skynet tmp]# touch /home/aquota.user [root@skynet tmp]# chmod 600 /home/aquota.user

9.3.3 Initialize The Quota Table

Editing the /etc/fstab file and remounting the file system only alerted Linux to the fact that the filesystem has quota capabilities. You have to generate a quota table, separate from the aquota files, which lists all the current allocations for each user on the file system. This table will then be automatically and transparently updated each time a file is modified. Linux compares the values in this table with the quota limitations the systems administrator has placed in the aquota files and will use this to determine whether the user has rights to having increased disk usage.

The table initialization is done using the quotacheck command. You'll get an error the first time you enter the command as Linux will realize that the aquota file wasn't created using one of the quota commands.

[root@skynet tmp]# quotacheck -vagum

quotacheck: WARNING - Quotafile /home/aquota.user was probably truncated. Can't save quota settings...

quotacheck: Scanning /dev/hda3 [/home] done quotacheck: Checked 185 directories and 926 files Edit The User's Quota Information

Now we need to edit the user's quota information. This is done with the edquota command which allows you to selectively edit a portion of the aquota.user file on a per user basis.

[root@skynet tmp]# edquota -u mp3user

The command will invoke the vi editor which will allow you to edit a number of fields.

Disk quotas for user mp3user (uid 503):

Filesystem blocks soft hard inodes soft hard /dev/hda3 24 0 0 7 0 0

Blocks: The amount of space in 1K blocks the user is currently using.

Inodes: The number of files the user is currently using.

Soft Limit: The maximum blocks/inodes a quota user may have on a partition. The role of a soft limit changes if grace periods are used. When this occurs, the user is only warned that their soft limit has been exceeded. When the grace period expires, the user is barred from using additional disk space or files. When set to zero, limits are disabled.

Hard Limit: The maximum blocks/inodes a quota user may have on a partition when a grace period is set.

Users may exceed a soft limit, but they can never exceed their hard limit.

In the example below we limit user mp3user to a maximum of 5 MB of data storage on /dev/hda3 (/home).

Disk quotas for user mp3user (uid 503):

Filesystem blocks soft hard inodes soft hard /dev/hda3 24 5000 0 7 0 0 Testing

Linux checks the total amount of disk space a user uses each time a file is accessed and compares it against the values in the quota file. If the values are exceeded, depending on the configuration, then Linux will prevent the creation of new files or the expansion of existing files to use more disk space.

Linux Administration – Account Management Page 52 of 167

www.wilshiresoft.com Wilshire Software Technologies Rev Dt: 15-Oct-08