(ephemeralDiskPath string)
| 397 | } |
| 398 | |
| 399 | func (p linux) SetupRootDisk(ephemeralDiskPath string) error { |
| 400 | var resizeCmd string |
| 401 | var resizeCmdArgs []string |
| 402 | |
| 403 | if p.options.SkipDiskSetup { |
| 404 | return nil |
| 405 | } |
| 406 | |
| 407 | // if there is ephemeral disk we can safely autogrow, if not we should not. |
| 408 | if (ephemeralDiskPath == "") && p.options.CreatePartitionIfNoEphemeralDisk { |
| 409 | p.logger.Info(logTag, "No Ephemeral Disk provided, Skipping growing of the Root Filesystem") |
| 410 | return nil |
| 411 | } |
| 412 | |
| 413 | // in case growpart is not available for another flavour of linux, don't stop the agent from running, |
| 414 | // without this integration-test would not run since the bosh-lite vm doesn't have it |
| 415 | if !p.cmdRunner.CommandExists("growpart") { |
| 416 | p.logger.Info(logTag, "The program 'growpart' is not installed, Root Filesystem cannot be grown") |
| 417 | return nil |
| 418 | } |
| 419 | |
| 420 | rootDevicePath, rootDeviceNumber, err := p.findRootDevicePathAndNumber() |
| 421 | if err != nil { |
| 422 | return bosherr.WrapError(err, "findRootDevicePath") |
| 423 | } |
| 424 | |
| 425 | stdout, _, _, err := p.cmdRunner.RunCommand( |
| 426 | "growpart", |
| 427 | rootDevicePath, |
| 428 | strconv.Itoa(rootDeviceNumber), |
| 429 | ) |
| 430 | |
| 431 | if err != nil { |
| 432 | if !strings.Contains(stdout, "NOCHANGE") { |
| 433 | return bosherr.WrapError(err, "growpart") |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | rootDevice := p.partitionPath(rootDevicePath, rootDeviceNumber) |
| 438 | fsType, err := p.diskManager.GetFormatter().GetPartitionFormatType(rootDevice) |
| 439 | if err != nil { |
| 440 | return bosherr.WrapError(err, "Getting root partition filesystem type") |
| 441 | } |
| 442 | |
| 443 | switch fsType { |
| 444 | case boshdisk.FileSystemXFS: |
| 445 | resizeCmd = boshdisk.FileSystemXFSResizeUtility |
| 446 | resizeCmdArgs = []string{"-d", rootDevice} |
| 447 | case boshdisk.FileSystemExt4: |
| 448 | resizeCmd = boshdisk.FileSystemExtResizeUtility |
| 449 | resizeCmdArgs = []string{"-f", rootDevice} |
| 450 | default: |
| 451 | return bosherr.Errorf("Cannot get filesystem type for root file system") |
| 452 | } |
| 453 | _, _, _, err = p.cmdRunner.RunComplexCommand(boshsys.Command{ |
| 454 | Name: resizeCmd, |
| 455 | Args: resizeCmdArgs, |
| 456 | }) |
nothing calls this directly
no test coverage detected