Skip to content

Commit

Permalink
Try to create mount directory first before making it mutable
Browse files Browse the repository at this point in the history
This will remove logic to ignore /home or /mnt directory before make
filesystem mutable. This will help in case other directories exist
same way like /home or /mnt like `/Users` so we don't need to make
filesystem mutable.
  • Loading branch information
praveenkumar committed Jan 27, 2025
1 parent ab8cf0b commit 88da767
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/crc/machine/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,16 @@ func configureSharedDirs(vm *virtualMachine, sshRunner *crcssh.Runner) error {
}
logging.Infof("Configuring shared directories")
for _, mount := range sharedDirs {
// CoreOS makes / immutable, we need to handle this if we need to create a directory outside of /home and /mnt
isHomeOrMnt := strings.HasPrefix(mount.Target, "/home") || strings.HasPrefix(mount.Target, "/mnt")
if !isHomeOrMnt {
// Try to create the mount directory and if it fails then
// make the file system mutable and again try to create the
// mount directory
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Creating %s", mount.Target), "mkdir", "-p", mount.Target); err != nil {
if _, _, err := sshRunner.RunPrivileged("Making / mutable", "chattr", "-i", "/"); err != nil {
return err
}
}
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Creating %s", mount.Target), "mkdir", "-p", mount.Target); err != nil {
return err
}
if !isHomeOrMnt {
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Creating %s", mount.Target), "mkdir", "-p", mount.Target); err != nil {
return err
}
if _, _, err := sshRunner.RunPrivileged("Making / immutable again", "chattr", "+i", "/"); err != nil {
return err
}
Expand Down

0 comments on commit 88da767

Please sign in to comment.