-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
introduce systemd-volatile-usr #39117
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
Closed
Closed
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -28,19 +28,30 @@ | |
|
|
||
| <refsect1> | ||
| <title>Description</title> | ||
| <para><filename>systemd-volatile-root.service</filename> is a service that works on /sysroot directory. | ||
| This service runs only in the initrd, before the system transitions to the host's root directory.</para> | ||
|
|
||
| <para> It is influenced by the <literal>systemd.volatile</literal> kernel command line parameter.</para> | ||
|
Member
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. Please don't add whitespace after |
||
|
|
||
| <para> If <literal>systemd.volatile=yes</literal> is specified, the service will replace the root | ||
| directory with a volatile memory file system (<literal>tmpfs</literal>), mounting the original | ||
| (non-volatile) <filename>/usr/</filename> inside it read-only. This way, vendor data from | ||
| <filename>/usr/</filename> is available as usual, but all configuration data in <filename>/etc/</filename>, | ||
| all state data in <filename>/var/</filename> and all other resources stored directly under the root | ||
| directory are reset on boot and lost at shutdown, enabling fully stateless systems.</para> | ||
|
|
||
| <para>If <literal>systemd.volatile=overlay-root</literal> is specified, the service will overlay the root | ||
| directory with an <literal>overlayfs</literal> file system, using the original <filename>/sysroot</filename> as | ||
| lower layer and a writable <literal>tmpfs</literal> as upper layer. | ||
| In addition, the original <filename>/usr/</filename> is mounted inside as read-only. | ||
| All files in the original file system are available, but any changes made directly under the root directory are lost on shutdown, while <filename>/usr/</filename> cannot be modified.</para> | ||
|
|
||
| <para>If <literal>systemd.volatile=overlay-usr</literal> is specified, the service will replace the | ||
| <filename>/usr/</filename> directory with an <literal>overlayfs</literal> file system, | ||
| using the original <filename>/usr/</filename> as lower layer and a writable <literal>tmpfs</literal> as upper layer. | ||
| This way, vendor data from <filename>/usr/</filename> is available as usual, but all new modifications made | ||
| under the <filename>/usr/</filename> directory are lost at shutdown.</para> | ||
|
|
||
| <para><filename>systemd-volatile-root.service</filename> is a service that replaces the root directory with a | ||
| volatile memory file system (<literal>tmpfs</literal>), mounting the original (non-volatile) | ||
| <filename>/usr/</filename> inside it read-only. This way, vendor data from <filename>/usr/</filename> is available as | ||
| usual, but all configuration data in <filename>/etc/</filename>, all state data in <filename>/var/</filename> and all | ||
| other resources stored directly under the root directory are reset on boot and lost at shutdown, enabling fully | ||
| stateless systems.</para> | ||
|
|
||
| <para>This service is only enabled if full volatile mode is selected, for example by specifying | ||
| <literal>systemd.volatile=yes</literal> on the kernel command line. This service runs only in the initrd, | ||
| before the system transitions to the host's root directory. Note that this service is not used if | ||
| <literal>systemd.volatile=state</literal> is used, as in that mode the root directory is non-volatile. | ||
| </para> | ||
| </refsect1> | ||
|
|
||
| <refsect1> | ||
|
|
@@ -51,5 +62,4 @@ | |
| <member><citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> | ||
| </simplelist></para> | ||
| </refsect1> | ||
|
|
||
| </refentry> | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| #include "alloc-util.h" | ||
| #include "proc-cmdline.h" | ||
| #include "string-table.h" | ||
| #include "string-util.h" | ||
| #include "volatile-util.h" | ||
|
|
||
| int query_volatile_mode(VolatileMode *ret) { | ||
|
|
@@ -35,7 +36,18 @@ static const char* const volatile_mode_table[_VOLATILE_MODE_MAX] = { | |
| [VOLATILE_NO] = "no", | ||
| [VOLATILE_YES] = "yes", | ||
| [VOLATILE_STATE] = "state", | ||
| [VOLATILE_OVERLAY] = "overlay", | ||
| [VOLATILE_OVERLAY_ROOT] = "overlay-root", | ||
| [VOLATILE_OVERLAY_USR] = "overlay-usr", | ||
| }; | ||
|
|
||
| DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(volatile_mode, VolatileMode, VOLATILE_YES); | ||
| const char* volatile_mode_to_string(VolatileMode i) { | ||
| return string_table_lookup_to_string(volatile_mode_table, ELEMENTSOF(volatile_mode_table), i); | ||
| } | ||
|
Comment on lines
+42
to
+44
Member
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. DEFINE_STRING_TABLE_LOOKUP_TO_STRING(volatile_mode, VolatileMode);? |
||
|
|
||
| VolatileMode volatile_mode_from_string(const char *s) { | ||
| /* Handle backward compatibility: "overlay" maps to VOLATILE_OVERLAY_ROOT */ | ||
| if (streq_ptr(s, "overlay")) | ||
| return VOLATILE_OVERLAY_ROOT; | ||
|
|
||
| return (VolatileMode) string_table_lookup_from_string_with_boolean(volatile_mode_table, ELEMENTSOF(volatile_mode_table), s, VOLATILE_YES); | ||
| } | ||
This file contains hidden or 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.
the
<filename>/sysroot/</filename>