-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor early system mounting #1866
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1a92e7d
Add mount command
frelon 715322e
Add elemental-sysroot feature
frelon e366717
Update sysroot, setup and rootfs dracut modules
frelon 3dec1b6
Test compatibility
frelon b3b9c80
Update to latest ele-testhelpers
frelon 6664c06
Forwards compatibility for immutable-rootfs feat
frelon 02c3321
Update init features for green and tumbleweed
frelon 1b00b6c
Remove oem mounts from elemental-setup-initramfs
frelon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ iso-meta.yaml | |
.qemu/ | ||
.loop | ||
tests/**/logs | ||
tests/vmstdout | ||
serial_port1.log | ||
capture.webm | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright © 2022 - 2023 SUSE LLC | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"k8s.io/mount-utils" | ||
|
||
"github.com/rancher/elemental-toolkit/cmd/config" | ||
"github.com/rancher/elemental-toolkit/pkg/action" | ||
"github.com/rancher/elemental-toolkit/pkg/constants" | ||
elementalError "github.com/rancher/elemental-toolkit/pkg/error" | ||
) | ||
|
||
func NewMountCmd(root *cobra.Command) *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: "mount", | ||
Short: "Mount an elemental system into the specified sysroot", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
mounter := mount.New(constants.MountBinary) | ||
|
||
cfg, err := config.ReadConfigRun(viper.GetString("config-dir"), cmd.Flags(), mounter) | ||
if err != nil { | ||
cfg.Logger.Errorf("Error reading config: %s\n", err) | ||
return elementalError.NewFromError(err, elementalError.ReadingRunConfig) | ||
} | ||
|
||
cmd.SilenceUsage = true | ||
spec, err := config.ReadMountSpec(cfg, cmd.Flags()) | ||
if err != nil { | ||
cfg.Logger.Errorf("Error reading spec: %s\n", err) | ||
return elementalError.NewFromError(err, elementalError.ReadingSpecConfig) | ||
} | ||
|
||
if spec.Disable { | ||
cfg.Logger.Info("Mounting disabled, exiting") | ||
return nil | ||
} | ||
|
||
cfg.Logger.Info("Mounting system...") | ||
return action.RunMount(cfg, spec) | ||
}, | ||
} | ||
root.AddCommand(c) | ||
return c | ||
} | ||
|
||
var _ = NewMountCmd(rootCmd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,29 @@ upgrade: | |
# grub menu entry, this is the string that will be displayed | ||
grub-entry-name: Elemental | ||
|
||
# configuration used for the 'mount' command | ||
mount: | ||
sysroot: /sysroot # Path to mount system to | ||
write-fstab: true # Write fstab into sysroot/etc/fstab | ||
overlay: | ||
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 | ||
paths: | ||
- /var | ||
- /etc | ||
- /srv | ||
persistent: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the persistent block device defined? I think this should be configurable and probably default to our persistent partition so it can be omitted from the config file, but still configurable. |
||
mode: overlay # overlay|bind | ||
paths: | ||
- /etc/systemd | ||
- /etc/ssh | ||
- /home | ||
- /opt | ||
- /root | ||
- /usr/libexec | ||
- /var/log | ||
|
||
# use cosign to validate images from container registries | ||
cosign: true | ||
# cosign key to used for validation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if this is the right name. I mean if we have
persistent
then probably we should have something liketransient
orephemeral
. Otherwise one could think this overlay device setting is for the persistent data.