You are on page 1of 29

RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  

STORAGE 78 I TecMint :

BEGINNER'S GUIDE FOR LINUX


Start learning Linux in minutes
How to
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  

Extend/Reduce
LVM’s (Logical
Volume
Management) in
Linux – Part II
by Babin Lonston | Published: August Vi/Vim Editor BEGINNER'S GUIDE
8, 2014 | Last Updated: June 27, 2017 Learn vi/vim as a Full Text Editor

SPONSORED SEARCHES

logical volume

linux create lvm

Download Your Free eBooks


NOW - 10 Free Linux eBooks for
Administrators | 4 Free Shell
Scripting eBooks

Previously we have seen how to


create a flexible disk storage
using LVM. Here, we are going to Linux Foundation Certification
Exam Study Guide to LFCS and LFCE
see how to extend volume group,
extend and reduce a logical
volume. Here we can reduce or
extend the partitions in Logical
How to Add Linux Host to Nagios Monitoring
volume management (LVM) also Server Using NRPE Plugin
called as flexible volume file-
system. How to Install Nagios 4.4.5 on RHEL/CentOS 8/7
and Fedora 30
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  
Install Cacti (Network Monitoring) on
RHEL/CentOS 8/7 and Fedora 30

How to Install Google Chrome 75 On RHEL/CentOS


7 and Fedora 30

How to Install Ubuntu Alongside With Windows 10


Extend/Reduce LVMs in Linux or 8 in Dual-Boot

Requirements
Create Flexible Disk Storage
with LVM – Part I

When do we need to
reduce volume?
May be we need to create a
separate partition for any other
use or we need to expand the
size of any low space partition, if
so we can reduce the large size
partition and we can expand the
low space partition very easily by
the following simple easy steps.

My Server Setup –
Requirements Linux System Administrator Bundle
with 7-Courses (96% off)
Operating System – CentOS
6.5 with LVM Installation Add to Cart - $69
Server IP – 192.168.0.200
Ending In: 3 days

Computer Hacker Professional


Certification Course (96% Off)
How to Extend Add to Cart Get
RedHat RHCSA and RHCE Certification Exam Study Ebook - $59
This Book  

Volume Group and Ending In: 4 days

Reduce Logical
Volume LINUX EBOOKS

◾ Introducing Learn Linux In One Week and Go


Logical Volume from Zero to Hero
Extending ◾ RedHat RHCE/RHCSA Certification Preparation
Guide
Currently, we have One PV, VG
◾ Linux Foundations LFCS/LFCE Certification
and 2 LV. Let’s list them one by Guide
one using following commands. ◾ Postfix Mail Server Setup Guide for Linux
◾ Ansible Setup Guide for Linux

# pvs ◾ Django Setup Guide for Linux

# vgs ◾ Awk Getting Started Guide for Beginners

# lvs ◾ Citrix XenServer Setup Guide for Linux

Never Miss Any Linux Tutorials,


Guides, Tips and Free eBooks
Join Our Community Of 150,000+ Linux Lovers
and get a weekly newsletter in your inbox

Logical Volume Extending


YES! SIGN ME UP

There are no free space available


in Physical Volume and Volume
group. So, now we can’t extend
the lvm size, for extending we
need to add one physical volume
(PV),RHCSA
RedHat and then weRHCE
and have Certification
to extend Exam Study Ebook Get This Book  
the volume group by extending
the vg. We will get enough space
to extend the Logical volume
size. So first we are going to add
one physical volume.

For adding a new PV we have to


use fdisk to create the LVM
partition.

# fdisk -cu /dev/sda

To Create new partition


Press n.
Choose primary partition use
p.
Choose which number of
partition to be selected to
create the primary partition.
Press 1 if any other disk
available.
RedHat Change
RHCSA the
andtype
RHCEusing t.
Certification Exam Study Ebook Get This Book  
Type 8e to change the
partition type to Linux LVM.
Use p to print the create
partition ( here we have not
used the option).
Press w to write the
changes.

Restart the system once


completed.

Create LVM Partition

List and check the partition we


have created using fdisk.

# fdisk -l /dev/sda

Verify LVM Partition


Next,RHCSA
RedHat create new PV (Physical
and RHCE Certification Exam Study Ebook Get This Book  
Volume) using following
command.

# pvcreate /dev/sda1

Verify the pv using below


command.

# pvs

Create Physical Volume

Extending Volume
Group
Add this pv to vg_tecmint vg to
extend the size of a volume
group to get more space for
expanding lv.

# vgextend vg_tecmint /dev/sda1


 
Let us
RedHat checkand
RHCSA the size
RHCE ofCertification
a Exam Study Ebook Get This Book  
Volume Group now using.

# vgs

Extend Volume Group

We can even see which PV are


used to create particular Volume
group using.

# pvscan

Check Volume Group

Here, we can see which Volume


groups are under Which Physical
Volumes. We have just added
one pv and its totally free. Let us
see the size of each logical
volume we have currently before
expanding it.
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  

Ad

Check All Logical Volume

LogVol00 defined for Swap.


LogVol01 defined for /.
Now we have 16.50 GB size
for / (root).
Currently there are 4226
Physical Extend (PE)
available.

Now we are going to expand the


/ partition LogVol01. After
expanding we can list out the
size as above for confirmation.
We can
RedHat extend
RHCSA andusing
RHCE GBCertification
or PE as Exam Study Ebook Get This Book  
I have explained it in LVM PART-I,
here I’m using PE to extend.

For getting the available Physical


Extend size run.

# vgdisplay

Check Available Physical Size

There are 4607 free PE available


= 18GB Free space available. So
we can expand our logical
volume up-to 18GB more. Let us
use the PE size to extend.

# lvextend -l +4607 /dev/vg_tecmint/LogVol01


 

Use + to add the more space.


After Extending, we need to re-
size the file-system using.
RedHat#RHCSA and RHCE
resize2fs Certification Exam Study Ebook
/dev/vg_tecmint/LogVol01 Get This Book  

 

Expand Logical Volume

Command used to extend


the logical volume using
Physical extends.
Here we can see it is
extended to 34GB from
16.51GB.
Re-size the file system, If the
file-system is mounted and
currently under use.
For extending Logical
volumes we don’t need to
unmount the file-system.

Now let’s see the size of re-sized


logical volume using.

# lvdisplay
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  

Resize Logical Volume

LogVol01 defined for /


extended volume.
After extending there is
34.50GB from 16.50GB.
Current extends, Before
extending there was 4226,
we have added 4607 extends
to expand so totally there are
8833.

Now if we check the vg available


Free PE it will be 0.

# vgdisplay

See the result of extending.


RedHat#RHCSA
pvs and RHCE Certification Exam Study Ebook Get This Book  

# vgs
# lvs

Verify Resize Partition

New Physical Volume added.


Volume group vg_tecmint
extended from 17.51GB to
35.50GB.
Logical volume LogVol01
extended from 16.51GB to
34.50GB.

Here we have completed the


process of extending volume
group and logical volumes. Let
us move towards some
interesting part in Logical volume
management.

Reducing Logical
Volume (LVM)
Here we are going to see how to
reduce the Logical Volumes.
Everyone
RedHat RHCSAsayand
its critical and may
RHCE Certification Exam Study Ebook Get This Book  
end up with disaster while we
reduce the lvm. Reducing lvm is
really interesting than any other
part in Logical volume
management.

Before starting, it is always


good to backup the data, so
that it will not be a headache
if something goes wrong.
To Reduce a logical volume
there are 5 steps needed to
be done very carefully.
While extending a volume we
can extend it while the
volume under mount status
(online), but for reduce we
must need to unmount the
file system before reducing.

Let’s wee what are the 5 steps


below.

unmount the file system for


reducing.
Check the file system after
unmount.
Reduce the file system.
Reduce the Logical Volume
size than Current size.
RedHat Recheck the RHCE
RHCSA and file system for
Certification Exam Study Ebook Get This Book  
error.
Remount the file-system
back to stage.

For demonstration, I have


created separate volume group
and logical volume. Here, I’m
going to reduce the logical
volume tecmint_reduce_test.
Now its 18GB in size. We need to
reduce it to 10GB without data-
loss. That means we need to
reduce 8GB out of 18GB. Already
there is 4GB data in the volume.

18GB ---> 10GB

While reducing size, we need to


reduce only 8GB so it will
roundup to 10GB after the
reduce.

# lvs

Reduce Logical Volume


HereRHCSA
RedHat we can and
see RHCE
the file-system
Certification Exam Study Ebook Get This Book  
information.

# df -h

Check File System Size

The size of the Volume is


18GB.
Already it used upto 3.9GB.
Available Space is 13GB.

First unmount the mount point.

# umount -v /mnt/tecmint_reduce_test/
 

Unmount Parition

Then check for the file-system


error using following command.
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  

Ad

# e2fsck -ff /dev/vg_tecmint_extra/tecmint_reduce_test


 

Scan Parition for Errors

Note: Must pass in every 5 steps


of file-system check if not there
might be some issue with your
file-system.

Next, reduce the file-system.

# resize2fs /dev/vg_tecmint_extra/tecmint_reduce_test 10GB


 

Reduce File System


Reduce
RedHat the Logical
RHCSA volume
and RHCE using Exam Study Ebook
Certification Get This Book  
GB size.

# lvreduce -L -8G /dev/vg_tecmint_extra/tecmint_reduce_test


 

Reduce Logical Partition

To Reduce Logical volume using


PE Size we need to Know the
size of default PE size and total
PE size of a Volume Group to put
a small calculation for accurate
Reduce size.

# lvdisplay vg_tecmint_extra
 

Here we need to do a little


calculation to get the PE size of
10GB using bc command.

1024MB x 10GB = 10240MB or 10GB

10240MB / 4PE = 2048PE


 
PressRHCSA
RedHat CRTL+D to RHCE
and exit from BC.
Certification Exam Study Ebook Get This Book  

Calculate PE Size

Reduce the size using PE.

# lvreduce -l -2048 /dev/vg_tecmint_extra/tecmint_reduce_test


 

Reduce Size Using PE

Re-size the file-system back, In


this step if there is any error that
means we have messed-up our
file-system.

# resize2fs /dev/vg_tecmint_extra/tecmint_reduce_test
 

Resize File System

Mount the file-system back to


same point.
RedHat#RHCSA
mountand RHCE Certification Exam Study Ebook Get This/mnt/tecmint_reduc
/dev/vg_tecmint_extra/tecmint_reduce_test Book  

 

Mount File System

Check the size of partition and


files.

# lvdisplay vg_tecmint_extra
 

Here we can see the final result


as the logical volume was
reduced to 10GB size.

Verify Logical Volume Size

In this article, we have seen how


to extend the volume group,
logical volume and reduce the
logical
RedHat volume.
RHCSA andInRHCE
the next part
Certification Exam Study Ebook Get This Book  
(Part III), we will see how to take
a Snapshot of logical volume and
restore it to earlier stage.

Sharing is Caring...
Share on Facebook

Share on Twitter

Share on Linkedin

Share on Reddit

If You
Appreciate
What We Do
Here On
TecMint, You
Should
Consider:

TecMint is the fastest


growing and most
trusted community
site for any kind of
Linux Articles, Guides
and Books on the
web. Millions of
people visit TecMint!
RedHat to search
RHCSA andorRHCE
browse
Certification Exam Study Ebook Get This Book  

the thousands of
published articles
available FREELY to
all.

If you like what you


are reading, please
consider buying us a
coffee ( or 2 ) as a
token of
appreciation.

We are thankful for


your never ending
support.

Tags: lvm

View all Posts


Babin Lonston
I'm Working as a
System
Administrator for
last 10 year's with 4
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  
years experience
with Linux
Distributions, fall in
love with text based
operating systems.

Your name can


also be listed
here. Got a
tip? Submit it
here to
become an
TecMint
author.

PREVIOUS NEXT

STORY STORY

Installing Kernel
MariaDB 3.16
10.1 in Released
Debian –
Jessie Compile
and and
Running Install
Various on
MariaDB Debian
Queries GNU/Linux
RedHatYOU MAYand
RHCSA ALSO LIKE...
RHCE Certification Exam Study Ebook Get This Book  

18 17 79

OwnClo
How to Create ud 9
Setup Centrali Release
DRBD to zed d–
Replicat Secure Create
e Storage Persona
Storage using l/Private
on Two iSCSI Cloud
CentOS Target Storage
7 on in Linux
Servers RHEL/C 19 FEB,

14 JAN,
entOS/F 2015

2019 edora
Part -I
14 JUL,
2014

78 RESPONSES

Comments 8

Pingbacks 0

Godwin Chanda
December 19, 2019 at 3:06 pm
Free-flowing explanation
from start to finish. Many
thanks.
Reply

Harsh
November 13, 2019 at 8:45 am
This was very helpful!!
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  
Thanks Babin!
Reply

Aditya Garg
August 17, 2019 at 11:53 am
In summary, to reduce ext
filesystem:
◾ unmount/mount at the
end
◾ fsck
◾ resize the filesystem
◾ lvreduce
◾ resize again to avoid
discrepancies between LV
and FS
◾ fsck
1 thru 5 are taken care by
single command: lvreduce -L
(size) -r /dev/mapper/vg-lv

As seen here:
https://access.redhat.com/documentation/en-
us/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/lv_reduce
 

The command performs


each of the steps (even
unmounts and mounts back)
Reply

Zak
July 10, 2019 at 12:24 am
Thanks, this was a very
helpful write up!
Reply

Bhargavi
June 12, 2019 at 5:20 pm
Hi,
I have created one hard disk
(sdc) and want to add in
(sdb) hard disk how to add in
command line in LVM please
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  
let me know.
Reply

Babin
March 25, 2019 at 10:23 pm
@Mihir,
Still, XFS did not provide an
option to reduce, but you can
grow the size on the fly.
Reply

Mihir Agrawal
March 21, 2019 at 8:50 pm
How to reduce xfs file
system?
Reply

Peter Haas
February 28, 2019 at 2:55 pm
It is worth mentioning if your
partition is xfs then you will
need to use ‘xfs_growfs‘.
xfs seems popular for later
releases of Centos.
Reply

« Older Comments

GOT SOMETHING TO SAY? JOIN


THE DISCUSSION.

Comment

Name * Email *
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  

Website

Save my name, email, and website


in this browser for the next time I
comment.

Notify me of followup
comments via e-mail. You can
also subscribe without
commenting.

Post Comment

This site uses Akismet to reduce


spam. Learn how your comment data
is processed.

LINUX MONITORING TOOLS LINUX INTERVIEW OPEN SOURCE TOOLS

QUESTIONS
Best Command Line
HTTP Clients for Linux
HowRHCSA
RedHat to Setupand
andRHCE Certification
15 BasicExam
MySQLStudy Ebook 21 Best Open Source
Get This Book  
Manage Log Rotation Interview Questions for Text Editors (GUI + CLI)
Using Logrotate in Linux Database Administrators in 2019

How to Configure 10 Useful ‘ls’ Command 11 Best Tools to Access


Custom Access and Error Interview Questions – Remote Linux Desktop
Log Formats in Nginx Part 2
My Favorite Command
Install Munin (Network Shilpa Nair Shares Her Line Editors for Linux –
Monitoring) in RHEL, Interview Experience on What’s Your Editor?
CentOS and Fedora RedHat Linux Package
Management 24 Outstanding Backup
CoreFreq – A Powerful Utilities for Linux
CPU Monitoring Tool for 11 Advance MySQL Systems in 2018
Linux Systems Database “Interview
Questions and Answers”
Nmon: Analyze and for Linux Users
Monitor Linux System
Performance 15 Interview Questions
on Linux “ls” Command –
Part 1

Tecmint: Linux Howtos, Tutorials & Guides ©


2020. All Rights Reserved.
The material in this site cannot be republished
either online or offline, without our permission.
Hosting Sponsored by : Linode Cloud Hosting
RedHat RHCSA and RHCE Certification Exam Study Ebook Get This Book  

You might also like