You are on page 1of 2

Manual of the Experiment-10

Configuring and Securing Open-ssh Service and Managing Networking

Introduction: Logical Volume Management (LVM) makes it easier to manage disk space. If a file system
needs more space, it can be added to its logical volumes from the free spaces in its volume group and
the file system can be re-sized as we wish. If a disk starts to fail, replacement disk can be registered as
a physical volume with the volume group and the logical volumes extents can be migrated to the new
disk without data loss.

LVM have 3 concepts: -

• Physical Volume (PV)


• Volume Group (VG)
• Logical Volume (LV)

Physical Volume: - it is a whole disk or a partition of a disk. Physical volume is the actual storage device
that will be used in the LVM configuration. It can be an entire disk, a partition on disk.
Commands:
1. To create a physical volume: pvcreate
In the following example I have added disk /dev/sda of 1 GB each.
Example: pvcreate -v /dev/sda
2. Display physical volume
For displaying the physical volume of our disk pvs (list the newly created PV) and pvdisplay (it get
detailed information about each Physical Volumne) commands can be used.
Example: pv
Example: pvdisplay /dev/sda

Volume group: - Physical volumes are combined into volume groups (VGs). It creates a pool of disk
space out of which logical volumes can be allocated.
Commands:
1. To create a volume group:
In order to create a volume group, vgcreate command can be used.
Example: vgcreate -s 16M cossvg /dev/sda
-s option - Sets the physical extent size on physical volumes of this volume group.
2. To display a volume group
In order to display the volume group, vgs and vgdisplay is used.
Logical volume: - A volume group is divided up into logical volumes. So, if you have created ‘cossvg’
earlier then you can create logical volumes from that VG. The amount of space you want to allocate
depends on your requirement. You might want to create LV of 200MB, 1GB etc.
Syntax: - lvcreate -l 30 -v -n cosslv cossvg
Option n- is used to indicate a name for the LV.
Option v- it creates the virtual size of the device
Option L- Gives the size to allocate for the new logical volume (fixed size).
Option l- is used to indicate a percentage of the remaining space in the container vg and give the
size of vg.
2. To display a volume group
lvs and lvdisplay command is used.
a) You can extend and reduce the logical volume:
Extend- lvextend -L +300M /dev/cossvg/cosslv
Reduce- lvreduce -L 200M /dev/cossvg/cosslv
Delete- lvdelete /dev/cossvg/cosslv
b) create filesystem to extend and reduce of logical volume:
We’ll use ‘vfat’ since it allows us both to increase and reduce the size of each LV.
Syntax- mkfs.vfat /dev/cossvg/cosslv
mkfs- make file system
c) make directory – mkdir /mnt/storage:
d) open the vim – vim /etc/fstab after open vim we write:
/dev/cossvg/cosslv /mnt/storage/ vfat defaults 0 0
Save and quit it.
e) give permission by mount command:
mount -a
f) show the logical volume – lsblk(list of file system)

You might also like