32
RH133 Red Hat Enterprise Linux System Administration Welcome!

Lvm Raid Quota

Embed Size (px)

DESCRIPTION

linux

Citation preview

Page 1: Lvm Raid Quota

RH133

Red Hat Enterprise Linux System Administration

Welcome!

Page 2: Lvm Raid Quota

2

Objectives

Logical Volume Manager Using LVM Formatting and Mounting LVM Resizing LVM

Understanding RAID Creating RAID Volumes Managing RAID Volumes

Disk Quota Management Appling Quota Grace Period

Page 3: Lvm Raid Quota

3

Logical Volume Manager

Page 4: Lvm Raid Quota

4

What is LVM?

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.

With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks.

The physical volumes are combined into logical volumes, with the exception of the /boot/ partition. The /boot/ partition cannot be on a logical volume group because the boot loader cannot read it. If the root (/) partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group.

Page 5: Lvm Raid Quota

5

LVM Terms

Physical Volume: A physical volume (PV) is another name for a regular physical disk partition that is used or will be used by LVM.

Volume Group: Any number of physical volumes (PVs) on different

disk drives can be added together into a volume group (VG).

Logical Volumes: Volume groups must then be subdivided into logical

volumes. Each logical volume can be individually formatted as if it were

a regular Linux partition. A logical volume is, therefore, like a virtual

partition on your virtual disk drive.

Page 6: Lvm Raid Quota

6

Logical VolumeVG ( Volume Group )

Page 7: Lvm Raid Quota

7

LVM Physical Volume Layout

• LVM label is placed in the second 512-byte sector.

• An LVM label provides correct identification and device ordering for a physical device, since devices can come up in any order when the system is booted. The LVM label identifies the device as an LVM physical volume. It contains a random unique identifier (the UUID) for the physical volume. It also stores the size of the block device in bytes, and it records where the LVM metadata will be stored on the device.

• LVM metadata is small and stored as ASCII.

Page 8: Lvm Raid Quota

8

There are three types of LVM logical volumes: linear volumes, striped volumes, and mirrored volumes.

Types of LVM

Page 9: Lvm Raid Quota

9

Linear LVM

• A linear volume aggregates multiple physical volumes into one logical volume. So, if we have two 60GB disks, you can create a 120GB logical volume. The physical storage is concatenated.

Page 10: Lvm Raid Quota

10

Striped LVM

• You can control the way the data is written to the physical volumes by creating a striped logical volume. For large sequential reads and writes, this can improve the efficiency of the data I/O.

• Striping enhances performance by writing data to a predetermined number of physical volumes in round-round fashion.

Page 11: Lvm Raid Quota

11

Mirrored LVM

• A mirror maintains identical copies of data on different devices. When data is written to one device, it is written to a second device as well, mirroring the data. This provides protection for device failures. When one leg of a mirror fails, the logical volume becomes a linear volume and can still be accessed.

Page 12: Lvm Raid Quota

12

CREATING LINEAR LVM

Page 13: Lvm Raid Quota

13

Step-1 – Create two Partitions of 500 MB each using FDISK and set type as LINUX LVM

Step-2 – Create Physical Volumes pvcreate /dev/hda8 /dev/hda9 Step-3 – Create Volume Group vgcreate VG1 /dev/hda8 /dev/hda9 Step-4 – Change Volume Group to ACTIVE vgchange -a y VG1 Step-5 – Create Logical Volume lvcreate -L +600M -n LV1 VG1 Step-6 – Format the Logical Volume mkfs.ext3 /dev/VG1/LV1 Step-7 – Mount in /etc/fstab /dev/VG1/LV1 /mnt/data ext3 defaults 0 0 Step-8 – Activate the new volume mount -a

Page 14: Lvm Raid Quota

14

Check the newly mounted Logical Volume

For Short details pvscan lvscan vgscan

For Long Full Details pvdisplay lvdisplay vgdisplay

Page 15: Lvm Raid Quota

15

RESIZING THE LVM - INCREASE Step-1 – Umount the LVM umount /mnt/data Step-2 – Resize the LVM lvextend -L +200M /dev/VG1/LV1 Step-3 – Make the LVM active vgchange -a y VG1 Step-4 – Update the /etc/fstab for new size mount /mnt/data Step-5 – Configuring the HDD for new extended space resize2fs /dev/VG1/LV1

Page 16: Lvm Raid Quota

16

RESIZING THE LVM - REDUCE Step-1 – Umount the LVM umount /mnt/data Step-2 – Check the LV for any inconsistencies fsck -f /dev/VG1/LV1 Step-3 – Reduce the file-system first resize2fs /dev/VG1/LV1 100M Step-4 – Now reduce the Logical Volume lvreduce /dev/VG1/LV1 -L 100M Step-5 – Mount the volume again mount /mnt/data

Page 17: Lvm Raid Quota

17

Renaming a Volume Group

vgrename /dev/vg02 /dev/my_volume_group

vgrename vg02 my_volume_group

Creating LVM by percentage % of free space

lvcreate -l 60%VG -n mylv testvg

lvcreate -l 100%FREE -n yourlv testvg

Creating Striped LVM

lvcreate -L50G -i2 -I64 -n gfslv vg0

ADVANCE LVM ------------- extraaa

Page 18: Lvm Raid Quota

18

Creating Mirror LVM

lvcreate -L50G -m1 -n gfslv vg0

lvcreate -L12MB -m1 --corelog -n ondiskmirvol bigvg

Changing LVM Type

lvconvert -m1 vg00/lvol1 ---- converting linear to mirror

lvconvert -m0 vg00/lvol1 ---- converting mirror to linear

Changing Permission of LVM

lvchange -pr vg00/lvol1 ---- changing LVM to read-only

ADVANCE LVM ------------- extraaa

Page 19: Lvm Raid Quota

19

Understanding RAID

Page 20: Lvm Raid Quota

20

What is RAID ?

The basic idea behind RAID is to combine multiple small, inexpensive disk drives into an array to accomplish performance or redundancy goals not attainable with one large and expensive drive. This array of drives appears to the computer as a single logical storage unit or drive.

RAID allows information to access several disks. RAID uses techniques such as disk striping (RAID Level 0), disk mirroring (RAID Level 1), and disk striping with parity (RAID Level 5) to achieve redundancy, lower latency, increased bandwidth, and maximized ability to recover from hard disk crashes.

RAID consistently distributes data across each drive in the array. RAID then breaks down the data into consistently-sized chunks (commonly 32K or 64k, although other values are acceptable). Each chunk is then written to a hard drive in the RAID array according to the RAID level employed. When the data is read, the process is reversed, giving the illusion that the multiple drives in the array are actually one large drive.

Page 21: Lvm Raid Quota

21

RAID Levels

RAID 0 This level of RAID makes it faster to read and write to the hard drives.

However, RAID 0 provides no data redundancy. It requires at least two

hard disks.

Reads and writes to the hard disks are done in parallel, in other words,

to two or more hard disks simultaneously. All hard drives in a RAID 0

array are filled equally. But since RAID 0 does not provide data

redundancy, a failure of any one of the drives will result in total data

loss. RAID 0 is also known as 'striping without parity.'

Page 22: Lvm Raid Quota

22

RAID Levels RAID 1 This level of RAID mirrors information to two or more other disks. In

other words, the same set of information is written to two different hard

disks. If one disk is damaged or removed, you still have all of the data

on the other hard disk. The disadvantage of RAID 1 is that data has to

be written twice, which can reduce performance.

And it is expensive. To support RAID 1, you need an additional hard

disk for every hard disk worth of data. RAID 1 is also known as disk

mirroring

Page 23: Lvm Raid Quota

23

RAID Levels

RAID 5 Distributes, or 'stripes,' parity information evenly across all the disks. If

one disk fails, the data can be reconstructed from the parity data on the

remaining disks. RAID does not stop; all data is still available even after

a single disk failure. RAID level 5 is the preferred choice in most cases:

the performance is good, data integrity is ensured, and only one disk's

worth of space is lost to parity data. RAID 5 is also known as disk

striping with parity. This set of RAID requires at least 3 Disks.

Page 24: Lvm Raid Quota

24

RAID 5 Level

RAID 1 Level

RAID 0 Level

Page 25: Lvm Raid Quota

25

Creating RAID Volumes Step-1 – Create three partitions of 500MB each and set the type as

LINUX RAID using fdisk Step-2 – Create RAID-5 using mdadm mdadm – C /dev/md0 -l 5 -n 3 /dev/hda8 /dev/hda9 /dev/hda10 Step-3 – Format the RAID mkfs.ext3 /dev/md0 Step-4 – Mount the RAID volume ---- /etc/fstab /dev/md0 /mnt/data ext3 defaults 0 0 Step-5 – Activate the RAID mount -a Step-6 – Check the RAID mdadm --detail /dev/md0

Page 26: Lvm Raid Quota

26

Recovering from HDD failure

Step-1 – Making a error disk mdadm --manage /dev/md0 --fail /dev/hda10 Step-2 – Removing the faulty disk/partition mdadm --manage /dev/md0 --remove /dev/hda10 Step-3 – Adding new partition mdadm --manage /dev/md0 --add /dev/hda10

Page 27: Lvm Raid Quota

27

IMPLEMENTING DISK QUOTA

Page 28: Lvm Raid Quota

28

What is Disk Quota ?

Disk space can be restricted by implementing disk quotas which alert a system administrator before a user consumes too much disk space or a partition becomes full.

Disk quotas can be configured for individual users as well as user groups.

In addition, quotas can be set not just to control the number of disk blocks consumed but to control the number of inodes (data structures that contain information about files in UNIX file systems). Because inodes are used to contain file-related information, this allows control over the number of files that can be created.

Page 29: Lvm Raid Quota

29

Configuring Disk Quota

To implement disk quotas, use the following steps:

1. Enable quotas per file system by modifying the /etc/fstab file.

2. Remount the file system(s).

3. Create the quota database files and generate the disk usage table.

4. Assign quota policies.

Page 30: Lvm Raid Quota

30

Applying Disk Quota Step 1 - Open /etc/fstab file using vi editor vi /etc/fstab Step 2 - Add usrquotausrquota or grpquotagrpquota to following line LABEL=/home /home ext3 defaults,usrquotausrquota 0 0 Step 3 – Remount the /home folder or reboot your machine mount –o remount /home Step 4 – Create quota database file quotacheck –cug /home

quotaon -vug /home Step 5 – Apply the quota to a user / group using following command edquota –u username or setquota -u username softHDDlimit hardHDDlimit softINODElimit

hardINODElimit /location

Page 31: Lvm Raid Quota

31

Quota Commands quota : Run by user to check quota status repquota : Run by the root user to check the

quota status for every user edquota –t : Assigns the grace period edquota -g groupname : Assigning Quotas on Group quotaoff -vaug : Disabling quota on everyone quotaon -vaug : Enabling quota on everyone

Page 32: Lvm Raid Quota

?Questions