LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-17-2016, 04:04 PM   #1
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 282

Rep: Reputation: Disabled
How to create Logical Volume from free space of existing Volume Group?


I have an LVM which is around 3.6T in size and I would like to cut around 120G from it and mount it on /var/lib/mysql which in current configuration is running out of space. All disk space in the only volume group is dedicated to one Logical Volume that I currently use. I have a lot of free space on this LV and it is all assigned to /home. I would like to take 120G of that free space and create the second LV from this. Is this a doable thing and if yes, how would this work (the more info the better, the commands I can look up on the Net and so on)?

Thanks.
 
Old 12-17-2016, 04:21 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
There are innumerable articles on the web - try searching. "resize LVM" might be a start.
Given the number of threads you have started, I would recommend the RHEL LVM Admin guide for a well rounded introduction to all things LVM. Not specific to RHEL and can be downloaded freely.
 
Old 12-17-2016, 04:22 PM   #3
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 282

Original Poster
Rep: Reputation: Disabled
This is all ext4.

pvdisplay - prntscr.com/dkphus
vgdisplay - prntscr.com/dkpi1q
lvdisplay - prntscr.com/dkpibq
df -h - prntscr.com/dkpiju
/etc/fstab - prntscr.com/dkpiqu
 
Old 12-17-2016, 04:25 PM   #4
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 282

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
There are innumerable articles on the web - try searching. "resize LVM" might be a start.
Given the number of threads you have started, I would recommend the RHEL LVM Admin guide for a well rounded introduction to all things LVM. Not specific to RHEL and can be downloaded freely.
I am familiar with Linux but I only work on things like this when something breaks. I normally work on making websites and learning PHP and JavaScript programming right now. Something happens more or less once every six months lets say, and I have to get into everything anew, what takes some time. I read a lot about it already when I was setting it up, but for right now I am not sure what keywords would I need to use in google to find what I need. I've been already researching and preparing this with google.com for three hours or more. Split LV, cut free space from LV, divide LVG into two LVs - things like these dont produce good results in google.com, so I was thinking that I could get some kind of advice from here.
 
Old 12-17-2016, 08:23 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Look for articles on reducing the size of a Linux hard drive, and add "LVM" to the search criteria.

Such as: How to Shrink an LVM Volume Safely.

Last edited by sundialsvcs; 12-17-2016 at 08:24 PM.
 
Old 12-18-2016, 08:14 AM   #6
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 282

Original Poster
Rep: Reputation: Disabled
Is it ok to use the same sizes (ie: 120G) in shrinking the file system and then the logical volume? Or would I, like some articles suggest, shrink the file system to something like 108G (90% of 120G) then shrink the LV to 120G. And after that I would grow the file system to 120G?

I guess I would just use the same numbers in the both commands, but this could be something that it would be better to get confirmed.

This is from the link that was posted above:

"When we reduce the size of the actual volume in the next step, it is critical that the new size is greater than or equal to the size of the file system. To be on the safe side, we’ll just shrink the file system a bit more than necessary and expand it to use the full space available later.

Finally, grow the file system so that it uses all available space on the logical volume."

This article used different numbers also, and people in the comments indicate that this is a mistake:

http://www.tecmint.com/extend-and-reduce-lvms-in-linux/

An option in the middle would be to check / verify the size and use the --extents option with the lvcreate:

If you want to be extra cautious about not shrinking the LV to a size smaller than the filesystem it contains, check the physical extent size of your volume group using vgdisplay volgrp01, and calculate how many physical extents are needed to hold the byte size of your filesystem (using 1MB = 1048576 bytes). Then specify that number using the --extents option instead of the --size 50G.

SO BASICALLY:
1) I can use the same numbers (the simplest option)
2) Check the numbers with vgdisplay volbrp-name (I am not exactly sure how to do this yet, I would need to look into this further if this is a good and needed step)
3) I can use smaller number for file system, number 10% higher for the LV and enlarge the file system to match the LV after that (the article that was suggesting this is like 6-7 years old, so I am not sure about it too).
 
Old 12-19-2016, 05:59 AM   #7
AdultFoundry
Member
 
Registered: Jun 2015
Posts: 282

Original Poster
Rep: Reputation: Disabled
/var/lib/mysql/ibdata1 (and possibly other files there) growing too large? Just move the whole thing where you have more disk space, and this is the easiest and possibly the best way to go. I was preparing for shrinking the lvm and database optimization for two days, and I could have solved everything in less than an hour and I would not waste all this time. On Centos 7 and it may be other distributions too the new location needs to be added to the /etc/php.ini file (two locations there in my situation).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing volume group before creating logical volume fanoflq Linux - Newbie 1 07-26-2016 06:32 PM
LVM Mount Physical Volume/Logical Volume without a working Volume Group mpivintis Linux - Newbie 10 01-11-2014 07:02 AM
Extended LVM Volume group and Logical Volume. But space not usable linuxlover.chaitanya Linux - Server 1 11-19-2012 09:37 AM
I have spce in volume group but it can not increase the size of logical volume anis123 Linux - Newbie 14 04-16-2012 06:23 AM
how to shrink Volume Group and get some space to create new volume Farah_s Linux - Newbie 1 03-14-2012 07:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration