mfleetwo / rpms / gparted

Forked from rpms/gparted 3 years ago
Clone
8b4468e
From 2f090b4a2b649c30c649d36b9919e1d4a4f65c07 Mon Sep 17 00:00:00 2001
8b4468e
From: Mike Fleetwood <mike.fleetwood@googlemail.com>
8b4468e
Date: Mon, 11 Jun 2018 12:57:52 +0100
8b4468e
Subject: [PATCH] Fix LVM2 PV shrinking with lvm2 2.02.171 and later (#1)
8b4468e
8b4468e
Shrinking an LVM2 Physical Volume on CentOS 7 with the latest
8b4468e
lvm2 2.02.177 fails like this:
8b4468e
8b4468e
  Shrink /dev/sda9 from 1.00 GiB to 768.00 MiB
8b4468e
  * calibrate /dev/sda9
8b4468e
  * check file system on /dev/sda9 for errors and (if possib...(SUCCESS)
8b4468e
  * shrink file system                                         (ERROR)
8b4468e
    * lvm pvresize -v --setphysicalvolumesize 786432K '/dev/...(ERROR)
8b4468e
        0 physical volume(s) resized / 1 physical volume(s) not resized
8b4468e
8b4468e
        Wiping internal VG cache
8b4468e
        Wiping cache of LVM-capable devices
8b4468e
        /dev/sda9: Requested size 712.00 MiB is less than real size 1.00 GiB.  Proceed? [y/n]:[n]
8b4468e
        Physical Volume /dev/sda9 not resized.
8b4468e
8b4468e
This upstream change to lvm2 [1] makes pvresize prompt for confirmation
8b4468e
whenever the --setphysicalvolumesize option is used.  (The change was
8b4468e
included in lvm2 2.02.171 and later, which is used in recent
8b4468e
distributions.  The reporter found the issue on Ubuntu 18.04 LTS and I
8b4468e
reproduced the issue on RHEL/CentOS 7.5).  The set size option has to be
8b4468e
used when shrinking the PV before shrinking the partition therefore fix
8b4468e
this issue by adding lvm common option --yes when using the set size
8b4468e
option.
8b4468e
8b4468e
[1] https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cbc69f8c693edf0d1307c9447e2e66d07a04bfe9
8b4468e
    pvresize: Prompt when non-default size supplied.
8b4468e
8b4468e
Closes #1 - Can't shrink LVM partition due to pvresize prompt
8b4468e
---
8b4468e
 src/lvm2_pv.cc |    2 +-
8b4468e
 1 files changed, 1 insertions(+), 1 deletions(-)
8b4468e
8b4468e
diff --git a/src/lvm2_pv.cc b/src/lvm2_pv.cc
8b4468e
index 15af3eb..5f7c7bb 100644
8b4468e
--- a/src/lvm2_pv.cc
8b4468e
+++ b/src/lvm2_pv.cc
8b4468e
@@ -102,7 +102,7 @@ bool lvm2_pv::resize( const Partition & partition_new, OperationDetail & operati
8b4468e
 {
8b4468e
 	Glib::ustring size = "" ;
8b4468e
 	if ( ! fill_partition )
8b4468e
-		size = " --setphysicalvolumesize " +
8b4468e
+		size = " --yes --setphysicalvolumesize " +
8b4468e
 			Utils::num_to_str( floor( Utils::sector_to_unit(
8b4468e
 				partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) ) + "K " ;
8b4468e
 	return ! execute_command( "lvm pvresize -v " + size + Glib::shell_quote( partition_new.get_path() ),
8b4468e
-- 
8b4468e
1.7.1
8b4468e