XEN

Необходимо было поднять пару сервисов для тестирования на сервере. Решил, для того чтобы не засорять сам сервер, поднять сервисы на виртуальных машинах. Мой выбор пал на XEN. Openvz и vservers являются не настоящими виртуалками, virtualbox использовал ранее, в целом нет нареканий, но хочется чего-нибудь новенького =)

Итак, ставим из репозитария. После установки потребуется ребутнуть сервер.

Далее, я бы рекомендовал отдельный раздел выделить для виртуальных машин.

А вот теперь — создаем машину:

wolf4ara@main-server:~$ sudo xen-create-image -hostname=netwild -size=10Gb -swap=512Mb -ip=10.100.0.7 -netmask=255.255.255.0 \
-gateway=10.100.0.1 -force -dir=/vz -memory=256Mb -arch=i386 -dist=squeeze -passwd
General Information
--------------------
Hostname       :  netwild
Distribution   :  squeeze
Mirror         :  http://ftp.ru.debian.org/debian
Partitions     :  swap            512Mb (swap)
                  /               10Gb  (ext3)
Image type     :  sparse
Memory size    :  256Mb
Kernel path    :  /boot/vmlinuz-2.6.32-5-xen-686
Initrd path    :  /boot/initrd.img-2.6.32-5-xen-686

Networking Information
----------------------
IP Address 1   : 10.100.0.7 [MAC: 00:16:3E:2A:ED:1E]
Netmask        : 255.255.255.0
Gateway        : 10.100.0.1

Creating partition image: /vz/domains/netwild/swap.img
Done

Creating swap on /vz/domains/netwild/swap.img
Done

Creating partition image: /vz/domains/netwild/disk.img
Done

Creating ext3 filesystem on /vz/domains/netwild/disk.img
Done
Installation method: debootstrap
Done

Running hooks
Done

No role scripts were specified.  Skipping

Creating Xen configuration file
Done
Setting up root password
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
All done

Logfile produced at:
         /var/log/xen-tools/netwild.log

Installation Summary
---------------------
Hostname        :  netwild
Distribution    :  squeeze
IP-Address(es)  :  10.100.0.7
RSA Fingerprint :  b2:be:8a:70:a0:d1:30:de:e3:f9:e7:a1:aa:f4:f2:44
Root Password   :  N/A

Параметры:

hostname: имя образа
size: размер виртуального диска
swap: размер swap файла
ip: ip адрес виртуальной машины
netmask: маска сети
gateway: ip адрес маршрутизатора (в данном случае ip основной системы)
force: переписывает уже созданные образы
dir: директория в которой будет содержатся образ
memory: размер памяти выделяемый для системы
arch: архитектура системы (amd64, i386)
dist: дистрибутив который Вы хотите установить
passwd: запрашивать пароль суперпользователя

Запускаем:

wolf4ara@main-server:~$ sudo xm create /etc/xen/netwild.cfg
Using config file "/etc/xen/netwild.cfg".
Started domain netwild (id=2)

Смотрим:

wolf4ara@main-server:~$ sudo xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  2135     2     r----- 203757.2
marina                                       1   124     1     -b----  22889.4
netwild                                      2   256     1     -b----      2.3

Заходим в консоль

wolf4ara@main-server:~$ sudo xm console netwild
[    0.000000] Reserving virtual address space above 0xf5800000
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 2.6.32-5-xen-686 (Debian 2.6.32-48squeeze1) (dannf@debian.org) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Mon Feb 25 05:55:06 UTC 2013
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   NSC Geode by NSC
[    0.000000]   Cyrix CyrixInstead
[    0.000000]   Centaur CentaurHauls
[    0.000000]   Transmeta GenuineTMx86
[    0.000000]   Transmeta TransmetaCPU
[    0.000000]   UMC UMC UMC UMC
[    0.000000] ACPI in unprivileged domain disabled
[    0.000000] released 0 pages of unused memory
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  Xen: 0000000000000000 - 00000000000a0000 (usable)
[    0.000000]  Xen: 00000000000a0000 - 0000000000100000 (reserved)
[    0.000000]  Xen: 0000000000100000 - 0000000010000000 (usable)
[    0.000000] DMI not present or invalid.
[    0.000000] last_pfn = 0x10000 max_arch_pfn = 0x1000000
[    0.000000] init_memory_mapping: 0000000000000000-0000000010000000
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] RAMDISK: 01653000 - 02cf9000
[    0.000000] 0MB HIGHMEM available.
[    0.000000] 256MB LOWMEM available.
[    0.000000]   mapped low ram: 0 - 10000000
[    0.000000]   low ram: 0 - 10000000
[    0.000000]   node 0 low ram: 00000000 - 10000000
[    0.000000]   node 0 bootmap 00002000 - 00004000
[    0.000000] (9 early reservations) ==> bootmem [0000000000 - 0010000000]
[    0.000000]   #0 [0000000000 - 0000001000]   BIOS data page ==> [0000000000 - 0000001000]
[    0.000000]   #1 [0002d3c000 - 0002d56000]   XEN PAGETABLES ==> [0002d3c000 - 0002d56000]
[    0.000000]   #2 [0000001000 - 0000002000]    EX TRAMPOLINE ==> [0000001000 - 0000002000]
[    0.000000]   #3 [0000006000 - 0000007000]       TRAMPOLINE ==> [0000006000 - 0000007000]
[    0.000000]   #4 [0001000000 - 000152da6c]    TEXT DATA BSS ==> [0001000000 - 000152da6c]
[    0.000000]   #5 [0001653000 - 0002cf9000]          RAMDISK ==> [0001653000 - 0002cf9000]
[    0.000000]   #6 [0002cf9000 - 0002d3c000]   XEN START INFO ==> [0002cf9000 - 0002d3c000]
[    0.000000]   #7 [0000007000 - 000006e000]          PGTABLE ==> [0000007000 - 000006e000]
[    0.000000]   #8 [0000002000 - 0000004000]          BOOTMAP ==> [0000002000 - 0000004000]
[    0.000000] Zone PFN ranges:
[    0.000000]   DMA      0x00000000 -> 0x00001000
[    0.000000]   Normal   0x00001000 -> 0x00010000
[    0.000000]   HighMem  0x00010000 -> 0x00010000
[    0.000000] Movable zone start PFN for each node
[    0.000000] early_node_map[2] active PFN ranges
[    0.000000]     0: 0x00000000 -> 0x000000a0
[    0.000000]     0: 0x00000100 -> 0x00010000
[    0.000000] Using APIC driver default
[    0.000000] SFI: Simple Firmware Interface v0.7 http://simplefirmware.org
[    0.000000] SMP: Allowing 1 CPUs, 0 hotplug CPUs
[    0.000000] Local APIC disabled by BIOS -- you can enable it with "lapic"
[    0.000000] APIC: disable apic facility
[    0.000000] PM: Registered nosave memory: 00000000000a0000 - 0000000000100000
[    0.000000] Allocating PCI resources starting at 10000000 (gap: 10000000:f0000000)
[    0.000000] Booting paravirtualized kernel on Xen
[    0.000000] Xen version: 4.0.1 (preserve-AD)
[    0.000000] NR_CPUS:32 nr_cpumask_bits:32 nr_cpu_ids:1 nr_node_ids:1
[    0.000000] PERCPU: Embedded 15 pages/cpu @c2f59000 s37720 r0 d23720 u65536
[    0.000000] pcpu-alloc: s37720 r0 d23720 u65536 alloc=16*4096
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Xen: using vcpu_info placement
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 64928
[    0.000000] Kernel command line: root=/dev/xvda2 ro
[    0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Enabling fast FPU save and restore... done.
[    0.000000] Enabling unmasked SIMD FPU exception support... done.
[    0.000000] Initializing CPU#0
[    0.000000] Initializing HighMem for node 0 (00000000:00000000)
[    0.000000] Memory: 229832k/262144k available (2642k kernel code, 31628k reserved, 1456k data, 404k init, 0k highmem)
[    0.000000] virtual kernel memory layout:
[    0.000000]     fixmap  : 0xf5556000 - 0xf57ff000   (2724 kB)
[    0.000000]     pkmap   : 0xf5000000 - 0xf5200000   (2048 kB)
[    0.000000]     vmalloc : 0xd0800000 - 0xf4ffe000   ( 583 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xd0000000   ( 256 MB)
[    0.000000]       .init : 0xc1401000 - 0xc1466000   ( 404 kB)
[    0.000000]       .data : 0xc1294b1b - 0xc1400b9c   (1456 kB)
[    0.000000]       .text : 0xc1000000 - 0xc1294b1b   (2642 kB)
[    0.000000] SLUB: Genslabs=13, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Hierarchical RCU implementation.
[    0.000000] NR_IRQS:1536
[    0.000000] Console: colour dummy device 80x25
[    0.000000] console [tty0] enabled
[    0.000000] console [hvc0] enabled
[    0.000000] installing Xen timer for CPU 0
[    0.000000] Detected 2000.054 MHz processor.
[    0.004000] Calibrating delay loop (skipped), value calculated using timer frequency.. 4000.10 BogoMIPS (lpj=8000216)
[    0.004000] Security Framework initialized
[    0.004000] SELinux:  Disabled at boot.
[    0.004000] Mount-cache hash table entries: 512
[    0.004000] Initializing cgroup subsys ns
[    0.004000] Initializing cgroup subsys cpuacct
[    0.004000] Initializing cgroup subsys devices
[    0.004000] Initializing cgroup subsys freezer
[    0.004000] Initializing cgroup subsys net_cls
[    0.004000] CPU: L1 I cache: 32K, L1 D cache: 32K
[    0.004000] CPU: L2 cache: 512K
[    0.004000] CPU: Unsupported number of siblings 2
[    0.004000] Performance Events: unsupported p6 CPU model 15 no PMU driver, software events only.
[    0.004000] SMP alternatives: switching to UP code
[    0.042462] Freeing SMP alternatives: 14k freed
[    0.042715] Brought up 1 CPUs
[    0.042892] devtmpfs: initialized
[    0.043400] Grant table initialized
[    0.043412] regulator: core version 0.5
[    0.043469] NET: Registered protocol family 16
[    0.044019] PCI: setting up Xen PCI frontend stub
[    0.044439] bio: create slab <bio-0> at 0
[    0.044523] ACPI: Interpreter disabled.
[    0.044553] xen_balloon: Initialising balloon driver with page order 0.
[    0.044603] vgaarb: loaded
[    0.044683] PCI: System does not support PCI
[    0.044692] PCI: System does not support PCI
[    0.044773] Switching to clocksource xen
[    0.045962] pnp: PnP ACPI: disabled
[    0.045979] PnPBIOS: Disabled
[    0.046227] NET: Registered protocol family 2
[    0.046317] IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.046549] TCP established hash table entries: 8192 (order: 4, 65536 bytes)
[    0.046589] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
[    0.046627] TCP: Hash tables configured (established 8192 bind 8192)
[    0.046634] TCP reno registered
[    0.046702] NET: Registered protocol family 1
[    0.046756] Unpacking initramfs...
[    0.076941] Freeing initrd memory: 23192k freed
[    0.088691] platform rtc_cmos: registered platform RTC device (no PNP device found)
[    0.088889] audit: initializing netlink socket (disabled)
[    0.088911] type=2000 audit(1364976382.684:1): initialized
[    0.092600] HugeTLB registered 2 MB page size, pre-allocated 0 pages
[    0.093754] VFS: Disk quotas dquot_6.5.2
[    0.093818] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.093898] msgmni has been set to 494
[    0.094155] alg: No test for stdrng (krng)
[    0.094229] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
[    0.094243] io scheduler noop registered
[    0.094248] io scheduler anticipatory registered
[    0.094255] io scheduler deadline registered
[    0.094291] io scheduler cfq registered (default)
[    0.094444] isapnp: ISA Plug & Play support disabled
[    0.104081] registering netback
[    0.105503] Linux agpgart interface v0.103
[    0.105593] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.105812] PNP: No PS/2 controller found. Probing ports directly.
[    0.106649] i8042.c: No controller found.
[    0.106728] mice: PS/2 mouse device common for all mice
[    0.106858] rtc_cmos rtc_cmos: rtc core: registered rtc_cmos as rtc0
[    0.106949] cpuidle: using governor ladder
[    0.106960] cpuidle: using governor menu
[    0.106969] No iBFT detected.
[    0.107286] TCP cubic registered
[    0.107449] NET: Registered protocol family 10
[    0.108216] Mobile IPv6
[    0.108232] NET: Registered protocol family 17
[    0.108271] Using IPI No-Shortcut mode
[    0.108403] registered taskstats version 1
[    0.108430] XENBUS: Device with no driver: device/vbd/51714
[    0.108436] XENBUS: Device with no driver: device/vbd/51713
[    0.108443] XENBUS: Device with no driver: device/vif/0
[    0.108449] XENBUS: Device with no driver: device/console/0
[    0.108474] /build/buildd-linux-2.6_2.6.32-48squeeze1-i386-F95osd/linux-2.6-2.6.32/debian/build/source_i386_xen/drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    0.108517] Initalizing network drop monitor service
[    0.108590] Freeing unused kernel memory: 404k freed
[    0.109972] Write protecting the kernel text: 2644k
[    0.110424] Write protecting the kernel read-only data: 972k
Loading, please wait...
[    0.152356] udev[47]: starting version 164
[    0.254836] Initialising Xen virtual ethernet driver.
[    0.364100] blkfront: xvda2: barriers enabled
[    0.374879] blkfront: xvda1: barriers enabled
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... [    0.448976] device-mapper: uevent: version 1.0.3
[    0.450817] device-mapper: ioctl: 4.15.0-ioctl (2009-04-01) initialised: dm-devel@redhat.com
  Volume group "test-debian-2" not found
  Skipping volume group test-debian-2
Unable to find LVM volume test-debian-2/swap_1
done.
Begin: Running /scripts/local-premount ... done.
[    0.520623] kjournald starting.  Commit interval 5 seconds
[    0.520653] EXT3-fs: mounted filesystem with ordered data mode.
Begin: Running /scripts/local-bottom ... done.
done.
Begin: Running /scripts/init-bottom ... done.
INIT: version 2.88 booting
Using makefile-style concurrent boot in runlevel S.
Starting the hotplug events dispatcher: udevd[    0.848945] udev[153]: starting version 164
.
Synthesizing the initial hotplug events...done.
Waiting for /dev to be fully populated...[    0.960708] input: PC Speaker as /devices/platform/pcspkr/input/input0
[    1.064637] Error: Driver 'pcspkr' is already registered, aborting...
done.
Activating swap...[    1.193070] Adding 524280k swap on /dev/xvda1.  Priority:-1 extents:1 across:524280k SS
done.
Checking root file system...fsck from util-linux-ng 2.17.2
/dev/xvda2: clean, 13856/655360 files, 166856/2621440 blocks
done.
[    1.324250] EXT3 FS on xvda2, internal journal
Loading kernel modules...done.
Cleaning up ifupdown....
Setting up networking....
Activating lvm and md swap...done.
Checking file systems...fsck from util-linux-ng 2.17.2
done.
Mounting local filesystems...done.
Activating swapfile swap...done.
Cleaning up temporary files....
Setting kernel variables ...done.
Configuring network interfaces...done.
Cleaning up temporary files....
INIT: Entering runlevel: 2
Using makefile-style concurrent boot in runlevel 2.
Starting enhanced syslogd: rsyslogd.
Starting OpenBSD Secure Shell server: sshd.
Starting periodic command scheduler: cron.

Debian GNU/Linux 6.0 netwild hvc0

netwild login: root
Password:
Linux netwild 2.6.32-5-xen-686 #1 SMP Mon Feb 25 05:55:06 UTC 2013 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@netwild:~#

Команды утилиты управления:

xm create — запускает виртуальную машину на основе конфигурационного файла
xm pause — временно останавливает виртуальную машину
xm unpause — запускает виртуальную машину после остановки
xm save — сохраняет состояние виртуальной машины
xm restore — востанавливает состояние виртуальной машины
xm reboot — перезагружает виртуальную машину
xm shutdown — выключает виртуальную машину
xentop — показывает текущую загрузку всех виртуальных машин
xm list — список запущенных виртуальных машин
xm dmesg — показывает dmesg виртуальной машины
xm delete — удаляет виртуальную машину
xm destroy — принудительно удаляет виртуальную машину

и другие…

При написании опирался на статью — http://habrahabr.ru/post/37824/ спасибо автору)