Professional Documents
Culture Documents
com/2010/08/how-to-create-lvm/
Home
About
Free eBook
Archives
Best of the Blog
Contact
8 Like 6 Tweet 6
With LVM, we can create logical partitions that can span across one or more physical hard drives.
First, the hard drives are divided into physical volumes, then those physical volumes are combined
together to create the volume group and finally the logical volumes are created from volume group.
The LVM commands listed in this article are used under Ubuntu Distribution. But, it is the same for
other Linux distributions.
1 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
Select the Physical Storage Devices for LVM – Use pvcreate, pvscan, pvdisplay
Commands
In this step, we need to choose the physical volumes that will be used to create the LVM. We can
create the physical volumes using pvcreate command as shown below.
As shown above two physical volumes are created – /dev/sda6 and /dev/sda7.
If the physical volumes are already created, you can view them using the pvscan command as shown
below.
$ sudo pvscan
PV /dev/sda6 lvm2 [1.86 GB]
PV /dev/sda7 lvm2 [1.86 GB]
Total: 2 [3.72 GB] / in use: 0 [0 ] / in no VG: 2 [3.72 GB]
You can view the list of physical volumes with attributes like size, physical extent size, total physical
extent size, the free space, etc., using pvdisplay command as shown below.
$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda6
VG Name
PV Size 1.86 GB / not usable 2.12 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 476
Free PE 456
Allocated PE 20
2 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
PV UUID m67TXf-EY6w-6LuX-NNB6-kU4L-wnk8-NjjZfv
Note : PE – Physical Extents are nothing but equal-sized chunks. The default size of extent is 4MB.
Volume groups are nothing but a pool of storage that consists of one or more physical volumes. Once
you create the physical volume, you can create the volume group (VG) from these physical volumes
(PV).
In this example, the volume group vol_grp1 is created from the two physical volumes as shown
below.
LVM processes the storage in terms of extents. We can also change the extent size (from the default
size 4MB) using -s flag.
$ sudo vgdisplay
--- Volume group ---
VG Name vol_grp1
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.72 GB
PE Size 4.00 MB
Total PE 952
Alloc PE / Size 0 / 0
Free PE / Size 952 / 3.72 GB
VG UUID Kk1ufB-rT15-bSWe-5270-KDfZ-shUX-FUYBvR
3 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
Now, everything is ready to create the logical volumes from the volume groups. lvcreate command
creates the logical volume with the size of 80MB.
Use lvdisplay command as shown below, to view the available logical volumes with its attributes.
$ sudo lvdisplay
--- Logical volume ---
LV Name /dev/vol_grp1/logical_vol1
VG Name vol_grp1
LV UUID ap8sZ2-WqE1-6401-Kupm-DbnO-2P7g-x1HwtQ
LV Write Access read/write
LV Status available
# open 0
LV Size 80.00 MB
Current LE 20
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
After creating the appropriate filesystem on the logical volumes, it becomes ready to use for the
storage purpose.
LVM resize: Change the size of the logical volumes – Use lvextend Command
We can extend the size of the logical volumes after creating it by using lvextend utility as shown
below. The changes the size of the logical volume from 80MB to 100MB.
We can also add additional size to a specific logical volume as shown below.
4 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
Tags: LVM Commands, LVM GUI, LVM Mirror, LVM Performance, LVM Snapshot, LVM Tutorial
5 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
When the partition is already in use and you are reducing it, you first have to reduce the
filesystem (e.g. run ‘resize2fs’ on the logical volume, in the case of ext2/ext3 filesystems), and
afterwards you use lvreduce. Otherwise you are running under serious risk of loosing your data!
(the reverse order applies with lvextend: After running lvextend, you will need to run resize2fs
to get usable space, when the partition is already in use)
The user asks “Please tell how to reduce the logical volume successfully.”
I suppose he knows about file system
Topper
6 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
In this case use Free PE # 952 ,this will assign the entire disk 3.72 GB, use -l and + sign.
Alo resize the file system resize2fs after extending the lvm
#sudo resize2fs /dev/vol_grp1/logical_vol1
4.1.11. I’m trying to fill my vg, and vgdisplay/vgs says that I have 1.87 GB free, but when I do
an lvcreate vg -L1.87G it says “insufficient free extends”. What’s going on?
The 1.87 GB figure is rounded to 2 decimal places, so it’s probably 1.866 GB or something. This
is a human-readable output to give you a general idea of how big the VG is. If you want to
specify an exact size, you must use extents instead of some multiple of bytes.
In the case of vgdisplay, use the Free PE count instead of the human readable capacity.
# lvcreate vg -l478
Note that instead of an upper-case ‘L’, we used a lower-case ‘l’ to tell lvm to use extents
instead of bytes.
In the case of vgs, you need to instruct it to tell you how many extents are available:
# vgs -o +vg_free_count,vg_extent_count
This tell vgs to add the free extents and the total number of extents to the end of the vgs
listing. Use the free extent number the same way you would in the above vgdisplay case.
7 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
Here’s a question.
First some background
I have a CentOS 6.2 install with two a LVM2 VG group created across two block devices,
/dev/sda and /dev/sdb. These are two fiber channel SAN units, formatted as RAID 6 with 2 hot
spares.They are attached via two hba’s to the host.
Problem: I have to downgrade to CentOS 5.6. The host server has its own disks,
I have not done anything to the current OS as of yet, i’m making sure I have all steps in place
prior to doing this. Can anyone here provide me with the proper method?
How do i restore the lvm and mount it to the newly installed 5.6 install?
The LVM configuration file cannot be created by an easy command like the mdadm.conf, but
LVM stores one or more copy(s) of the configuration file content at the beginning of the
partition. I use the command dd to extract the first part of the partition and write it to a text
file:
Good luck
8 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
Hi,
I used this command to increase already created logical volumes..
lvextend -L+1806 /dev/vgroot/plat_var
Now when I do LV display, it shows me the increased size:
LV Name /dev/vgroot/plat_var
VG Name vgroot
LV UUID mO3lQ0-vAz8-bCqc-Al8Y-0mEi-BNEU-uhn36J
LV Write Access read/write
LV Status available
# open 1
LV Size 14.69 GB
Current LE 470
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:4
Now I am not getting that even after increasing the size why it is not shown up in vgroot-
plat-var1
Must extend AND file system with tool according your file system type.
But Gparted is already good choice.
Leave a Comment
Name
9 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
Website
Previous post: VMware ESXi 4: How to Add VMFS Datastore Using vSphere Client ( with Screenshots )
Next post: How to Register RHEL/OEL Linux to Oracle Support (ULN) using up2date
Search
COURSE
Linux Sysadmin CentOS 6 Course - Master the Tools, Configure it Right, and be Lazy
EBOOKS
Linux 101 Hacks 2nd Edition eBook - Practical Examples to Build a Strong
Foundation in Linux
10 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
Bash 101 Hacks eBook - Take Control of Your Bash Command Line and Shell Scripting
Sed and Awk 101 Hacks eBook - Enhance Your UNIX / Linux Life with Sed and Awk
Vim 101 Hacks eBook - Practical Examples for Becoming Fast and Productive in Vim Editor
Nagios Core 3 eBook - Monitor Everything, Be Proactive, and Sleep Well
POPULAR POSTS
12 Amazing and Essential Linux Books To Enrich Your Brain and Library
50 UNIX / Linux Sysadmin Tutorials
50 Most Frequently Used UNIX / Linux Commands (With Examples)
How To Be Productive and Get Things Done Using GTD
30 Things To Do When you are Bored and have a Computer
Linux Directory Structure (File System Structure) Explained with Examples
Linux Crontab: 15 Awesome Cron Job Examples
Get a Grip on the Grep! – 15 Practical Grep Command Examples
Unix LS Command: 15 Practical Examples
15 Examples To Master Linux Command Line History
Top 10 Open Source Bug Tracking System
Vi and Vim Macro Tutorial: How To Record and Play
Mommy, I found it! -- 15 Practical Linux Find Command Examples
15 Awesome Gmail Tips and Tricks
15 Awesome Google Search Tips and Tricks
RAID 0, RAID 1, RAID 5, RAID 10 Explained with Diagrams
Can You Top This? 15 Practical Linux Top Command Examples
Top 5 Best System Monitoring Tools
Top 5 Best Linux OS Distributions
How To Monitor Remote Linux Host using Nagios 3.0
Awk Introduction Tutorial – 7 Awk Print Examples
How to Backup Linux? 15 rsync Command Examples
The Ultimate Wget Download Guide With 15 Awesome Examples
Top 5 Best Linux Text Editors
Packet Analyzer: 15 TCPDUMP Command Examples
The Ultimate Bash Array Tutorial with 15 Examples
3 Steps to Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id
Unix Sed Tutorial: Advanced Sed Substitution Examples
UNIX / Linux: 10 Netstat Command Examples
The Ultimate Guide for Creating Strong Passwords
6 Steps to Secure Your Home Wireless Network
11 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
CATEGORIES
Linux
Vim
Sed
Awk
Bash
Nagios
OpenSSH
IPTables
Apache
MySQL
Perl
Google
Ubuntu
PostgreSQL
Hello World
C Programming
C++ Programming
DELL
Oracle
VMware
Support Us
12 of 13 07-Jun-13 12:57 AM
How To Create LVM Using vgcreate, lvcreate, and lvextend lvm2... http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
Contact Us
Email Me : Use this Contact Form to get in touch me with your comments, questions or
suggestions about this site. You can also simply drop me a line to say hello!.
Follow us on Twitter
Copyright © 2008–2013 Ramesh Natarajan. All rights reserved | Terms of Service | Advertise
13 of 13 07-Jun-13 12:57 AM