Welcome!
RH133
Red Hat Enterprise Linux
System Administration
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
2
Logical Volume Manager
3
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.
4
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.
5
Logical
VG ( Volume Group )
Volume
6
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.
7
Types of LVM
There are three types of LVM logical volumes: linear volumes, striped
volumes, and mirrored volumes.
8
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.
9
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.
10
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.
11
CREATING LINEAR LVM
12
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
00
Step-8 – Activate the new volume
mount -a
13
Check the newly mounted Logical Volume
For Short details
pvscan
lvscan
vgscan
For Long Full Details
pvdisplay
lvdisplay
vgdisplay
14
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
15
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
16
ADVANCE LVM ------------- extraaa
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
lvcreate
-l 100%FREE
-n
mylv
-n
testvg
yourlv
testvg
Creating Striped LVM
lvcreate
-L50G
-i2 -I64
-n
gfslv
vg0
17
ADVANCE LVM ------------- extraaa
Creating Mirror LVM
lvcreate
-L50G -m1
lvcreate
-L12MB
-n gfslv
-m1 --corelog
vg0
-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
18
Understanding RAID
19
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.
20
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.'
21
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
22
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.
23
RAID 0 Level
RAID 1 Level
RAID 5 Level
24
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
00
Step-5 – Activate the RAID
mount -a
Step-6 – Check the RAID
mdadm --detail /dev/md0
25
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
26
IMPLEMENTING DISK QUOTA
27
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.
28
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.
29
Applying Disk Quota
Step 1 - Open /etc/fstab file using vi editor
vi /etc/fstab
Step 2 - Add usrquota or grpquota to following line
LABEL=/home
/home
ext3
defaults,usrquota
Step 3 – Remount the /home folder or reboot your machine
mount –o remount /home
Step 4 – Create quota database file
quotacheck
–cug /home
00
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
30
Quota Commands
quota
repquota
:
edquota –t
edquota -g groupname
quotaoff -vaug
quotaon -vaug
:
:
:
:
:
Run by user to check quota status
Run by the root user to check the
quota status for every user
Assigns the grace period
Assigning Quotas on Group
Disabling quota on everyone
Enabling quota on everyone
31
?
Questions
">