Linux Field
Linux Field
Submitted By:
Faculty Coordinator
Semester: IV
Submitted By:
Objectives:
As of the Red Hat Enterprise Linux 7.3 release, LVM supports log reports, which
contain a log of operations, messages, and per-object status with complete object
identification collected during LVM command execution
LVM provides a wide range of configuration and command line options to produce
customized reports and to filter the report's output.
Linear Volumes
A linear volume aggregates space from one or more physical volumes into one logical
volume. For example, if you have two 60GB disks, you can create a 120GB logical
volume. The physical storage is concatenated.
The physical volumes that make up a logical volume do not have to be the
same size. “Linear Volume with Unequal Physical Volumes” shows volume
group VG1 with a physical extent size of 4MB.
This volume group includes 2 physical volumes named PV1 and PV2. The
physical volumes are divided into 4MB units, since that is the extent size. In
this example, PV1 is 200 extents in size (800MB) and PV2 is 100 extents in
size (400MB).
You can create a linear volume any size between 1 and 300 extents (4MB to
1200MB). In this example, the linear volume named LV1 is 300 extents in size.
You can configure more than one linear logical volume of whatever size you require
from the pool of physical extents. “Multiple Logical Volumes” shows the same
volume group as in “Linear Volume with Unequal Physical Volumes”, but in this case
two logical volumes have been carved out of the volume group: LV1, which is 250
extents in size (1000MB) and LV2 which is 50 extents in size (200MB).
Multiple Logical Volumes
When you write data to an LVM logical volume, the file system lays the data out
across the underlying physical volumes. 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.
The following illustration shows data being striped across three physical volumes. In this
figure:
the first stripe of data is written to the first physical volume
the second stripe of data is written to the second physical volume
the third stripe of data is written to the third physical volume
the fourth stripe of data is written to the first physical volume
In a striped logical volume, the size of the stripe cannot exceed the size of an extent.
Striped logical volumes can be extended by concatenating another set of devices onto
the end of the first set. In order to extend a striped logical volume, however, there must
be enough free space on the set of underlying physical volumes that make up the
volume group to support the stripe.
For example, if you have a two-way stripe that uses up an entire volume group, adding
a single physical volume to the volume group will not enable you to extend the stripe.
Instead, you must add at least two physical volumes to the volume group. For more
information on extending a striped volume, “Extending a Striped Volume”.
A Detailed Explanation on LVM:
As we have already mentioned that the concept of using LVM is very much similar to
virtualization; therefore, its working is also more or less the same as virtualization.
All these partitions have a file system installed on them which can be used to manage
these partitions.
Format Control
Whether you use the pvs, lvs, or vgs command determines the default set of fields displayed
and the sort order. You can control the output of these commands with the following
arguments:
You can change what fields are displayed to something other than the default by using
the -o argument. For example, the following output is the default display for
the pvs command (which displays information about physical volumes).
# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 new_vg lvm2 a- 17.14G 17.14G
/dev/sdc1 new_vg lvm2 a- 17.14G 17.09G
/dev/sdd1 new_vg lvm2 a- 17.14G 17.14G
The following command displays only the physical volume name and size.
# pvs -o pv_name,pv_size
PV PSize
/dev/sdb1 17.14G
/dev/sdc1 17.14G
/dev/sdd1 17.14G
You can append a field to the output with the plus sign (+), which is used in
combination with the -o argument.
Adding the -v argument to a command includes some extra fields. For example,
the pvs -v command will display the DevSize and PV UUID fields in addition to the
default fields.
# pvs -v
Scanning for physical volume names
PV VG Fmt Attr PSize PFree DevSize PV UUID
/dev/sdb1 new_vg lvm2 a- 17.14G 17.14G 17.14G onFF2w-1fLC-ughJ-D9eB-
M7iv-6XqA-dqGeXY
/dev/sdc1 new_vg lvm2 a- 17.14G 17.09G 17.14G Joqlch-yWSj-kuEn-IdwM-
01S9-XO8M-mcpsVe
/dev/sdd1 new_vg lvm2 a- 17.14G 17.14G 17.14G yvfvZK-Cf31-j75k-dECm-
0RZ3-0dGW-tUqkCS
The --noheadings argument suppresses the headings line. This can be useful for
writing scripts.
The following example uses the --noheadings argument in combination with
the pv_name argument, which will generate a list of all physical volumes.
To keep the fields aligned when using the separator argument, use
the separator argument in conjunction with the --aligned argument.
For a full listing of display arguments, see the pvs(8), vgs(8) and lvs(8) man
pages.
Volume group fields can be mixed with either physical volume (and physical
volume segment) fields or with logical volume (and logical volume segment)
fields, but physical volume and logical volume fields cannot be mixed. For
example, the following command will display one line of output for each
physical volume.
# vgs -o +pv_name
VG #PV #LV #SN Attr VSize VFree PV
new_vg 3 1 0 wz--n- 51.42G 51.37G /dev/sdc1
new_vg 3 1 0 wz--n- 51.42G 51.37G /dev/sdd1
new_vg 3 1 0 wz--n- 51.42G 51.37G /dev/sdb1
The following is a summary of the steps to perform to create an LVM logical volume.
1. Initialize the partitions you will use for the LVM volume as physical volumes (this
labels them).
2. Create a volume group.
3. Create a logical volume.
After creating the logical volume you can create and mount the file system. The examples in
this document use GFS2 file systems.
1. Create a GFS2 file system on the logical volume with the mkfs.gfs2 command.
2. Create a new mount point with the mkdir command. In a clustered system, create the
mount point on all nodes in the cluster.
3. Mount the file system. You may want to add a line to the fstab file for each node in the
system.
Conclusion
This article provided you with a brief overview of logical volume management which
is a very important framework of the Linux operating system. Without this framework,
we have very limited options for managing our storage space.
Also, these options fail to resolve the conflicts between the varying storage needs of
multiple users. That is why LVM is considered as an essential component of the Linux
based systems.
Name of the Students Faculty Coordinator HoD
GOWRI SHANKAR TR
KANISHKA S
KARMEGA KUMAR A
PRATHEESH N
SENTHIL R
SHIVANI B
THARANI THARAN R