How to Automount a CIFS share after WiFi connects on Raspbian












1















I've got Raspbian running on RaspberryPi 2. I've a WIFI dongle, configured network/interfaces to automatically connect to my home network... all works great.



I've a windows share on my LAN that I want to mount on raspbian. I edited /etc/fstab file. My added line works fine when I use Ethernet cable, it automatically mounts the share on boot. However, when on WiFi it doesn't. I'm guessing it runs fstab too early before the WiFi connects.... also if I run sudo mount -a, it reads the rule from fstab and applies it just fine...



My question is, how can I get the system to automount AFTER there is an available connection? or after it acquires an IP maybe?



I looked at udev rules but I'm not sure if that's the way to go...










share|improve this question
















bumped to the homepage by Community 15 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    1















    I've got Raspbian running on RaspberryPi 2. I've a WIFI dongle, configured network/interfaces to automatically connect to my home network... all works great.



    I've a windows share on my LAN that I want to mount on raspbian. I edited /etc/fstab file. My added line works fine when I use Ethernet cable, it automatically mounts the share on boot. However, when on WiFi it doesn't. I'm guessing it runs fstab too early before the WiFi connects.... also if I run sudo mount -a, it reads the rule from fstab and applies it just fine...



    My question is, how can I get the system to automount AFTER there is an available connection? or after it acquires an IP maybe?



    I looked at udev rules but I'm not sure if that's the way to go...










    share|improve this question
















    bumped to the homepage by Community 15 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      I've got Raspbian running on RaspberryPi 2. I've a WIFI dongle, configured network/interfaces to automatically connect to my home network... all works great.



      I've a windows share on my LAN that I want to mount on raspbian. I edited /etc/fstab file. My added line works fine when I use Ethernet cable, it automatically mounts the share on boot. However, when on WiFi it doesn't. I'm guessing it runs fstab too early before the WiFi connects.... also if I run sudo mount -a, it reads the rule from fstab and applies it just fine...



      My question is, how can I get the system to automount AFTER there is an available connection? or after it acquires an IP maybe?



      I looked at udev rules but I'm not sure if that's the way to go...










      share|improve this question
















      I've got Raspbian running on RaspberryPi 2. I've a WIFI dongle, configured network/interfaces to automatically connect to my home network... all works great.



      I've a windows share on my LAN that I want to mount on raspbian. I edited /etc/fstab file. My added line works fine when I use Ethernet cable, it automatically mounts the share on boot. However, when on WiFi it doesn't. I'm guessing it runs fstab too early before the WiFi connects.... also if I run sudo mount -a, it reads the rule from fstab and applies it just fine...



      My question is, how can I get the system to automount AFTER there is an available connection? or after it acquires an IP maybe?



      I looked at udev rules but I'm not sure if that's the way to go...







      raspberry-pi raspbian






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 '15 at 5:36









      slm

      251k67528685




      251k67528685










      asked Mar 26 '15 at 5:26









      Haytham AbuelFutuhHaytham AbuelFutuh

      62




      62





      bumped to the homepage by Community 15 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 15 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          While the NFS-specific mount binary supports a bg option, the CIFS mount does not.



          Options I can think of:




          • Create a script that attempts to perform the mount, but sleeps and loops if unsuccessful. Exit if mount successful. Run as a startup script.

          • Install and use the automounter, autofs.






          share|improve this answer































            0














            You might want to take a look into "network interface configuration for ifup and ifdown" with



            man interfaces


            The configuration file allows several "command" options. In your case you might want to take a look into the option



            post-up command


            which is run after the interface is brought up.






            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%2f192568%2fhow-to-automount-a-cifs-share-after-wifi-connects-on-raspbian%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              While the NFS-specific mount binary supports a bg option, the CIFS mount does not.



              Options I can think of:




              • Create a script that attempts to perform the mount, but sleeps and loops if unsuccessful. Exit if mount successful. Run as a startup script.

              • Install and use the automounter, autofs.






              share|improve this answer




























                0














                While the NFS-specific mount binary supports a bg option, the CIFS mount does not.



                Options I can think of:




                • Create a script that attempts to perform the mount, but sleeps and loops if unsuccessful. Exit if mount successful. Run as a startup script.

                • Install and use the automounter, autofs.






                share|improve this answer


























                  0












                  0








                  0







                  While the NFS-specific mount binary supports a bg option, the CIFS mount does not.



                  Options I can think of:




                  • Create a script that attempts to perform the mount, but sleeps and loops if unsuccessful. Exit if mount successful. Run as a startup script.

                  • Install and use the automounter, autofs.






                  share|improve this answer













                  While the NFS-specific mount binary supports a bg option, the CIFS mount does not.



                  Options I can think of:




                  • Create a script that attempts to perform the mount, but sleeps and loops if unsuccessful. Exit if mount successful. Run as a startup script.

                  • Install and use the automounter, autofs.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 26 '15 at 6:46









                  BowlOfRedBowlOfRed

                  2,590715




                  2,590715

























                      0














                      You might want to take a look into "network interface configuration for ifup and ifdown" with



                      man interfaces


                      The configuration file allows several "command" options. In your case you might want to take a look into the option



                      post-up command


                      which is run after the interface is brought up.






                      share|improve this answer




























                        0














                        You might want to take a look into "network interface configuration for ifup and ifdown" with



                        man interfaces


                        The configuration file allows several "command" options. In your case you might want to take a look into the option



                        post-up command


                        which is run after the interface is brought up.






                        share|improve this answer


























                          0












                          0








                          0







                          You might want to take a look into "network interface configuration for ifup and ifdown" with



                          man interfaces


                          The configuration file allows several "command" options. In your case you might want to take a look into the option



                          post-up command


                          which is run after the interface is brought up.






                          share|improve this answer













                          You might want to take a look into "network interface configuration for ifup and ifdown" with



                          man interfaces


                          The configuration file allows several "command" options. In your case you might want to take a look into the option



                          post-up command


                          which is run after the interface is brought up.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 26 '15 at 7:06









                          FloHimselfFloHimself

                          6,49421318




                          6,49421318






























                              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%2f192568%2fhow-to-automount-a-cifs-share-after-wifi-connects-on-raspbian%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

                              Accessing regular linux commands in Huawei's Dopra Linux

                              Can't connect RFCOMM socket: Host is down

                              Kernel panic - not syncing: Fatal Exception in Interrupt