特殊:Badtitle/NS100:UserModeLinux:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/UserModeLinux}} | {{From|https://help.ubuntu.com/community/UserModeLinux}} | ||
{{Languages|UbuntuHelp:UserModeLinux}} | {{Languages|UbuntuHelp:UserModeLinux}} | ||
'''User-Mode Linux''' is another virtualisation technique for running [[UbuntuHelp:VirtualMachines|VirtualMachines]] under GNU/Linux. | <<Include(Tag/ContentCleanup)>> | ||
<<Include(Tag/NeedsExpansion)>> | |||
'''User-Mode Linux''' is another virtualisation technique for running [[UbuntuHelp:VirtualMachines|VirtualMachines]] under GNU/Linux. A simplified version of the Linux kernel is run as a normal user-space process. | |||
See the User-Mode Linux [http://user-mode-linux.sourceforge.net/ project page] for more information. | See the User-Mode Linux [http://user-mode-linux.sourceforge.net/ project page] for more information. | ||
---- | This page will help you get started using User-Mode Linux with Ubuntu. Guide is created for Hardy LTS, but will most likely work with other releases. | ||
[[ | === Installing required packages === | ||
The first thing we need is to install the uml kernel and utilities we will need. | |||
<pre><nowiki> | |||
sudo apt-get install user-mode-linux uml-utilities bridge-utils debootstrap | |||
</nowiki></pre> | |||
=== Creating a virtual machine image === | |||
The next step is getting us a nice ubuntu hardy filesystem: | |||
<pre><nowiki> | |||
# Create an empty file to contain the root filesystem | |||
dd if=/dev/zero of=uml-root-hardy bs=4096 seek=1M count=1 | |||
# Create the filesystem on the file | |||
mkfs.xfs uml-root-hardy | |||
# Mount the filesystem | |||
sudo mount -o loop uml-root-hardy /mnt | |||
# Switch to root account for the rest | |||
sudo -i | |||
# Install a base system on the mounted partition. Use i386 or amd64 for the --arch option | |||
debootstrap --arch amd64 hardy /mnt http://us.archive.ubuntu.com/ubuntu | |||
# Create an fstab file | |||
echo "/dev/ubd0 / xfs defaults 0 1" > /mnt/etc/fstab | |||
echo "proc /proc proc defaults 0 0" >> /mnt/etc/fstab | |||
# Create the device file for the root file system and configure permissions | |||
mknod --mode=660 /mnt/dev/ubd0 b 98 0 | |||
chown root:disk /mnt/dev/ubd0 | |||
# Create a hosts file | |||
echo "127.0.0.1 localhost" > /mnt/etc/hosts | |||
# Configure network interfaces: eth0 using dhcp | |||
echo "auto lo" > /mnt/etc/network/interfaces | |||
echo "iface lo inet loopback" >> /mnt/etc/network/interfaces | |||
echo "auto eth0" >> /mnt/etc/network/interfaces | |||
echo "iface eth0 inet dhcp" >> /mnt/etc/network/interfaces | |||
# Add first terminal and serial terminal to secure list | |||
echo "tty0" >> /mnt/etc/securetty | |||
echo "ttys/0" >> /mnt/etc/securetty | |||
# Remove the other terminal events | |||
rm /mnt/etc/event.d/tty2 | |||
rm /mnt/etc/event.d/tty3 | |||
rm /mnt/etc/event.d/tty4 | |||
rm /mnt/etc/event.d/tty5 | |||
rm /mnt/etc/event.d/tty6 | |||
rm /mnt/etc/udev/rules.d/75-persistent-net-generator.rules | |||
# Return to normal account | |||
exit | |||
</nowiki></pre> | |||
TODO: network bridge | |||
Basically what we've done is created an empty filesystem, mounted it, and made some changes that we want done on all our VMs. Most of the commands need to be run as root using <code><nowiki>sudo</nowiki></code> in order to set the permissions correctly. | |||
=== Running the VM === | |||
We should be ready to run our new VM now: | |||
<pre><nowiki> | |||
linux ubd0=uml-root-hardy.cow1,uml-root-hardy umid=uml1 | |||
</nowiki></pre> | |||
This command runs the virtual machine using a copy-on-write (COW) file in <code><nowiki>uml-root-hardy.cow1</nowiki></code>. This file receives all changes that are made in the filesystem. <code><nowiki>uml-root-hardy</nowiki></code> remains unchanged, so we can run several virtual machines from this image. | |||
'''Note:''' if your virtual machine crashes when mounting the root filesystem, the copy-on-write mechanism doesn't work. Use the following command instead: | |||
<pre><nowiki> | |||
linux ubd0=uml-root-hardy umid=uml1 | |||
</nowiki></pre> | |||
This means that the original image will be modified. | |||
This issue has been reported in Launchpad as [https://bugs.launchpad.net/ubuntu/+source/user-mode-linux/+bug/338795 bug 338795]. In the meantime you can use [http://packages.debian.org/lenny/user-mode-linux the package from Debian]. | |||
=== Networking === | |||
'''Just started''' | |||
To have your UML talking to the rest of the world, you have some options and one would be to use a [[UbuntuHelp:TAP|TAP]]-interface in the host-OS. This interface is created with the use of ''tunctl'' as in: | |||
<pre><nowiki> | |||
tunctl -u uml-net | |||
</nowiki></pre> | |||
where `uml-net` is the user who should own the interface `/dev/net/tun`. It's very important this user matches the one specified in /etc/default/uml-utilities or the network won't work. | |||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2009年5月12日 (二) 19:24的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/UserModeLinux }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/af | • {{#if: UbuntuHelp:UserModeLinux|Afrikaans| [[::UserModeLinux/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/ar | • {{#if: UbuntuHelp:UserModeLinux|العربية| [[::UserModeLinux/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/az | • {{#if: UbuntuHelp:UserModeLinux|azərbaycanca| [[::UserModeLinux/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/bcc | • {{#if: UbuntuHelp:UserModeLinux|جهلسری بلوچی| [[::UserModeLinux/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/bg | • {{#if: UbuntuHelp:UserModeLinux|български| [[::UserModeLinux/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/br | • {{#if: UbuntuHelp:UserModeLinux|brezhoneg| [[::UserModeLinux/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/ca | • {{#if: UbuntuHelp:UserModeLinux|català| [[::UserModeLinux/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/cs | • {{#if: UbuntuHelp:UserModeLinux|čeština| [[::UserModeLinux/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/de | • {{#if: UbuntuHelp:UserModeLinux|Deutsch| [[::UserModeLinux/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/el | • {{#if: UbuntuHelp:UserModeLinux|Ελληνικά| [[::UserModeLinux/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/es | • {{#if: UbuntuHelp:UserModeLinux|español| [[::UserModeLinux/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/fa | • {{#if: UbuntuHelp:UserModeLinux|فارسی| [[::UserModeLinux/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/fi | • {{#if: UbuntuHelp:UserModeLinux|suomi| [[::UserModeLinux/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/fr | • {{#if: UbuntuHelp:UserModeLinux|français| [[::UserModeLinux/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/gu | • {{#if: UbuntuHelp:UserModeLinux|ગુજરાતી| [[::UserModeLinux/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/he | • {{#if: UbuntuHelp:UserModeLinux|עברית| [[::UserModeLinux/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/hu | • {{#if: UbuntuHelp:UserModeLinux|magyar| [[::UserModeLinux/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/id | • {{#if: UbuntuHelp:UserModeLinux|Bahasa Indonesia| [[::UserModeLinux/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/it | • {{#if: UbuntuHelp:UserModeLinux|italiano| [[::UserModeLinux/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/ja | • {{#if: UbuntuHelp:UserModeLinux|日本語| [[::UserModeLinux/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/ko | • {{#if: UbuntuHelp:UserModeLinux|한국어| [[::UserModeLinux/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/ksh | • {{#if: UbuntuHelp:UserModeLinux|Ripoarisch| [[::UserModeLinux/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/mr | • {{#if: UbuntuHelp:UserModeLinux|मराठी| [[::UserModeLinux/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/ms | • {{#if: UbuntuHelp:UserModeLinux|Bahasa Melayu| [[::UserModeLinux/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/nl | • {{#if: UbuntuHelp:UserModeLinux|Nederlands| [[::UserModeLinux/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/no | • {{#if: UbuntuHelp:UserModeLinux|norsk| [[::UserModeLinux/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/oc | • {{#if: UbuntuHelp:UserModeLinux|occitan| [[::UserModeLinux/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/pl | • {{#if: UbuntuHelp:UserModeLinux|polski| [[::UserModeLinux/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/pt | • {{#if: UbuntuHelp:UserModeLinux|português| [[::UserModeLinux/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/ro | • {{#if: UbuntuHelp:UserModeLinux|română| [[::UserModeLinux/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/ru | • {{#if: UbuntuHelp:UserModeLinux|русский| [[::UserModeLinux/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/si | • {{#if: UbuntuHelp:UserModeLinux|සිංහල| [[::UserModeLinux/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/sq | • {{#if: UbuntuHelp:UserModeLinux|shqip| [[::UserModeLinux/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/sr | • {{#if: UbuntuHelp:UserModeLinux|српски / srpski| [[::UserModeLinux/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/sv | • {{#if: UbuntuHelp:UserModeLinux|svenska| [[::UserModeLinux/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/th | • {{#if: UbuntuHelp:UserModeLinux|ไทย| [[::UserModeLinux/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/tr | • {{#if: UbuntuHelp:UserModeLinux|Türkçe| [[::UserModeLinux/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/vi | • {{#if: UbuntuHelp:UserModeLinux|Tiếng Việt| [[::UserModeLinux/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/yue | • {{#if: UbuntuHelp:UserModeLinux|粵語| [[::UserModeLinux/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/zh | • {{#if: UbuntuHelp:UserModeLinux|中文| [[::UserModeLinux/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/zh-hans | • {{#if: UbuntuHelp:UserModeLinux|中文(简体)| [[::UserModeLinux/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:UserModeLinux | UbuntuHelp:UserModeLinux | {{#if: | :}}UserModeLinux}}/zh-hant | • {{#if: UbuntuHelp:UserModeLinux|中文(繁體)| [[::UserModeLinux/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:UserModeLinux|:UserModeLinux|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :UserModeLinux/zh | | {{#ifexist: UserModeLinux/zh | | {{#ifeq: {{#titleparts:UserModeLinux|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:UserModeLinux|1|-1|}} | zh | | }}
<<Include(Tag/ContentCleanup)>> <<Include(Tag/NeedsExpansion)>> User-Mode Linux is another virtualisation technique for running VirtualMachines under GNU/Linux. A simplified version of the Linux kernel is run as a normal user-space process. See the User-Mode Linux project page for more information. This page will help you get started using User-Mode Linux with Ubuntu. Guide is created for Hardy LTS, but will most likely work with other releases.
Installing required packages
The first thing we need is to install the uml kernel and utilities we will need.
sudo apt-get install user-mode-linux uml-utilities bridge-utils debootstrap
Creating a virtual machine image
The next step is getting us a nice ubuntu hardy filesystem:
# Create an empty file to contain the root filesystem dd if=/dev/zero of=uml-root-hardy bs=4096 seek=1M count=1 # Create the filesystem on the file mkfs.xfs uml-root-hardy # Mount the filesystem sudo mount -o loop uml-root-hardy /mnt # Switch to root account for the rest sudo -i # Install a base system on the mounted partition. Use i386 or amd64 for the --arch option debootstrap --arch amd64 hardy /mnt http://us.archive.ubuntu.com/ubuntu # Create an fstab file echo "/dev/ubd0 / xfs defaults 0 1" > /mnt/etc/fstab echo "proc /proc proc defaults 0 0" >> /mnt/etc/fstab # Create the device file for the root file system and configure permissions mknod --mode=660 /mnt/dev/ubd0 b 98 0 chown root:disk /mnt/dev/ubd0 # Create a hosts file echo "127.0.0.1 localhost" > /mnt/etc/hosts # Configure network interfaces: eth0 using dhcp echo "auto lo" > /mnt/etc/network/interfaces echo "iface lo inet loopback" >> /mnt/etc/network/interfaces echo "auto eth0" >> /mnt/etc/network/interfaces echo "iface eth0 inet dhcp" >> /mnt/etc/network/interfaces # Add first terminal and serial terminal to secure list echo "tty0" >> /mnt/etc/securetty echo "ttys/0" >> /mnt/etc/securetty # Remove the other terminal events rm /mnt/etc/event.d/tty2 rm /mnt/etc/event.d/tty3 rm /mnt/etc/event.d/tty4 rm /mnt/etc/event.d/tty5 rm /mnt/etc/event.d/tty6 rm /mnt/etc/udev/rules.d/75-persistent-net-generator.rules # Return to normal account exit
TODO: network bridge
Basically what we've done is created an empty filesystem, mounted it, and made some changes that we want done on all our VMs. Most of the commands need to be run as root using sudo
in order to set the permissions correctly.
Running the VM
We should be ready to run our new VM now:
linux ubd0=uml-root-hardy.cow1,uml-root-hardy umid=uml1
This command runs the virtual machine using a copy-on-write (COW) file in uml-root-hardy.cow1
. This file receives all changes that are made in the filesystem. uml-root-hardy
remains unchanged, so we can run several virtual machines from this image.
Note: if your virtual machine crashes when mounting the root filesystem, the copy-on-write mechanism doesn't work. Use the following command instead:
linux ubd0=uml-root-hardy umid=uml1
This means that the original image will be modified. This issue has been reported in Launchpad as bug 338795. In the meantime you can use the package from Debian.
Networking
Just started To have your UML talking to the rest of the world, you have some options and one would be to use a TAP-interface in the host-OS. This interface is created with the use of tunctl as in:
tunctl -u uml-net
where `uml-net` is the user who should own the interface `/dev/net/tun`. It's very important this user matches the one specified in /etc/default/uml-utilities or the network won't work.