@@ -113,8 +113,7 @@ func (client *client) updateVMConfig(startConfig types.StartConfig, vm *virtualM
113
113
114
114
func growRootFileSystem (sshRunner * crcssh.Runner , preset crcPreset.Preset ) error {
115
115
if preset == crcPreset .Microshift {
116
- logging .Debugf ("growRootFileSystem does not support LVM which is used by %s images" , preset )
117
- return nil
116
+ return growLVForMicroshift (sshRunner )
118
117
}
119
118
// With 4.7, this is quite a manual process until https://github.com/openshift/installer/pull/4746 gets fixed
120
119
// See https://github.com/crc-org/crc/issues/2104 for details
@@ -165,6 +164,53 @@ func runGrowpart(sshRunner *crcssh.Runner, rootPart string) error {
165
164
return nil
166
165
}
167
166
167
+ func growLVForMicroshift (sshRunner * crcssh.Runner ) error {
168
+ rootPart , _ , err := sshRunner .RunPrivileged ("Get PV disk path" , "/usr/sbin/pvs" , "-S" , "lv_name=root" , "-o" , "pv_name" , "--noheadings" )
169
+ if err != nil {
170
+ return err
171
+ }
172
+ rootPart = strings .TrimSpace (rootPart )
173
+ if err := runGrowpart (sshRunner , rootPart ); err != nil {
174
+ return err
175
+ }
176
+
177
+ if _ , _ , err := sshRunner .RunPrivileged ("Resizing the physical volume(PV)" , "/usr/sbin/pvresize" , rootPart ); err != nil {
178
+ return err
179
+ }
180
+
181
+ // Get the size of volume group
182
+ sizeVG , _ , err := sshRunner .RunPrivileged ("Get the volume group size" , "/usr/sbin/vgs" , "--noheadings" , "--nosuffix" , "--units" , "b" , "-o" , "vg_size" )
183
+ if err != nil {
184
+ return err
185
+ }
186
+ vgSize , err := strconv .Atoi (strings .TrimSpace (sizeVG ))
187
+ if err != nil {
188
+ return err
189
+ }
190
+
191
+ // Get the size of root lv
192
+ sizeLV , _ , err := sshRunner .RunPrivileged ("Get the size of root logical volume" , "/usr/sbin/lvs" , "-S" , "lv_name=root" , "--noheadings" , "--nosuffix" , "--units" , "b" , "-o" , "lv_size" )
193
+ if err != nil {
194
+ return err
195
+ }
196
+ lvSize , err := strconv .Atoi (strings .TrimSpace (sizeLV ))
197
+ if err != nil {
198
+ return err
199
+ }
200
+
201
+ // vgFree space as part of the bundle is default to ~15.02G (16127098880 byte)
202
+ vgFree := 16127098880
203
+ expectedLVSize := vgSize - vgFree
204
+ sizeToIncrease := expectedLVSize - lvSize
205
+ if sizeToIncrease > 1 {
206
+ logging .Info ("Extending and resizing '/dev/rhel/root' logical volume" )
207
+ if _ , _ , err := sshRunner .RunPrivileged ("Extending and resizing the logical volume(LV)" , "/usr/sbin/lvextend" , "-r" , "-L" , fmt .Sprintf ("+%db" , sizeToIncrease ), "/dev/rhel/root" ); err != nil {
208
+ return err
209
+ }
210
+ }
211
+ return nil
212
+ }
213
+
168
214
func configureSharedDirs (vm * virtualMachine , sshRunner * crcssh.Runner ) error {
169
215
logging .Debugf ("Configuring shared directories" )
170
216
sharedDirs , err := vm .Driver .GetSharedDirs ()
0 commit comments