What happens if the last process in a namespace exits?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite
1












I am running Linux.



I have a single process in a mount namespace.
I did in this process a mount -t tmpfs tmpfs /mountpoint.



What happens if the process exits and there are no more processes in that mount namespace?
Will the filesystem be automatically unmounted?
Will the mount namespace be destroyed?
If the namespaces and the mount are still active how do I access it?



What happens to tun/tap/macvtap interfaces if a network namespace has no more processes?










share|improve this question



















  • 1




    I guess that nothing would happen. At least according to my understanding of namespaces(7)
    – Basile Starynkevitch
    Jun 25 '15 at 16:16











  • According to the manpage you refer, network interfaces in a names space will be handed back to the origin namespace. What happens to mounts in mount namespaces?
    – abraXxl
    Jun 26 '15 at 12:00











  • I really don't know; study the kernel's source code.
    – Basile Starynkevitch
    Jun 26 '15 at 12:42














up vote
4
down vote

favorite
1












I am running Linux.



I have a single process in a mount namespace.
I did in this process a mount -t tmpfs tmpfs /mountpoint.



What happens if the process exits and there are no more processes in that mount namespace?
Will the filesystem be automatically unmounted?
Will the mount namespace be destroyed?
If the namespaces and the mount are still active how do I access it?



What happens to tun/tap/macvtap interfaces if a network namespace has no more processes?










share|improve this question



















  • 1




    I guess that nothing would happen. At least according to my understanding of namespaces(7)
    – Basile Starynkevitch
    Jun 25 '15 at 16:16











  • According to the manpage you refer, network interfaces in a names space will be handed back to the origin namespace. What happens to mounts in mount namespaces?
    – abraXxl
    Jun 26 '15 at 12:00











  • I really don't know; study the kernel's source code.
    – Basile Starynkevitch
    Jun 26 '15 at 12:42












up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1





I am running Linux.



I have a single process in a mount namespace.
I did in this process a mount -t tmpfs tmpfs /mountpoint.



What happens if the process exits and there are no more processes in that mount namespace?
Will the filesystem be automatically unmounted?
Will the mount namespace be destroyed?
If the namespaces and the mount are still active how do I access it?



What happens to tun/tap/macvtap interfaces if a network namespace has no more processes?










share|improve this question















I am running Linux.



I have a single process in a mount namespace.
I did in this process a mount -t tmpfs tmpfs /mountpoint.



What happens if the process exits and there are no more processes in that mount namespace?
Will the filesystem be automatically unmounted?
Will the mount namespace be destroyed?
If the namespaces and the mount are still active how do I access it?



What happens to tun/tap/macvtap interfaces if a network namespace has no more processes?







linux namespace network-namespaces






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 25 '15 at 15:47









Mikel

38k996123




38k996123










asked Jun 25 '15 at 15:40









abraXxl

384




384







  • 1




    I guess that nothing would happen. At least according to my understanding of namespaces(7)
    – Basile Starynkevitch
    Jun 25 '15 at 16:16











  • According to the manpage you refer, network interfaces in a names space will be handed back to the origin namespace. What happens to mounts in mount namespaces?
    – abraXxl
    Jun 26 '15 at 12:00











  • I really don't know; study the kernel's source code.
    – Basile Starynkevitch
    Jun 26 '15 at 12:42












  • 1




    I guess that nothing would happen. At least according to my understanding of namespaces(7)
    – Basile Starynkevitch
    Jun 25 '15 at 16:16











  • According to the manpage you refer, network interfaces in a names space will be handed back to the origin namespace. What happens to mounts in mount namespaces?
    – abraXxl
    Jun 26 '15 at 12:00











  • I really don't know; study the kernel's source code.
    – Basile Starynkevitch
    Jun 26 '15 at 12:42







1




1




I guess that nothing would happen. At least according to my understanding of namespaces(7)
– Basile Starynkevitch
Jun 25 '15 at 16:16





I guess that nothing would happen. At least according to my understanding of namespaces(7)
– Basile Starynkevitch
Jun 25 '15 at 16:16













According to the manpage you refer, network interfaces in a names space will be handed back to the origin namespace. What happens to mounts in mount namespaces?
– abraXxl
Jun 26 '15 at 12:00





According to the manpage you refer, network interfaces in a names space will be handed back to the origin namespace. What happens to mounts in mount namespaces?
– abraXxl
Jun 26 '15 at 12:00













I really don't know; study the kernel's source code.
– Basile Starynkevitch
Jun 26 '15 at 12:42




I really don't know; study the kernel's source code.
– Basile Starynkevitch
Jun 26 '15 at 12:42










2 Answers
2






active

oldest

votes

















up vote
2
down vote













It seems that the mounts remain, but become unaccessible.



I did the following as a test:



  1. Entered a new namespace and mounted tmpfs:


root@localhost:~# mkdir tmp
root@localhost:~# unshare -m bash
root@localhost:~# mount -t tmpfs tmpfs tmp


  1. Checked memory usage before and after creating a 200 megabyte file on the tmpfs. You can notice the "shared" usage going from 404 megabytes to 604 megabytes:


root@localhost:~# free -m
total used free shared buff/cache available
Mem: 9885 2966 681 404 6237 6148
Swap: 8191 293 7898
root@localhost:~# dd if=/dev/urandom of=tmp/dummy bs=1M count=200
200+0 records in
200+0 records out
209715200 bytes (210 MB, 200 MiB) copied, 12.0075 s, 17.5 MB/s
root@localhost:~# free -m
total used free shared buff/cache available
Mem: 9885 2966 481 604 6437 5948
Swap: 8191 293 7898


  1. Exited the unshare shell, the memory did not get reclaimed:


root@localhost:~# exit
root@localhost:~# free -m
total used free shared buff/cache available
Mem: 9885 2963 484 604 6437 5951
Swap: 8191 293 7898


Whereas if I unmount the tmpfs, the shared count goes back to initial value.






share|improve this answer



























    up vote
    0
    down vote













    Cannot add a comment, because not enough rep, so here it goes:
    I did exactly the same test as jpa on a unmodified debian stretch and the memory gets back to the initial value, even though I did NOT unmount. So it seems this behaviour has changed.



    http://man7.org/linux/man-pages/man7/namespaces.7.html



    implies this at least by saying:




    Bind mounting (see mount(2)) one of the files in this directory to
    somewhere else in the filesystem keeps the corresponding namespace of
    the process specified by pid alive even if all processes currently in
    the namespace terminate.




    So not doing that destroys the namespace (?).






    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',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      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%2f212172%2fwhat-happens-if-the-last-process-in-a-namespace-exits%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote













      It seems that the mounts remain, but become unaccessible.



      I did the following as a test:



      1. Entered a new namespace and mounted tmpfs:


      root@localhost:~# mkdir tmp
      root@localhost:~# unshare -m bash
      root@localhost:~# mount -t tmpfs tmpfs tmp


      1. Checked memory usage before and after creating a 200 megabyte file on the tmpfs. You can notice the "shared" usage going from 404 megabytes to 604 megabytes:


      root@localhost:~# free -m
      total used free shared buff/cache available
      Mem: 9885 2966 681 404 6237 6148
      Swap: 8191 293 7898
      root@localhost:~# dd if=/dev/urandom of=tmp/dummy bs=1M count=200
      200+0 records in
      200+0 records out
      209715200 bytes (210 MB, 200 MiB) copied, 12.0075 s, 17.5 MB/s
      root@localhost:~# free -m
      total used free shared buff/cache available
      Mem: 9885 2966 481 604 6437 5948
      Swap: 8191 293 7898


      1. Exited the unshare shell, the memory did not get reclaimed:


      root@localhost:~# exit
      root@localhost:~# free -m
      total used free shared buff/cache available
      Mem: 9885 2963 484 604 6437 5951
      Swap: 8191 293 7898


      Whereas if I unmount the tmpfs, the shared count goes back to initial value.






      share|improve this answer
























        up vote
        2
        down vote













        It seems that the mounts remain, but become unaccessible.



        I did the following as a test:



        1. Entered a new namespace and mounted tmpfs:


        root@localhost:~# mkdir tmp
        root@localhost:~# unshare -m bash
        root@localhost:~# mount -t tmpfs tmpfs tmp


        1. Checked memory usage before and after creating a 200 megabyte file on the tmpfs. You can notice the "shared" usage going from 404 megabytes to 604 megabytes:


        root@localhost:~# free -m
        total used free shared buff/cache available
        Mem: 9885 2966 681 404 6237 6148
        Swap: 8191 293 7898
        root@localhost:~# dd if=/dev/urandom of=tmp/dummy bs=1M count=200
        200+0 records in
        200+0 records out
        209715200 bytes (210 MB, 200 MiB) copied, 12.0075 s, 17.5 MB/s
        root@localhost:~# free -m
        total used free shared buff/cache available
        Mem: 9885 2966 481 604 6437 5948
        Swap: 8191 293 7898


        1. Exited the unshare shell, the memory did not get reclaimed:


        root@localhost:~# exit
        root@localhost:~# free -m
        total used free shared buff/cache available
        Mem: 9885 2963 484 604 6437 5951
        Swap: 8191 293 7898


        Whereas if I unmount the tmpfs, the shared count goes back to initial value.






        share|improve this answer






















          up vote
          2
          down vote










          up vote
          2
          down vote









          It seems that the mounts remain, but become unaccessible.



          I did the following as a test:



          1. Entered a new namespace and mounted tmpfs:


          root@localhost:~# mkdir tmp
          root@localhost:~# unshare -m bash
          root@localhost:~# mount -t tmpfs tmpfs tmp


          1. Checked memory usage before and after creating a 200 megabyte file on the tmpfs. You can notice the "shared" usage going from 404 megabytes to 604 megabytes:


          root@localhost:~# free -m
          total used free shared buff/cache available
          Mem: 9885 2966 681 404 6237 6148
          Swap: 8191 293 7898
          root@localhost:~# dd if=/dev/urandom of=tmp/dummy bs=1M count=200
          200+0 records in
          200+0 records out
          209715200 bytes (210 MB, 200 MiB) copied, 12.0075 s, 17.5 MB/s
          root@localhost:~# free -m
          total used free shared buff/cache available
          Mem: 9885 2966 481 604 6437 5948
          Swap: 8191 293 7898


          1. Exited the unshare shell, the memory did not get reclaimed:


          root@localhost:~# exit
          root@localhost:~# free -m
          total used free shared buff/cache available
          Mem: 9885 2963 484 604 6437 5951
          Swap: 8191 293 7898


          Whereas if I unmount the tmpfs, the shared count goes back to initial value.






          share|improve this answer












          It seems that the mounts remain, but become unaccessible.



          I did the following as a test:



          1. Entered a new namespace and mounted tmpfs:


          root@localhost:~# mkdir tmp
          root@localhost:~# unshare -m bash
          root@localhost:~# mount -t tmpfs tmpfs tmp


          1. Checked memory usage before and after creating a 200 megabyte file on the tmpfs. You can notice the "shared" usage going from 404 megabytes to 604 megabytes:


          root@localhost:~# free -m
          total used free shared buff/cache available
          Mem: 9885 2966 681 404 6237 6148
          Swap: 8191 293 7898
          root@localhost:~# dd if=/dev/urandom of=tmp/dummy bs=1M count=200
          200+0 records in
          200+0 records out
          209715200 bytes (210 MB, 200 MiB) copied, 12.0075 s, 17.5 MB/s
          root@localhost:~# free -m
          total used free shared buff/cache available
          Mem: 9885 2966 481 604 6437 5948
          Swap: 8191 293 7898


          1. Exited the unshare shell, the memory did not get reclaimed:


          root@localhost:~# exit
          root@localhost:~# free -m
          total used free shared buff/cache available
          Mem: 9885 2963 484 604 6437 5951
          Swap: 8191 293 7898


          Whereas if I unmount the tmpfs, the shared count goes back to initial value.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 1 '17 at 8:52









          jpa

          56327




          56327






















              up vote
              0
              down vote













              Cannot add a comment, because not enough rep, so here it goes:
              I did exactly the same test as jpa on a unmodified debian stretch and the memory gets back to the initial value, even though I did NOT unmount. So it seems this behaviour has changed.



              http://man7.org/linux/man-pages/man7/namespaces.7.html



              implies this at least by saying:




              Bind mounting (see mount(2)) one of the files in this directory to
              somewhere else in the filesystem keeps the corresponding namespace of
              the process specified by pid alive even if all processes currently in
              the namespace terminate.




              So not doing that destroys the namespace (?).






              share|improve this answer
























                up vote
                0
                down vote













                Cannot add a comment, because not enough rep, so here it goes:
                I did exactly the same test as jpa on a unmodified debian stretch and the memory gets back to the initial value, even though I did NOT unmount. So it seems this behaviour has changed.



                http://man7.org/linux/man-pages/man7/namespaces.7.html



                implies this at least by saying:




                Bind mounting (see mount(2)) one of the files in this directory to
                somewhere else in the filesystem keeps the corresponding namespace of
                the process specified by pid alive even if all processes currently in
                the namespace terminate.




                So not doing that destroys the namespace (?).






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Cannot add a comment, because not enough rep, so here it goes:
                  I did exactly the same test as jpa on a unmodified debian stretch and the memory gets back to the initial value, even though I did NOT unmount. So it seems this behaviour has changed.



                  http://man7.org/linux/man-pages/man7/namespaces.7.html



                  implies this at least by saying:




                  Bind mounting (see mount(2)) one of the files in this directory to
                  somewhere else in the filesystem keeps the corresponding namespace of
                  the process specified by pid alive even if all processes currently in
                  the namespace terminate.




                  So not doing that destroys the namespace (?).






                  share|improve this answer












                  Cannot add a comment, because not enough rep, so here it goes:
                  I did exactly the same test as jpa on a unmodified debian stretch and the memory gets back to the initial value, even though I did NOT unmount. So it seems this behaviour has changed.



                  http://man7.org/linux/man-pages/man7/namespaces.7.html



                  implies this at least by saying:




                  Bind mounting (see mount(2)) one of the files in this directory to
                  somewhere else in the filesystem keeps the corresponding namespace of
                  the process specified by pid alive even if all processes currently in
                  the namespace terminate.




                  So not doing that destroys the namespace (?).







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 10 at 17:45









                  spawn

                  261




                  261



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f212172%2fwhat-happens-if-the-last-process-in-a-namespace-exits%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay