Is it possible to use a variable in systemd mount unit configuration?Using variables in systemd unit...
How do I type a hyphen in iOS 12?
Parsing text written the millitext font
In American Politics, why is the Justice Department under the President?
The best in flight meal option for those suffering from reflux
Changing the PK column of a data extension without completely recreating it
Can I attach a DC blower to intake manifold of my 150CC Yamaha FZS FI engine?
If absolute velocity does not exist, how can we say a rocket accelerates in empty space?
Why is my Taiyaki (Cake that looks like a fish) too hard and dry?
I sent an angry e-mail to my interviewers about a conflict at my home institution. Could this affect my application?
Is fission/fusion to iron the most efficient way to convert mass to energy?
Print "N NE E SE S SW W NW"
Fastest way from 8 to 7
David slept with Bathsheba because she was pure?? What does that mean?
Part of my house is inexplicably gone
Why are ambiguous grammars bad?
Do they make "karaoke" versions of concertos for solo practice?
Does the UK delegate some immigration control to the Republic of Ireland?
Can an open source licence be revoked if it violates employer's IP?
Simple log rotation script
Are athlete's college degrees discounted by employers and graduate school admissions?
In The Incredibles 2, why does Screenslaver's name use a pun on something that doesn't exist in the 1950s pastiche?
What is the theme of analysis?
Am I being scammed by a sugar daddy?
How (un)safe is it to ride barefoot?
Is it possible to use a variable in systemd mount unit configuration?
Using variables in systemd unit fileInteraction of initrd commands and systemd services doing same thingEnabling 'linked' unit files in SystemdExecute backup script when USB disk is mountedWhat is the systemd service/unit name for mounting fstab entriessystemd: finish the execution of custom shell script before starting nginxUnattended upgrades won’t use mailx when run by SystemdRecovering linux boot entries in a UEFI dual boot settingRestricting systemd units to specific host based on DNS alias?Why is one of my mount units missing `Before=local-fs.target`?How do I specify a path to an executable for a systemd unit file on nix?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Is it possible to use a variable in the what=
field of a systemd mount configuration file instead of an absolute path string?
For Example:
[Unit]
Before=local-fs.target
[Mount]
What=/dev/disk/by-partlabel/${part_variable}
Where=/mnt/optional/config/
I am trying to find a way to use a custom kernel command-line bootparam, and mount a partition provided by that bootparam.
systemd
add a comment |
Is it possible to use a variable in the what=
field of a systemd mount configuration file instead of an absolute path string?
For Example:
[Unit]
Before=local-fs.target
[Mount]
What=/dev/disk/by-partlabel/${part_variable}
Where=/mnt/optional/config/
I am trying to find a way to use a custom kernel command-line bootparam, and mount a partition provided by that bootparam.
systemd
add a comment |
Is it possible to use a variable in the what=
field of a systemd mount configuration file instead of an absolute path string?
For Example:
[Unit]
Before=local-fs.target
[Mount]
What=/dev/disk/by-partlabel/${part_variable}
Where=/mnt/optional/config/
I am trying to find a way to use a custom kernel command-line bootparam, and mount a partition provided by that bootparam.
systemd
Is it possible to use a variable in the what=
field of a systemd mount configuration file instead of an absolute path string?
For Example:
[Unit]
Before=local-fs.target
[Mount]
What=/dev/disk/by-partlabel/${part_variable}
Where=/mnt/optional/config/
I am trying to find a way to use a custom kernel command-line bootparam, and mount a partition provided by that bootparam.
systemd
systemd
edited 1 hour ago
sob
asked Mar 19 '18 at 16:34
sobsob
197211
197211
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
For the record:
Is if possible to use a variable in the
What=
field of a systemd mount
configuration file instead of an absolute path string?
Yes, it is possible, e.g. (just tested with systemd v.238
):
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
if you run
systemctl set-environment SOMEPATH=/dev/disk/by-label/DATA
and then
systemctl start mnt-date.mount
it will mount /dev/disk/by-label/DATA
to /mnt/data
or, via a env file:
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
EnvironmentFile=/path/to/env_file
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
/path/to/env_file
content:
SOMEPATH=/dev/disk/by-uuid/1b5a38ca-9f0d-4f1a-8fc1-7c418e79bf07
This may not help you to
find a way to use a custom kernel command-line
bootparam, and mount a partition provided by that bootparam.
but it's definitely possible to use What=${SOMEVAR}
.
add a comment |
According to man systemd.mount
, no variable substitution is supported there.
I believe it's still possible to write a systemd service which runs early in the boot process, which writes out a a dynamically generated .mount
file.
add a comment |
No.
What you describe is exactly what generators are for, see man systemd.generators
. Compare man systemd-fstab-generator
which generates the mount units from /etc/fstab
, it also reads e.g. root=
from the kernel command line. That said, if you only support a kernel command line option, and you don't have a config file, you may be just as happy writing an early-boot (DefaultDependencies=no
) service unit for this.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432129%2fis-it-possible-to-use-a-variable-in-systemd-mount-unit-configuration%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
For the record:
Is if possible to use a variable in the
What=
field of a systemd mount
configuration file instead of an absolute path string?
Yes, it is possible, e.g. (just tested with systemd v.238
):
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
if you run
systemctl set-environment SOMEPATH=/dev/disk/by-label/DATA
and then
systemctl start mnt-date.mount
it will mount /dev/disk/by-label/DATA
to /mnt/data
or, via a env file:
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
EnvironmentFile=/path/to/env_file
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
/path/to/env_file
content:
SOMEPATH=/dev/disk/by-uuid/1b5a38ca-9f0d-4f1a-8fc1-7c418e79bf07
This may not help you to
find a way to use a custom kernel command-line
bootparam, and mount a partition provided by that bootparam.
but it's definitely possible to use What=${SOMEVAR}
.
add a comment |
For the record:
Is if possible to use a variable in the
What=
field of a systemd mount
configuration file instead of an absolute path string?
Yes, it is possible, e.g. (just tested with systemd v.238
):
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
if you run
systemctl set-environment SOMEPATH=/dev/disk/by-label/DATA
and then
systemctl start mnt-date.mount
it will mount /dev/disk/by-label/DATA
to /mnt/data
or, via a env file:
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
EnvironmentFile=/path/to/env_file
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
/path/to/env_file
content:
SOMEPATH=/dev/disk/by-uuid/1b5a38ca-9f0d-4f1a-8fc1-7c418e79bf07
This may not help you to
find a way to use a custom kernel command-line
bootparam, and mount a partition provided by that bootparam.
but it's definitely possible to use What=${SOMEVAR}
.
add a comment |
For the record:
Is if possible to use a variable in the
What=
field of a systemd mount
configuration file instead of an absolute path string?
Yes, it is possible, e.g. (just tested with systemd v.238
):
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
if you run
systemctl set-environment SOMEPATH=/dev/disk/by-label/DATA
and then
systemctl start mnt-date.mount
it will mount /dev/disk/by-label/DATA
to /mnt/data
or, via a env file:
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
EnvironmentFile=/path/to/env_file
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
/path/to/env_file
content:
SOMEPATH=/dev/disk/by-uuid/1b5a38ca-9f0d-4f1a-8fc1-7c418e79bf07
This may not help you to
find a way to use a custom kernel command-line
bootparam, and mount a partition provided by that bootparam.
but it's definitely possible to use What=${SOMEVAR}
.
For the record:
Is if possible to use a variable in the
What=
field of a systemd mount
configuration file instead of an absolute path string?
Yes, it is possible, e.g. (just tested with systemd v.238
):
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
if you run
systemctl set-environment SOMEPATH=/dev/disk/by-label/DATA
and then
systemctl start mnt-date.mount
it will mount /dev/disk/by-label/DATA
to /mnt/data
or, via a env file:
mnt-data.mount
content:
[Unit]
Description=Mount System Backups Directory
[Mount]
EnvironmentFile=/path/to/env_file
What=${SOMEPATH}
Where=/mnt/data
Type=ext4
Options=defaults
/path/to/env_file
content:
SOMEPATH=/dev/disk/by-uuid/1b5a38ca-9f0d-4f1a-8fc1-7c418e79bf07
This may not help you to
find a way to use a custom kernel command-line
bootparam, and mount a partition provided by that bootparam.
but it's definitely possible to use What=${SOMEVAR}
.
answered Mar 19 '18 at 20:12
don_crisstidon_crissti
53.2k17145173
53.2k17145173
add a comment |
add a comment |
According to man systemd.mount
, no variable substitution is supported there.
I believe it's still possible to write a systemd service which runs early in the boot process, which writes out a a dynamically generated .mount
file.
add a comment |
According to man systemd.mount
, no variable substitution is supported there.
I believe it's still possible to write a systemd service which runs early in the boot process, which writes out a a dynamically generated .mount
file.
add a comment |
According to man systemd.mount
, no variable substitution is supported there.
I believe it's still possible to write a systemd service which runs early in the boot process, which writes out a a dynamically generated .mount
file.
According to man systemd.mount
, no variable substitution is supported there.
I believe it's still possible to write a systemd service which runs early in the boot process, which writes out a a dynamically generated .mount
file.
answered Mar 19 '18 at 19:37
Mark StosbergMark Stosberg
4,2431329
4,2431329
add a comment |
add a comment |
No.
What you describe is exactly what generators are for, see man systemd.generators
. Compare man systemd-fstab-generator
which generates the mount units from /etc/fstab
, it also reads e.g. root=
from the kernel command line. That said, if you only support a kernel command line option, and you don't have a config file, you may be just as happy writing an early-boot (DefaultDependencies=no
) service unit for this.
add a comment |
No.
What you describe is exactly what generators are for, see man systemd.generators
. Compare man systemd-fstab-generator
which generates the mount units from /etc/fstab
, it also reads e.g. root=
from the kernel command line. That said, if you only support a kernel command line option, and you don't have a config file, you may be just as happy writing an early-boot (DefaultDependencies=no
) service unit for this.
add a comment |
No.
What you describe is exactly what generators are for, see man systemd.generators
. Compare man systemd-fstab-generator
which generates the mount units from /etc/fstab
, it also reads e.g. root=
from the kernel command line. That said, if you only support a kernel command line option, and you don't have a config file, you may be just as happy writing an early-boot (DefaultDependencies=no
) service unit for this.
No.
What you describe is exactly what generators are for, see man systemd.generators
. Compare man systemd-fstab-generator
which generates the mount units from /etc/fstab
, it also reads e.g. root=
from the kernel command line. That said, if you only support a kernel command line option, and you don't have a config file, you may be just as happy writing an early-boot (DefaultDependencies=no
) service unit for this.
answered Mar 19 '18 at 19:41
sourcejedisourcejedi
27.3k446121
27.3k446121
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432129%2fis-it-possible-to-use-a-variable-in-systemd-mount-unit-configuration%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown