LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-09-2008, 09:43 AM   #1
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 448

Rep: Reputation: 31
Question How do I LVM2 defrag or move based on logical volumes


I've created a real mess for my self.

I've got 5 hard drives which I've put 9 varying sized partitions on each. When I initially set things up I was allocating things between ASM and three LVM volume groups. The large amount of partitions was so I could move things around between ASM and different logical groups. Theory being I could isolate one group to one HD for backups, and I could de-allocate from LVM for ASM. Really bad idea.

For some reason the I failed to realized that since the ASM was running in a virtual machine (xen) I could allocate a LVM partition to the VT and ASM wouldn't know the difference. Also that I can pvmove any non-backup related logical volumes off a disk if needed.


So now, I've merged everything into one big volume group. I have a total of 30 pv volumes with free space and logical volumes scattered all over the place.

So my questions:

1. Is there an automatic defrag for lvm so I can put logical volumes together on the various disks?
2. Is there a way to move entire logical volume to a new disk rather than having to do it individually over the ~20 pv's that it's sitting on?
 
Old 12-09-2008, 10:39 AM   #2
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 475

Rep: Reputation: 73
Quote:
Originally Posted by MikeyCarter View Post
1. Is there an automatic defrag for lvm so I can put logical volumes together on the various disks?
no defrag but you can use man 8 pvmove to move the LV's or LVs' PEs from a PV or PVs to a different PV

in it's simplest form pvmove --background /dev/sda2 /dev/sdb3 will move all allocated PEs from sda2|PV to sdb3|PV as long as sdb3|PV has enough free PEs to accomodate. (NOTE: I've always started the pvmove with --background and then checked status with a separate pvmove process with --interval and, while i do not perform this often, the 6-8 times initiated has completed successfully for me. YMMV)

Quote:
Originally Posted by MikeyCarter View Post
2. Is there a way to move entire logical volume to a new disk rather than having to do it individually over the ~20 pv's that it's sitting on?
yes, man 8 pvmove.
given, PVs sdc1, sdc5, sdd2, sdd3, sde6 contain all of PEs for LV named MikeyCarter and sdg8 has enough PEs available to entirely contain MikeyCarter LV one should (may need to check syntax|structure here...) be able to run the following (or similar):
Code:
pvmove --background --name MikeyCarter /dev/sdc1 /dev/sdc5 /dev/sdd2 /dev/sdd3 /dev/sde6  /dev/sdg8
if you just want to vacate a PV of all allocated PEs and let LVM move it to available PVs within the VG:
Code:
pvmove --background /dev/sdh1
 
Old 12-09-2008, 01:06 PM   #3
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 448

Original Poster
Rep: Reputation: 31
That's a great help thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Kickstart & logical volumes Corrado Red Hat 2 11-14-2007 01:03 PM
KDiskFree gets it wrong with Logical Volumes GTrax Linux - Software 3 11-12-2007 01:10 AM
finding and mounting logical volumes Steve Riley Fedora 5 04-14-2007 03:39 PM
Mounting Logical Volumes acidblue Fedora 6 01-28-2006 10:02 PM
I did not know about logical volumes gezi Linux - Newbie 5 04-27-2005 09:26 AM


All times are GMT -5. The time now is 02:36 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration