LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-22-2019, 04:42 AM   #1
N6rV1UUV
LQ Newbie
 
Registered: May 2019
Posts: 5

Rep: Reputation: Disabled
Shrinking lvm disk


I want to shrink lvm partitioned disk and clone it to a smaller one.
I did
Code:
lvreduce -L XXG
and then tried shrinking it with gparted which failed due to segment allocation.
Code:
pvs -v --segments /dev/sdb2
gives this result:

https://i.postimg.cc/zGJdHt5w/Screen...1-08-50-46.png

Code:
pvmove --alloc anywhere /dev/sdb2:16577-27615 /dev/sdb2:11457-22495
fails because free SSize is too small.
How do I make free segments appear on the end of PV table?
 
Old 05-22-2019, 09:50 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
That's because pvmove cannot handle overlapping moves.

The simplest thing to do would be to move just the last 5120 segments of the centos-root LV to the currently free region:
Code:
pvmove /dev/sdb2:22506-27615 /dev/sdb2:11457-16576
That has the disadvantage of making the segments of the centos-root LV even more out of sequence physically than they are now.

You can do the move in several stages of 5120 segments at a time (like playing the 15-tile-puzzle game), but frankly I would, instead of cloning, just create a new PV on the target disk and then pvmove the segments of all LVs from your current disk to the locations where you want them on the new disk:
Code:
vgextend centos /dev/sdb2
pvmove /dev/sda2:0-9695 sdb2:0-9695
pvmove /dev/sda2:16577-27615 /dev/sdb2:9696-20734
pvmove /dev/sda2:9696-11456 /dev/sdb2:20735-22495
That will put your LVs on the new disk, with the root filesystem segments back in order.
 
2 members found this post helpful.
Old 05-22-2019, 05:46 PM   #3
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
I always like to keep a backup. I would mirror to the new disk then break the mirror.
 
  


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
LVM and shrinking the root filesystem coreychch Linux - Newbie 5 11-22-2015 10:35 PM
Shrinking a Logical Volume With LVM jimmyjiang Red Hat 1 02-28-2008 04:45 PM
Shrinking a partition that is managed by LVM? unclestoner Linux - Newbie 8 01-25-2008 03:12 PM
Shrinking and moving an lvm partition. (and random fdisk help) pardasaniman Linux - Software 2 08-02-2006 08:11 AM
Shrinking an LVM partition Sabre_X Linux - Software 6 09-30-2005 11:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:50 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