UML ("User Mode Linux") allows you to run multiple Linux servers on one physical machine. This can be handy for many different purposes. For example, you might want to give different people root rights, but prevent them from interfering with one another. Or, you might want to have several identically configured servers, one for production, one for development, and one for testing, but without investing in multiple physical machines.
Once you have prepared your machine for running UML instances as described in the following section, adding new instances will take less than five minutes. The preparation, however, might take a bit longer.
This HOWTO is based on an article in the German computer magazine c't 12/04, page 156 ("Linux: Sicherer Spiele-Server mit User Mode Linux" by Dirk Hartmann).
Run
$ /opt/uml/bin/create_uml_instance.sh test1 11 256M 4G
You will have to answer a few questions (just press the default) and type in the root password. This will create a new uml child with name test1, IP address 192.168.3.11, max. 256MB RAM and 4 GB disk space. Please use only small letters for the name, the script will create a user with that name. This will fail if there are capital letters.
To start it, simply type: /etc/init.d/uml-test1 start
You can ssh from outside to this instance on port 10000 + 1000 * 11 + 22 = 21022 (e.g. with ssh -p 21022 root@yourMachine). Since the IP number gets multiplied by 1000, you should not use IP numbers bigger than 55 unless you change PORTS_PER_UML in uml-child.sh.
You probably want to have more than the bare base system. I installed additional packages using dselect and stored the list of installed packages using:
$ dpkg --get-selections > myconf
To reproduce the installation, you only need to execute
$ dpkg --set-selections < myconf
$ apt-get -u dselect-upgrade
to have your packages back. This way you need to backup only files you or your programs modified. This is usually the files in /etc you changed, all files below /var and maybe /home.
You can do all of this without starting the uml instance. Just mount the
partition and do a chroot on it.
If you always want to run an instance with low priority (e.g. a test instance), you can insert --nice as first parameter in create_iml_instance.sh:
$ create_uml_instance.sh --nice test1 11 256M 4G
This only makes the uml-instance nice, not the creation of it. If you want this too, type:
$ nice create_uml_instance.sh --nice test1 11 256M 4G
Execute:
$ /etc/init.d/uml-test1 backup
This will give you a new logical volume /dev/vg1/test1-backup. The uml child is not halted afterwards. It was only
halted for less then a second.
You can mount it and do a backup now on this snapshot. When you are done with your backup, just delete the logical volume with lvremove.
Well, the total time of your backup probably takes longer than 1 second, but your UML child is interrupted for less than a second. No process inside this UML child suffers from this small break.
You need to do three things:
<typolist>
delete the logical volume with lvremove
delete the user (e.g. test1)
delete /etc/init.d/unl-test1
</typolist>
The script delete_uml_instance.sh does this for you.
All files mentioned above can be found here:
| 3.0 K | |
| 389 | |
| 1.5 M | |
| 1.3 M | |
| 18.3 K | |
| 2.6 K | |
| 47 K | |
| 6.4 K |
This document is free; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
This document is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You can get a copy of the GNU GPL at at
Written by .
--- Fight spam with alias addresses from safersignup.com! ---