• persistent namespaces


    persistent namespaces

     
    Today I merged support for persistent namespaces to unshare(1). The persistent namespace does not require any running process with in the namespace and it's possible to enter the namespace by nsenter(1).

    For example let's create a new UTS namespace and set a different hostname within the namespace:
      # hostname
      ws
      # touch /root/ns-uts         
      # unshare --uts=/root/ns-uts
      # hostname FooBar
      # exit
    
    Now there is no process in the namespace, try to enter the namespace by --uts=/root/ns-uts reference:
      # nsenter --uts=/root/ns-uts
      # hostname
      FooBar 
      # exit
    
    The reference to the namespace is bind mount to /proc/[pid]/ns/[type], so umount(8) is enough to remove the reference:
      # umount /root/ns-uts
    
    If there is no another reference or any running process within the namespace then the namesapce is destoyed.

    It's also possible to create another types of the persistent namespaces (--net, --ipc, ...). Don't forget that if you want to create a persistent mount namespace than the file (--mount=file) has to be on "private" filesystem, for example on Fedora where all is "shared" you have to use:

      # mount --bind /mnt/test /mnt/test
      # mount --make-rprivate /mnt/test
      # touch /mnt/test/my-ns
      # unshare --mount=/mnt/test/my-ns
      ...
    
    Note that PID namespace cannot be without a running process (or more precisely the PID namespace is dead thing after init process (PID 1) termination).
  • 相关阅读:
    ibatis resultMap 结果集映射
    iabtis初探
    struts2获取请求参数的三种方式及传递给JSP参数的方式
    Struts2的运行机制简介
    Spring AOP面向切面编程的实现
    java 单例模式及getInstance的好处
    It is indirectly referenced from required .class files
    AngularJS学习篇(二)
    AngularJS学习篇(一)
    Flex布局语法
  • 原文地址:https://www.cnblogs.com/dream397/p/14074260.html
Copyright © 2020-2023  润新知