@@ -15,7 +15,7 @@ import (
15
15
"github.com/crc-org/crc/pkg/crc/cluster"
16
16
"github.com/crc-org/crc/pkg/crc/constants"
17
17
crcerrors "github.com/crc-org/crc/pkg/crc/errors"
18
- "github.com/crc-org/crc/pkg/crc/logging"
18
+ logging "github.com/crc-org/crc/pkg/crc/logging"
19
19
"github.com/crc-org/crc/pkg/crc/machine/bundle"
20
20
"github.com/crc-org/crc/pkg/crc/machine/config"
21
21
"github.com/crc-org/crc/pkg/crc/machine/state"
@@ -118,14 +118,39 @@ func growRootFileSystem(sshRunner *crcssh.Runner, preset crcPreset.Preset) error
118
118
}
119
119
// With 4.7, this is quite a manual process until https://github.com/openshift/installer/pull/4746 gets fixed
120
120
// See https://github.com/crc-org/crc/issues/2104 for details
121
- rootPart , _ , err := sshRunner . Run ( "realpath" , "/dev/disk/by-label/root" )
121
+ rootPart , err := getrootPartition ( sshRunner , "/dev/disk/by-label/root" )
122
122
if err != nil {
123
123
return err
124
124
}
125
+
126
+ if err := runGrowpart (sshRunner , rootPart ); err != nil {
127
+ return err
128
+ }
129
+
130
+ logging .Infof ("Resizing %s filesystem" , rootPart )
131
+ if _ , _ , err := sshRunner .RunPrivileged ("Remounting /sysroot read/write" , "mount -o remount,rw /sysroot" ); err != nil {
132
+ return err
133
+ }
134
+ if _ , _ , err = sshRunner .RunPrivileged (fmt .Sprintf ("Growing %s filesystem" , rootPart ), "xfs_growfs" , rootPart ); err != nil {
135
+ return err
136
+ }
137
+
138
+ return nil
139
+ }
140
+
141
+ func getrootPartition (sshRunner * crcssh.Runner , label string ) (string , error ) {
142
+ rootPart , _ , err := sshRunner .Run ("realpath" , label )
143
+ if err != nil {
144
+ return "" , err
145
+ }
125
146
rootPart = strings .TrimSpace (rootPart )
126
147
if ! strings .HasPrefix (rootPart , "/dev/vda" ) && ! strings .HasPrefix (rootPart , "/dev/sda" ) {
127
- return fmt .Errorf ("Unexpected root device: %s" , rootPart )
148
+ return "" , fmt .Errorf ("Unexpected root device: %s" , rootPart )
128
149
}
150
+ return rootPart , nil
151
+ }
152
+
153
+ func runGrowpart (sshRunner * crcssh.Runner , rootPart string ) error {
129
154
// with '/dev/[sv]da4' as input, run 'growpart /dev/[sv]da 4'
130
155
if _ , _ , err := sshRunner .RunPrivileged (fmt .Sprintf ("Growing %s partition" , rootPart ), "/usr/bin/growpart" , rootPart [:len ("/dev/.da" )], rootPart [len (rootPart )- 1 :]); err != nil {
131
156
var exitErr * ssh.ExitError
@@ -135,19 +160,8 @@ func growRootFileSystem(sshRunner *crcssh.Runner, preset crcPreset.Preset) error
135
160
if exitErr .ExitStatus () != 1 {
136
161
return err
137
162
}
138
-
139
163
logging .Debugf ("No free space after %s, nothing to do" , rootPart )
140
- return nil
141
164
}
142
-
143
- logging .Infof ("Resizing %s filesystem" , rootPart )
144
- if _ , _ , err := sshRunner .RunPrivileged ("Remounting /sysroot read/write" , "mount -o remount,rw /sysroot" ); err != nil {
145
- return err
146
- }
147
- if _ , _ , err = sshRunner .RunPrivileged (fmt .Sprintf ("Growing %s filesystem" , rootPart ), "xfs_growfs" , rootPart ); err != nil {
148
- return err
149
- }
150
-
151
165
return nil
152
166
}
153
167
0 commit comments