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;
}







4















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.










share|improve this question































    4















    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.










    share|improve this question



























      4












      4








      4


      2






      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.










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 hour ago







      sob

















      asked Mar 19 '18 at 16:34









      sobsob

      197211




      197211






















          3 Answers
          3






          active

          oldest

          votes


















          5














          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}.






          share|improve this answer































            1














            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.






            share|improve this answer































              0














              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.






              share|improve this answer
























                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
                });


                }
                });














                draft saved

                draft discarded


















                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









                5














                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}.






                share|improve this answer




























                  5














                  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}.






                  share|improve this answer


























                    5












                    5








                    5







                    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}.






                    share|improve this answer













                    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}.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 19 '18 at 20:12









                    don_crisstidon_crissti

                    53.2k17145173




                    53.2k17145173

























                        1














                        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.






                        share|improve this answer




























                          1














                          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.






                          share|improve this answer


























                            1












                            1








                            1







                            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.






                            share|improve this answer













                            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.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 19 '18 at 19:37









                            Mark StosbergMark Stosberg

                            4,2431329




                            4,2431329























                                0














                                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.






                                share|improve this answer




























                                  0














                                  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.






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    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.






                                    share|improve this answer













                                    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.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Mar 19 '18 at 19:41









                                    sourcejedisourcejedi

                                    27.3k446121




                                    27.3k446121






























                                        draft saved

                                        draft discarded




















































                                        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.




                                        draft saved


                                        draft discarded














                                        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





















































                                        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







                                        Popular posts from this blog

                                        Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                                        Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                                        Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...