0% found this document useful (0 votes)
31 views10 pages

Extending LVM on CentOS 7

Module7 discusses Logical Volume Management (LVM) in Linux. LVM allows combining physical volumes from multiple disks into a volume group. Logical volumes can then be created from the volume group, providing flexibility to resize partitions without data loss. It summarizes the key benefits of LVM as increased abstraction, flexibility and control over disk space management.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views10 pages

Extending LVM on CentOS 7

Module7 discusses Logical Volume Management (LVM) in Linux. LVM allows combining physical volumes from multiple disks into a volume group. Logical volumes can then be created from the volume group, providing flexibility to resize partitions without data loss. It summarizes the key benefits of LVM as increased abstraction, flexibility and control over disk space management.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Module7:LVM (Logical Volume Management)

LVM (Logical Volume Management) is basically a tool that provides logical volume
management for the Linux kernel. It is being introduced simply to make physical
storage device management easier. It also includes allocating disks, striping,
mirroring, resizing logical volumes. Its main advantages are increased abstraction,
flexibility, and control. It simply allows for flexible disk space management. It is
especially required to resize the size of the file system online. In Linux, the size of
the LVM partition can be extended using “lvextend” command

Logical Volume Manager (LVM):

 Combining two or more physical volumes (partitions)from two or more HDDs


making a group called as “Volume Group” and dividing Volume group into
small parts called as “Logical Volumes”
 By using LVM ,If you require large amount of partition you can create
 By using LVM ,You can increase partition (Logical Volume) size without loss
of data ,by adding a new disk / physical volume to Volume Group .
 But LVM do not support fault tolerance
Steps for creating LVM :

 Step1 : Create two more partitions from HDD1 / HDD2


 Step2 : Create Physical Volumes (#pvcreate )
 Step3 : Create Volume Group (#vgcreate)
 Step4 : Create Logical Volume in a Volume Group (#lvcreate)
 Step5 : Format Logical Volume (#mkfs.ext3 )
 Step6 : Mount the Logical Volume (#mount)
Checking Partitions by using “fdisk” :

root@localhost ~]# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes


255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1288 10241437+ 83 Linux
/dev/sda3 1289 1543 2048287+ 82 Linux swap / Solaris
/dev/sda4 1544 1666 987997+ 83 Linux

Disk /dev/sdb: 21.4 GB, 21474836480 bytes


255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sdb1 1 366 2939863+ 83 Linux
/dev/sdb2 367 610 1959930 83 Linux
[root@localhost ~]#

Creating Physical Volumes :

[root@localhost ~]# pvcreate /dev/sda4 /dev/sdb1


Physical volume "/dev/sda4" successfully created
Physical volume "/dev/sdb1" successfully created
[root@localhost ~]#
44
Checking Physical Volumes :

[root@localhost ~]# pvdisplay

--- NEW Physical volume ---


PV Name /dev/sda4
VG Name
PV Size 964.84 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID uWHvL3-T0F2-bwQL-r3ll-fD2w-xQYZ-ivMnH0

--- NEW Physical volume ---


PV Name /dev/sdb1
VG Name
PV Size 2.80 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID jibguB-4P2o-FHx8-HQRD-zZSq-fLUo-3AkpGX

[root@localhost ~]#

Creating Volume Group :

[root@localhost ~]# vgcreate mydata /dev/sda4 /dev/sdb1


Volume group "mydata" successfully created
[root@localhost ~]#

4
4
45
Verifying Volume Group :

[root@localhost ~]# vgdisplay


--- Volume group ---
VG Name mydata
System ID
Format lvm2
Metadata Areas
2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 3.74 GB
PE Size 4.00 MB
Total PE 958
Alloc PE / Size 0/0
Free PE / Size 958 / 3.74 GB
VG UUID 4fEcVZ-G7sF-00W2-nm3Z-B16k-qHwe-RevZPi

[root@localhost ~]#

Creating Logical Volume :

[root@localhost ~]# lvcreate -L 500mb mydata -n itdept


Logical volume "itdept" created

Verifying Logical Voumes :

[root@localhost ~]# lvdisplay


--- Logical volume ---
LV Name /dev/mydata/itdept
VG Name mydata
LV UUID 6VPpkz-CcTv-YeAq-sQX6-2f0m-6r3q-duRAZI
LV Write Access read/write
LV Status available
# open 0
LV Size 500.00 MB
Current LE 125
Segments 1
Allocation inherit
Read ahead sectors
0
Block device 253:0

[root@localhost ~]#

4
46
Formatting Logical Volume :

[root@localhost ~]# mkfs.ext3 /dev/mydata/itdept


mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
128016 inodes, 512000 blocks
25600 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
63 block groups
8192 blocks per group, 8192 fragments per group
2032 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done


Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 29 mounts or


180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]#

Mounting Logical Volume:

[root@localhost ~]# mkdir /itdeptdata


[root@localhost ~]# mount /dev/mydata/itdept /itdeptdata
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.5G 2.6G 6.5G 28% /
/dev/sda1 99M 9.9M 84M 11% /boot
tmpfs 506M 0 506M 0% /dev/shm
/dev/mapper/mydata-itdept
485M 11M 449M 3% /itdeptdata
[root@localhost ~]#

4
6
47
Extending “/dev/mydata/itdept” Logical Volume Size:

Steps for Extending Logical Volume Size :


 Step1 : Add a New HDD or if existed HDD has free space ,create a new partition
 Step2 : Create a physical volume (#pvcreate)
 Step3 : Extend(Add) physical volume into Volume Group (#vgextend)
 Step4 : Resize (increase) logical volume (#lvresize)
 Step5 : Arrange file system for logical volume (#resize2fs)
 Step6 : Verifying Logical Volume Size (#lvdisplay)

Extending Logical Volume Size :


Step1 : Creating a new
partition : [root@localhost ~]#
fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes


255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1288 10241437+ 83 Linux
/dev/sda3 1289 1543 2048287+ 82 Linux swap / Solaris
/dev/sda4 1544 1666 987997+ 83 Linux

Disk /dev/sdb: 21.4 GB, 21474836480 bytes


255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sdb1 1 366 2939863+ 83 Linux
[root@localhost ~]#

4
7
/dev/sdb2 367 610 1959930 83 Linux

[root@localhost ~]#
Step2 : Create a physical volume :

[root@localhost ~]# pvcreate


/dev/sdb2
Physical volume "/dev/sdb2" successfully created
[root@localhost ~]#

Step3 : Extend(Add) physical volume into Volume Group:

[root@localhost ~]# vgextend mydata /dev/sdb2


Volume group "mydata" successfully extended
[root@localhost ~]#

Step4 : Resize (increase) logical volume:

[root@localhost ~]# lvresize -L +450M /dev/mydata/itdept


Rounding up size to full physical extent 452.00 MB
Extending logical volume itdept to 952.00 MB
Logical volume itdept successfully resized
[root@localhost ~]#

Step5 : Arrange file system for logical volume:

[root@localhost ~]# resize2fs /dev/mydata/itdept


resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mydata/itdept is mounted on /itdeptdata; on-line resizing required
Performing an on-line resize of /dev/mydata/itdept to 974848 (1k) blocks.
The filesystem on /dev/mydata/itdept is now 974848 blocks long.

Step6 : Verifying Logical Volume Size:

[root@localhost ~]# lvdisplay


--- Logical volume ---
LV Name /dev/mydata/itdept
VG Name mydata
LV UUID 6VPpkz-CcTv-YeAq-sQX6-2f0m-6r3q-duRAZI
LV Write Access read/write
LV Status available
# open 1
LV Size 952.00 MB
Current LE 238
Segments 1
Allocation inherit
Read ahead sectors
0

[root@localhost ~]#

4
8
Block device 253:0

[root@localhost ~]#

Common questions

Powered by AI

'vgextend' is used to add more physical volumes to an existing volume group, essentially expanding the pool of available disk space. This is significant because it allows for scaling storage solutions without downtime. By adding new disks to a volume group, you can subsequently extend logical volumes as needed. It implies increased flexibility in storage management, as more space can be allocated to different logical volumes to meet changing storage demands .

'fdisk' is used to create and manage disk partitions, a preliminary requirement before setting up LVM. During the initial creation of physical volumes, 'fdisk' ensures proper partitioning structure, which LVM can then use to define physical volumes. Throughout the lifecycle of disk management, 'fdisk' offers verification and modification capabilities essential for maintenance and expansion, providing a foundational tool for disk readiness before further LVM processes occur .

Creating a Logical Volume involves several critical steps: (1) creating partitions on HDDs, (2) creating physical volumes using 'pvcreate', (3) forming a volume group with 'vgcreate', (4) creating the logical volume within this group using 'lvcreate', (5) formatting the logical volume using a command like 'mkfs.ext3', and (6) mounting it for use. Each step is crucial: physical volumes are the raw disk partitions, volume groups aggregate these into a usable pool of storage, and logical volumes are the actual partitions used by the system. Each step builds on the previous, ensuring that the volume is ready for data storage and management .

In LVM, physical volumes form the fundamental storage blocks, which are abstracted into volume groups acting as larger aggregated storage pools. Logical volumes are carved out of these groups and are flexible in size. This abstraction allows for dynamic resizing and makes storage provision seamless, eliminating the constraints of fixed-size partitions in traditional methods. Logical volumes can be expanded or reduced without impacting data integrity, facilitating efficient space utilization and management .

'resize2fs' is used to resize the filesystem to match the new size of an extended logical volume. The benefit is that it allows the filesystem to fully utilize the space available on the logical volume, avoiding wasted disk space. However, the trade-off is that resizing operations, especially for large filesystems, can be time-consuming and require careful planning to avoid data corruption or accidental data loss. Nonetheless, 'resize2fs' ensures that extended logical volumes can fully serve expanding data needs .

'lvextend' is used to increase the size of an existing logical volume within the volume group. It solves the problem of dynamic disk space allocation, allowing administrators to resize file systems online, without unmounting them. This is particularly useful in environments where uptime is critical and disk space requirements change frequently. The ability to extend a logical volume without data loss makes it a powerful tool in managing dynamic storage needs .

One key limitation of LVM is its lack of built-in fault tolerance. This impacts systems that require high availability because LVM doesn't inherently protect against disk failure; if a physical disk in a volume group fails, data could be lost unless additional protective measures such as hardware RAID or backups are implemented. This limitation means that while LVM excels in flexibility and space management, it falls short in environments that require resilience against hardware failures .

LVM provides increased abstraction, flexibility, and control over disk management. It allows for easy resizing of logical volumes, supports combining multiple physical volumes into a single volume group, and enables better management of disk space without downtime. Unlike traditional disk management, LVM supports on-the-fly resizing of partitions, which can be extended without data loss by adding new disks or physical volumes. However, it does not support fault tolerance, which is a consideration when planning storage solutions .

Mounting a logical volume is vital as it integrates the formatted filesystem into the system hierarchy, making it accessible for storage operations. Without mounting, the system cannot interact with the logical volume to store or retrieve data. This step is critical because it transitions the volume from a virtual construct within the LVM to an active part of the system's storage infrastructure, ready for application use and user interaction .

'vgdisplay' reveals metadata, including volume group size and metadata areas, which are crucial for LVM operations. Metadata management impacts the ability to monitor, manage, and modify storage allocations within LVM. Proper handling of metadata ensures the integrity and efficiency of volume group operations, affecting how volume activities are tracked and implemented. Poor metadata management can result in misallocation or data access issues, highlighting the need for precise control that metadata offers .

You might also like