Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ upgrade:
mount:
sysroot: /sysroot # Path to mount system to
write-fstab: true # Write fstab into sysroot/etc/fstab
overlay:
ephemeral:
type: tmpfs # tmpfs|block
device: /dev/sda6 # Block device used to store overlay. Used when type is set to block
size: 25% # Size of tmpfs as percentag of system memory. Used when type is set to tmpfs
Expand Down
10 changes: 5 additions & 5 deletions pkg/action/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const overlaySuffix = ".overlay"
func RunMount(cfg *v1.RunConfig, spec *v1.MountSpec) error {
cfg.Logger.Info("Running mount command")

cfg.Logger.Debugf("Mounting overlays")
if err := MountOverlay(cfg, spec.Sysroot, spec.Overlay); err != nil {
cfg.Logger.Debugf("Mounting ephemeral directories")
if err := MountEphemeral(cfg, spec.Sysroot, spec.Ephemeral); err != nil {
cfg.Logger.Errorf("Error mounting overlays: %s", err.Error())
return err
}
Expand All @@ -53,7 +53,7 @@ func RunMount(cfg *v1.RunConfig, spec *v1.MountSpec) error {
return nil
}

func MountOverlay(cfg *v1.RunConfig, sysroot string, overlay v1.OverlayMounts) error {
func MountEphemeral(cfg *v1.RunConfig, sysroot string, overlay v1.EphemeralMounts) error {
if err := utils.MkdirAll(cfg.Config.Fs, constants.OverlayDir, constants.DirPerm); err != nil {
cfg.Logger.Errorf("Error creating directory %s: %s", constants.OverlayDir, err.Error())
return err
Expand Down Expand Up @@ -198,7 +198,7 @@ func WriteFstab(cfg *v1.RunConfig, spec *v1.MountSpec) error {
}

data := fstab(loop, "/", "ext2", []string{"ro", "relatime"})
data = data + fstab("tmpfs", constants.OverlayDir, "tmpfs", []string{"defaults", fmt.Sprintf("size=%s", spec.Overlay.Size)})
data = data + fstab("tmpfs", constants.OverlayDir, "tmpfs", []string{"defaults", fmt.Sprintf("size=%s", spec.Ephemeral.Size)})

for _, part := range spec.Partitions.PartitionsByMountPoint(false) {
if part.Path == "" {
Expand All @@ -214,7 +214,7 @@ func WriteFstab(cfg *v1.RunConfig, spec *v1.MountSpec) error {
data = data + fstab(part.Path, part.MountPoint, "auto", []string{"defaults"})
}

for _, rw := range spec.Overlay.Paths {
for _, rw := range spec.Ephemeral.Paths {
trimmed := strings.TrimPrefix(rw, "/")
pathName := strings.ReplaceAll(trimmed, "/", "-") + overlaySuffix
upper := fmt.Sprintf("%s/%s/upper", constants.OverlayDir, pathName)
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var _ = Describe("Mount Action", func() {
It("Writes a simple fstab", func() {
spec := &v1.MountSpec{
WriteFstab: true,
Overlay: v1.OverlayMounts{
Ephemeral: v1.EphemeralMounts{
Size: "30%",
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func NewMountSpec() *v1.MountSpec {
Sysroot: "/sysroot",
WriteFstab: true,
Partitions: partitions,
Overlay: v1.OverlayMounts{
Ephemeral: v1.EphemeralMounts{
Type: constants.Tmpfs,
Size: "25%",
Paths: []string{"/var", "/etc", "/srv"},
Expand Down
16 changes: 8 additions & 8 deletions pkg/types/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ type MountSpec struct {
Sysroot string `yaml:"sysroot,omitempty" mapstructure:"sysroot"`
Mode string `yaml:"mode,omitempty" mapstructure:"mode"`
Partitions ElementalPartitions
Overlay OverlayMounts `yaml:"overlay,omitempty" mapstructure:"overlay"`
Ephemeral EphemeralMounts `yaml:"ephemeral,omitempty" mapstructure:"ephemeral"`
Persistent PersistentMounts `yaml:"persistent,omitempty" mapstructure:"persistent"`
}

Expand All @@ -255,9 +255,9 @@ type PersistentMounts struct {
Paths []string `yaml:"paths,omitempty" mapstructure:"paths"`
}

// OverlayMounts contains information about the RW overlay mounted over the
// EphemeralMounts contains information about the RW overlay mounted over the
// immutable system.
type OverlayMounts struct {
type EphemeralMounts struct {
Type string `yaml:"type,omitempty" mapstructure:"type"`
Device string `yaml:"device,omitempty" mapstructure:"device"`
Size string `yaml:"size,omitempty" mapstructure:"size"`
Expand All @@ -282,16 +282,16 @@ func (spec *MountSpec) Sanitize() error {
})
}

switch spec.Overlay.Type {
switch spec.Ephemeral.Type {
case constants.Tmpfs, constants.Block:
break
default:
return fmt.Errorf("unknown overlay type: '%s'", spec.Overlay.Type)
return fmt.Errorf("unknown overlay type: '%s'", spec.Ephemeral.Type)
}

if spec.Overlay.Paths != nil {
sort.Slice(spec.Overlay.Paths, func(i, j int) bool {
return strings.Count(spec.Overlay.Paths[i], separator) < strings.Count(spec.Overlay.Paths[j], separator)
if spec.Ephemeral.Paths != nil {
sort.Slice(spec.Ephemeral.Paths, func(i, j int) bool {
return strings.Count(spec.Ephemeral.Paths[i], separator) < strings.Count(spec.Ephemeral.Paths[j], separator)
})
}

Expand Down