Editing
Namespaces
From Linix VServer
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
You may have heard that [[alpha util-vserver]] use so called namespaces and wonder what namespaces are and more important, what they are good for. This document should give you some insights (hopefully ;)). == What are namespaces? == Namespaces are a feature of the linux kernel that allow different processes to have a different view on the filesystem. Normally there is just a single filesystem tree with different mounts here and there. Now with namespaces you can have different mounts/views for different processes. What does this mean? This means that if process A and process B are in different namespaces, (un-)mounting in one namespace does not affect the other namespace. When you mount something it only appears in the current namespace and if you unmount something it only disappears in the current namespace. A namespace is automagically destroyed once all processes using that namespace have died. All mounts are automagically unmounted in that namesapce, so you don't have to take care that some dead mounts hang around somewhere you can't access them and keep you from, for example, removing a media from your cdrom drive (of course you have to take care that all processes die ;)). == How does alpha util-vserver use them? == Using the default settings alpha util-vserver creates a new namespace for each vserver. There are at least two reasons for doing this: === Cosmetic === The cosmetic reason is that your host's namespace isn't cluttered with all those mounts inside the vservers, i.e. /proc/mounts only contains the list of mounts in the current namespace. === Security === Security is added since alpha util-vserver also overlay the original root directory with the vserver's root directory (using a recursive bind mount), that way chroot break-outs fail since you end up being in the root directory which is now the vserver's root directory anyway ;) (you can also secure your vservers against chroot break-outs if you don't use namespaces, see chroot-barrier). == Drawbacks? == Yes, there are some drawbacks if you use namespaces for your vservers, but only minor ones. Since namespaces are isolated from each other, you cannot directly add a mount to a vserver using "mount". Instead you have to switch to the vserver's namespace first. Fortunately alpha util-vserver comes with a tool that allows you to switch to a vserver's namespace easily. <pre># get a bash in the namespace of vserver "myvserver": vnamespace -e myvserver bash # same in context 123 vnamespace -e 123 bash # mount something in the namespace of vserver "myvserver": vnamespace -e myvserver mount /dev/somenode /path/to/mount/point # unmount something in the namespace of context 123 vnamespace -e 123 umount /path/to/mount/point # display all mounts in the namespace of 'myvserver' vnamespace -e myvserver cat /proc/mounts </pre> Recent versions of alpha util-vserver automatically translate a vserver-name to a context id, while older tools still require the use of the correct context id. Remember that if you do bind mounts, the source of the bind mount has to be already available in the vserver's namespace. Using the new configuration scheme you can also configure mounts for a vserver to be automatically setup while starting the vserver, see [http://www.nongnu.org/util-vserver/doc/conf/configuration.html The Great Flower Page] for details.
Summary:
Please note that all contributions to Linix VServer may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Linix VServer:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
About
Overview
Paper
News
Developers
Donations
Search
Getting Started
Downloads
FAQs
Documentation
Support
Participate
How to participate
Report a Bug
Communicate
Teams/Projects
Hall of Fame
Resources
Archives
Recent Wiki Changes
Pastebin
Related Projects
VServer Hosting
Happy VServer Users
Tools
What links here
Related changes
Special pages
Page information