[gparted/1-can-t-shrink-lvm-partition-due-to-pvresize-prompt] Fix LVM2 PV shrinking with lvm2 2.02.171 and later (#1)



commit 5892b72890748c1d3e96bd7e25800c8aab351025
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Jun 11 12:57:52 2018 +0100

    Fix LVM2 PV shrinking with lvm2 2.02.171 and later (#1)
    
    Shrinking an LVM2 Physical Volume on CentOS 7 with the latest
    lvm2 2.02.177 fails like this:
    
      Shrink /dev/sda9 from 1.00 GiB to 768.00 MiB
      * calibrate /dev/sda9
      * check file system on /dev/sda9 for errors and (if possib...(SUCCESS)
      * shrink file system                                         (ERROR)
        * lvm pvresize -v --setphysicalvolumesize 786432K '/dev/...(ERROR)
            0 physical volume(s) resized / 1 physical volume(s) not resized
    
            Wiping internal VG cache
            Wiping cache of LVM-capable devices
            /dev/sda9: Requested size 712.00 MiB is less than real size 1.00 GiB.  Proceed? [y/n]:[n]
            Physical Volume /dev/sda9 not resized.
    
    This upstream change to lvm2 [1] makes pvresize prompt for confirmation
    whenever the --setphysicalvolumesize option is used.  (The change was
    included in lvm2 2.02.171 and later, which is used in recent
    distributions.  The reporter found the issue on Ubuntu 18.04 LTS and I
    reproduced the issue on RHEL/CentOS 7.5).  The set size option has to be
    used when shrinking the PV before shrinking the partition therefore fix
    this issue by adding lvm common option --yes when using the set size
    option.
    
    [1] https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cbc69f8c693edf0d1307c9447e2e66d07a04bfe9
        pvresize: Prompt when non-default size supplied.
    
    Closes #1 - Can't shrink LVM partition due to pvresize prompt

 src/lvm2_pv.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/src/lvm2_pv.cc b/src/lvm2_pv.cc
index ece13cd4..69193e30 100644
--- a/src/lvm2_pv.cc
+++ b/src/lvm2_pv.cc
@@ -103,7 +103,7 @@ bool lvm2_pv::resize( const Partition & partition_new, OperationDetail & operati
 {
        Glib::ustring size = "" ;
        if ( ! fill_partition )
-               size = " --setphysicalvolumesize " +
+               size = " --yes --setphysicalvolumesize " +
                        Utils::num_to_str( floor( Utils::sector_to_unit(
                                partition_new .get_sector_length(), partition_new .sector_size, UNIT_KIB ) ) 
) + "K " ;
        return ! execute_command( "lvm pvresize -v " + size + Glib::shell_quote( partition_new.get_path() ),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]