What is Disk quota? –
A disk quota is a limit set by a system administrator that restricts certain aspects of file system usage on modern operating systems. The function of using disk quotas is to allocate limited disk space in a reasonable way. Quotas are used to manage storage in distributed environments. Disk quotas are abilities to manage and limit disk resources to those who abuse the system in the form of storage facility.
Disk quotas allow you to monitor the amount of disk space left against the limit assigned to individual users or groups. Disk quotas can be controlled by per volume, per user and per group. If you suspect that a particular user is using disk space to download files from the Internet and is consuming a considerable amount of space… limit their space with quotas.
About Partition –
Hard disk partitions: The disk available, now a days, are quite large. Partitions help us manage the disks easily. Also they help protect our system. Linux is organized into directories. We can mount different directories on different partitions.
Partition types: There are four ways of partitioning a hard disk-
Primary partition: We can have up to 4 different primary partitions on a single hard disk. One of these partitions should be marked as active, to boot the O.S. from. This partition can have the boot loader, such as LILO (Linux Loader) or GRUB (Grand Unified Boot Loader).
Extended partition: If the above four partitions are not just enough, then we can convert any of the primary partition into Extended partition. We can then subdivide this partition into multiple logical partitions, as we require. We cannot use extended partition directly i.e. we cannot mount a directory on it.
Logical partition: We use the extended partition by making logical partitions. Logical partitions are volumes or in Microsoft terms, these are the logical drives.
Swap partition: The swap partition is an exclusive are on the hard disk, which is used as virtual memory. Swap is not the different type of partition, but we can mount swap either on the primary or on the logical partition itself. Recommended size of swap partition is twice the amount of installed RAM.
Partition names: The first two letters of the disk name tell about the kind of disk we are using. For IDE hard disks the letters are hd and for SCSI or SATA disks the letters are sd.
The third letter tells the disk’s position on motherboard. For IDE or SATA it is as under:
1- Primary Master a 2- Primary Slave b
3- Secondary Master c 3- Secondary Slave d
And for SCSI, disks letters correspond to their designated ID numbers. For example,
1- SCSI with ID 0 a 2- SCSI with ID 1 b
Naming of CD and DVD drives has also been, categorized as the hard disk drives.
The fourth letter tells the type and position of the partition on hard disk. The primary partitions have numbers reserved as 1, 2, 3 and 4. The logical partitions get their numbers 5 onwards. Even if we have only one primary partition, the first logical partition will get its position number 5 only.
Typical partition names –
Name and details –
/dev/hdb2 the second primary partition on the hard disk on primary slave
/dev/hda8 the fourth logical partition on hard disk on primary master
/dev/sda1 the first primary partition on first SCSI disk or primary master SATA
/dev/hdc as this has no number; it means it is secondary master CD or DVD on IDE controller.
Red Hat Linux file system –
File system of any operating system used to be the structure, in which all the information on our system is stored. The file system is organized in hierarchy of directories, which may contain files or the subdirectories as well. These file system types determine how the information can be stored as files or as directory. In Linux there are following types file system, which we generally use: ext3, swap, LVM and RAID.
Linux file system structure –
Red Hat Linux organizes file into directories. The standard directories are as follows…
/ - This is top level root directory. The remaining directories are kept below this root (/) directory, i.e. these are subdirectories of root directory.
Note: / is different from root. Both are pronounced as root, but former is directory while later is a user with administrative privileges.
/root: This is the home directory for root user (administrator).
/home: This directory is place for keeping all the user’s home directories except root user.
/dev: This directory will list all available device drivers.
/mnt: It contains the mount points of removable media, like /mnt/cdrecorder
/etc: It contains the basic Linux configuration files related to passwords, X window and daemons etc.
/boot: It stores the file and commands to boot Linux on our system.
/bin: It has all the basic command line utilities.
/lib: It lists program libraries, which may be needed by different applications or Linux kernel.
/proc: It includes the kernel related processes which are running currently.
/initrd: It configures one empty directory which is used by Initial RAM disk during boot. We should not delete this directory; else we will not be able to boot the Linux system.
/sbin: It contains commands for system administration.
/var: It contains log file and print spools etc.
/usr: It contains programs and data which is available to all the users.
Assigning Quota on Linux –
STEP 1 –
At 1st see the information about the disk partition and disk space…
#fdisk -l
The above command is used for the getting information about the disk partition and disk space detail in linux operating system.
STEP 2 –
Then create a new partition on the disk. The methods of creating new partition in linux are following –
Steps in creating a new partition –
1. Install a fresh hard disk in the system.
2. Boot the system from already installed Red Hat Linux.
3. As root user, type the following command to check whether new disk has been detected.
# dmesg | less
In the output of this command, check for the device name. If the hard disk added was second SATA, then we should see something like sdb: Or, you can run the command.
# fdisk –l
Some where near the end of its output you should see a line like.
Disk /dev/sda doesn’t contain a valid partition table.
Disk /dev/sda doesn’t contain a valid partition table.
4. Now since you have come to the device name for this hard disk, you can run the following command to open up this hard disk:
# fdisk /dev/sda
If it is a completely new hard disk, you will see a message telling that this hard disk does not contain a valid partition table, as we saw in the previous command. If it doesn’t show it, this will mean that it is old hard disk.
5. We can get help of all the commands which can be used here. For these just press m on the prompt like Command (m for help):
6. To create new partition type n, as follows.
Command (m for help)
Command (m for help)
Command (n for new partition): n
7. Here you will be asked to choose primary or extended partition. To choose for primary partition, type the following:
Command action –
Extended primary partition (1-4): p
8. Now you will be asked for the partition number. If you are creating first partition, type one:
Partition number (1-4): 1
9. Now you will have to tell the cylinder number. Here just press ENTER, to accept default, or specify the desired number:
First cylinder (1-4865, default 6): 6
10. Lastly, either define the last cylinder, if you know, else define the space in MB. Default is last cylinder to use entire hard disk.
Last cylinder or +size or +sizeM or +sizeK (1-4865, default 4865): +5000M
11. Repeat the previous five steps to create more partitions on the disk.
12. Save changes to the disk using w, this will send you back to the shell.
13. At this point of time, to make the changes effective, just restart the system. Instead of restarting the system, you can run the partprobe command as well.
# Partprobe – (#partprobe /dev/sda)
14. Now we will have to make the file system on this partition, i.e. format the partition. To create an ext3 file system on the first partition of this disk, type the following:
# mkfs -t ext3 /dev/sda6 (6 – the partition number)
Alternatively, if you are formatting a partition for Linux swap space, you can use mkswap command, e.g. if you want to setup /dev/sdb2 as swap partition, you can run the following command:
#mkfs.ext3 /dev/sda6 or #mkfs -t ext3 /dev/sda6
16. To use the partition for quota or general use just created, make a directory to mount on it.
# mkdir /quota
STEP 3 –
Now for assigning the quota on the created partition; use following command –
#quotaoff /quota (/quota – is a directory on which you are going to mount it)
STEP 4 –
Now mount the created partition at the created directory.
For temporary mounting method
#mount /dev/sda6 /quota
For permanent mounting method
For mount the partition permanently edit the following lines in fstab file.
# vi /etc/fstab
And now edit following lines in the last of the file-
/dev/sda6 | /quota | ext3 | Defaults,userquota,grpquota | 1 2 |
STEP 5 –
For active the partition run the following command in the terminal-
#mount -a
And then remount the partition for assigning the quota successfully. Run the following command in the terminal.
#mount -o remount /quota
STEP 6 –
And the checking about the quota runs the following command.
#quotacheck -ucg /quota
(Here you will find every thing is okay)
And then run the following command for make on the quota.
#quotaon /quota (/quota – is a directory on which the disk partition is mounted)
STEP 7 –
Now configure the quota for users and groups. Run following command.
#edquota -u ram (user name)
You will find a file after this command. Edit the file as you need…
Soft link for – warning level of quota
Hard link for – limit level of quota
(Note - you can configure quota limitation as the cylinder space or number of files for that user or group)
#edquota -g ajay (group name)
The above command is used for the assigning quota for the group…
STEP 8 –
At last give the permission for quota.
#chmod 777 /quota (777 are for – full permission of the directory and the /quota is the directory on which the partition is mounted…
No comments:
Post a Comment