Skip to content

Commit 30fdfa7

Browse files
committed
Fix LVM resize error due to fs utilities do not support renamed devices
As part of disk resize for microshift looks like there is bug in the lvextend tool and it is not work when extending a lvm with resize. - https://access.redhat.com/solutions/7016718 - https://bugzilla.redhat.com/show_bug.cgi?id=2211856 This PR is a workaround which is provided as part of BZ where `lvextend` shouldn't run with `-r` (resize) option. So now we are using `lvextend` only for extending the respective logical volume and then using `xfs_growfs` to grow that volume.
1 parent 446fa57 commit 30fdfa7

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

pkg/crc/machine/start.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,25 @@ func (client *client) updateVMConfig(startConfig types.StartConfig, vm *virtualM
112112
}
113113

114114
func growRootFileSystem(sshRunner *crcssh.Runner, preset crcPreset.Preset) error {
115+
var rootPart string
116+
var err error
115117
if preset == crcPreset.Microshift {
116118
lvFullName := "rhel/root"
117-
return growLVForMicroshift(sshRunner, lvFullName)
118-
}
119-
// With 4.7, this is quite a manual process until https://github.com/openshift/installer/pull/4746 gets fixed
120-
// See https://github.com/crc-org/crc/issues/2104 for details
121-
rootPart, err := getrootPartition(sshRunner, "/dev/disk/by-label/root")
122-
if err != nil {
123-
return err
124-
}
119+
rootPart = fmt.Sprintf("/dev/%s", lvFullName)
120+
if err := growLVForMicroshift(sshRunner, lvFullName); err != nil {
121+
return err
122+
}
123+
} else {
124+
// With 4.7, this is quite a manual process until https://github.com/openshift/installer/pull/4746 gets fixed
125+
// See https://github.com/crc-org/crc/issues/2104 for details
126+
rootPart, err = getrootPartition(sshRunner, "/dev/disk/by-label/root")
127+
if err != nil {
128+
return err
129+
}
125130

126-
if err := runGrowpart(sshRunner, rootPart); err != nil {
127-
return err
131+
if err := runGrowpart(sshRunner, rootPart); err != nil {
132+
return err
133+
}
128134
}
129135

130136
logging.Infof("Resizing %s filesystem", rootPart)
@@ -206,7 +212,7 @@ func growLVForMicroshift(sshRunner *crcssh.Runner, lvFullName string) error {
206212
lvPath := fmt.Sprintf("/dev/%s", lvFullName)
207213
if sizeToIncrease > 1 {
208214
logging.Info("Extending and resizing '/dev/rhel/root' logical volume")
209-
if _, _, err := sshRunner.RunPrivileged("Extending and resizing the logical volume(LV)", "/usr/sbin/lvextend", "-r", "-L", fmt.Sprintf("+%db", sizeToIncrease), lvPath); err != nil {
215+
if _, _, err := sshRunner.RunPrivileged("Extending and resizing the logical volume(LV)", "/usr/sbin/lvextend", "-L", fmt.Sprintf("+%db", sizeToIncrease), lvPath); err != nil {
210216
return err
211217
}
212218
}

0 commit comments

Comments
 (0)