Arief Yudhawarman

Masih belajar buat blog

Instalasi Xen Hypervisor pada Debian Wheezy

with one comment

Xen Hypervisor

Xen is an open-source (GPL) type-1 or baremetal hypervisor, which makes it possible to run many instances of an operating system or indeed different operating systems in parallel on a single machine (or host).
Here are some of the Xen Project hypervisor’s key features:

  • Small footprint and interface (is around 1MB in size). Because it uses a microkernel design, with a small memory footprint and limited interface to the guest, it is more robust and secure than other hypervisors.
  • Operating system agnostic: Most installations run with Linux as the main control stack (aka “domain 0”). But a number of other operating systems can be used instead, including NetBSD and OpenSolaris.
  • Driver Isolation: The Xen Project hypervisor has the capability to allow the main device driver for a system to run inside of a virtual machine. If the driver crashes, or is compromised, the VM containing the driver can be rebooted and the driver restarted without affecting the rest of the system.
  • Paravirtualization: Fully paravirtualized guests have been optimized to run as a virtual machine. This allows the guests to run much faster than with hardware extensions (HVM). Additionally, the hypervisor can run on hardware that doesn’t support virtualization extensions.

Guest types
Xen supports running two different types of guests: Paravirtualization (PV) and Full or Hardware assisted Virtualization (HVM). Both guest types can be used at the same time on a single Xen system. It is also possible to use techniques used for Paravirtualization in an HVM guest: essentially creating a continuum between PV and HVM. This approach is called PV on HVM. See the Xen Overview on the Xen wiki for more information.

Domain 0
Xen has a special domain called domain 0 which contains drivers for the hardware, as well as the toolstack to control VMs. Domain 0 is often referred to as dom0. Before installing Xen you should install Debian on the host machine. This installation will form the basis of Domain 0.

Xen Architecture

Xen Architecture


  1. Xen
  2. Xen Project Software Overview

Instalasi OS Debian

  1. Hal-hal yang perlu dilakukan sebelum melakukan instalasi.
    • CD instalasi Debian 7.8.0 NetInstal Amd64.
    • CPU 2 cores (64-bit).
    • Memori minimal 4GB.
    • Harddisk 1TB untuk keperluan instalasi OS Debian dan guest OS.
    • Network interface yang akan memperoleh ip address dari dhcp server dan terhubung ke internet.
    • Setup BIOS pada komputer.
      • Setup first booting agar menggunakan CD.
      • Hidupkan feature untuk virtualisasi.
  2. Booting komputer dengan CD Installer.
  3. Klik Install.

    Instalasi debian

    Instalasi debian

  4. Pilih bahasa English untuk proses instalasi.
  5. Untuk setup time zone dan system locale pilih Other -> Asia -> Indonesia.
  6. Untuk default locale settings pilih United States – en_US.UTF-8.
  7. Konfigur keymap untuk keyboard menggunakan American English.
  8. Selanjutnya proses instalasi akan melakukan Loading additional components.
  9. Setelah sampai di menu Configure the network lakukan pengisian sbb:
    • Hostname : server
    • Domain name :
  10. Pada menu setup users and passwords isikan password yang kuat untuk user root.
  11. Kemudian lakukan pengisian Full Name, username, dan password untuk user baru.
  12. Setup time zone menggunakan Western (Sumatra, Jakarta, Java, West and Central Kalimantan).
  13. Sampai pada menu Partition disks lakukan partisi seperti gambar di bawah ini:
       Device Boot      Start         End      Blocks   Id  System 
    /dev/sda1   *        2048    39063551    19530752   83  Linux 
    /dev/sda2        39063552    46876671     3906560   82  Linux swap / Solaris 
    /dev/sda3        46876672  1951168511   952145920   8e  Linux LVM


    • /dev/sda1 adalah root partition dialokasikan space sebesar 20GB.
    • /dev/sda2 adalah swap partition dialokasikan space sebesar 2 x RAM atau 4GB.
    • /dev/sda3 adalah LVM partition. Semua free space dialokasikan untuk partisi ini.
  14. Usai melakukan partisi disk proses installing the base system akan berlangsung.
  15. Pada menu Configure the package manager pilih negara Indonesia sebagai tempat mirror untuk debian archive. Kemudian pilih mirror karena mempunyai bandwidth koneksi internet yang besar dan stabil.
    Configuring apt

    Configuring apt

    Select and Install Software

    Select and Install Software

  16. Langkah berikutnya adalah pemilihan software yang akan diinstal. Pilih 2 software berikut:
    • SSH Server
    • Standard system utilities
  17. Pilih untuk instalasi GRUB boot loader pada master boot record.

    Installing GRUB boot loader

    Installing GRUB boot loader

  18. Setelah selesai instalasi pastikan untuk mengeluarkan CD Instaler. Komputer akan reboot.

Pra Instalasi Xen Hypervisor

  1. Setelah booting, login ke komputer lalu pastikan bahwa prosesor sudah support virtualisasi dengan menjalankan perintah yang berhuruf tebal di bawah ini.

    root@server:~# egrep '^flags.*(vmx|svm)' /proc/cpuinfo
    flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt lahf_lm arat epb dtherm tpr_shadow vnmi flexpriority ept vpid
  2. Berikutnya lakukan update dan instalasi package lvm dan ntp.
    apt-get update
    apt-get install lvm2 liblinux-lvm-perl ntp
  3. Instalasi NTP diperlukan agar semua guest atau domU mempunyai time yang sync dengan dom0.
    • Jika ingin mengubah time zone lakukan perintah dpkg-reconfigure tzdata
    • Buka file /etc/ntp.conf dan edit server ntp lalu tambahkan network yang bisa melakukan sync ke ntp server.
      # ntp servers 
      # clients who can access 
      restrict mask nomodify notrap
    • Restart service ntp dengan perintah dpkg-reconfigure ntp
    • Lakukan perintah ntpq -p untuk melakukan query ke server root ntp.
      root@server:~# ntpq -p 
           remote           refid      st t when poll reach   delay   offset  jitter 
      ==============================================================================   2 u    3   64    1   26.409    8.990   0.002    2 u    4   64    1   10.243   12.871   0.002 
       kartolo.sby.dat    2 u    3   64    1   24.745    6.041   0.002   2 u    2   64    1   31.593   19.630   0.002
  4. Setup networking
    • Edit file /etc/hosts	localhost  server
    • Edit file /etc/network/interfaces
      # The loopback network interface 
      auto lo 
      iface lo inet loopback 
      # The primary network interface 
      auto eth0 
      iface eth0 inet static
    • Edit file /etc/resolv.conf
    • Restart networking
      /etc/init.d/networking restart

Instalasi Xen Hypervisor

  1. Instal xen hypervisor.
    apt-get install xen-linux-system-amd64 xen-tools
  2. Buat kernel-xen agar memiliki prioritas tertinggi saat booting.
    mv /etc/grub.d/20_linux_xen /etc/grub.d/08_linux_xen
  3. Lakukan reboot
  4. Komputer akan booting menggunakan kernel-xen.
    Lihat informasi xen di komputer dengan perintah xm info

    root@server:~# xm info 
    host                   : server
    release                : 3.2.0-4-amd64 
    version                : #1 SMP Debian 3.2.68-1+deb7u2 
    machine                : x86_64 
    nr_cpus                : 4 
    nr_nodes               : 1 
    cores_per_socket       : 4 
    threads_per_core       : 1 
    cpu_mhz                : 2133 
    hw_caps                : bfebfbff:2c100800:00000000:00003f40:009ee3fd:00000000:00000001:00000000 
    virt_caps              : hvm 
    total_memory           : 10231 
    free_memory            : 1161 
    free_cpus              : 0 
    xen_major              : 4 
    xen_minor              : 1 
    xen_extra              : .4 
    xen_caps               : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64 
    xen_scheduler          : credit 
    xen_pagesize           : 4096 
    platform_params        : virt_start=0xffff800000000000 
    xen_changeset          : unavailable 
    xen_commandline        : placeholder 
    cc_compiler            : gcc version 4.7.2 (Debian 4.7.2-5) 
    cc_compile_by          : ultrotter 
    cc_compile_domain      : 
    cc_compile_date        : Fri Jun 12 16:15:34 EEST 2015 
    xend_config_format     : 4


  5. Tampilkan isi Xen message buffer
    root@server:~# xm dmesg 
    (XEN) Xen version 4.1.4 (Debian 4.1.4-3+deb7u8) ( (gcc version 4.7.2 (Debian 4.7.2-5) ) Fri Jun 12 16:15:34 EEST 2015 
    (XEN) Bootloader: GRUB 1.99-27+deb7u2 
    (XEN) Command line: placeholder 
    (XEN) Video information: 
    (XEN)  VGA is text mode 80x25, font 8x16 
    (XEN)  VBE/DDC methods: none; EDID transfer time: 0 seconds 
    (XEN)  EDID info not retrieved because no DDC retrieval method detected 
    (XEN) Disc information: 
    (XEN)  Found 1 MBR signatures 
    (XEN)  Found 1 EDD information structures 
    (XEN) Xen-e820 RAM map: 
    (XEN)  0000000000000000 - 0000000000093400 (usable) 
    (XEN)  0000000000093400 - 00000000000a0000 (reserved) 
    (XEN)  00000000000e4000 - 0000000000100000 (reserved) 
    (XEN)  0000000000100000 - 00000000bf780000 (usable) 
    (XEN)  00000000bf78e000 - 00000000bf790000 type 9 
    (XEN)  00000000bf790000 - 00000000bf79e000 (ACPI data) 
    (XEN)  00000000bf79e000 - 00000000bf7d0000 (ACPI NVS) 
    (XEN)  00000000bf7d0000 - 00000000bf7e0000 (reserved) 
    (XEN)  00000000bf7ec000 - 00000000c0000000 (reserved) 
    (XEN)  00000000e0000000 - 00000000f0000000 (reserved) 
    (XEN)  00000000fee00000 - 00000000fee01000 (reserved) 
    (XEN)  00000000ffc00000 - 0000000100000000 (reserved) 
    (XEN)  0000000100000000 - 00000002c0000000 (usable) 
    (XEN) ACPI: RSDP 000FABE0, 0024 (r2 ACPIAM) 
    (XEN) ACPI: XSDT BF790100, 007C (r1 SMCI            20110105 MSFT       97) 
    (XEN) ACPI: FACP BF790290, 00F4 (r3 010511 FACP1122 20110105 MSFT       97) 
    (XEN) ACPI: DSDT BF7906A0, 655C (r1  10006 10006000        0 INTL 20051117) 
    (XEN) ACPI: FACS BF79E000, 0040 
    (XEN) ACPI: APIC BF790390, 011E (r1 010511 APIC1122 20110105 MSFT       97) 
    (XEN) ACPI: MCFG BF7904B0, 003C (r1 010511 OEMMCFG  20110105 MSFT       97) 
    (XEN) ACPI: SLIT BF7904F0, 0030 (r1 010511 OEMSLIT  20110105 MSFT       97) 
    (XEN) ACPI: OEMB BF79E040, 0085 (r1 010511 OEMB1122 20110105 MSFT       97) 
    (XEN) ACPI: HPET BF79A6A0, 0038 (r1 010511 OEMHPET  20110105 MSFT       97) 
    (XEN) ACPI: SSDT BF79F1C0, 0363 (r1 DpgPmm    CpuPm       12 INTL 20051117) 
    (XEN) ACPI: EINJ BF79A6E0, 0130 (r1  AMIER AMI_EINJ 20110105 MSFT       97) 
    (XEN) ACPI: BERT BF79A870, 0030 (r1  AMIER AMI_BERT 20110105 MSFT       97) 
    (XEN) ACPI: ERST BF79A8A0, 01B0 (r1  AMIER AMI_ERST 20110105 MSFT       97) 
    (XEN) ACPI: HEST BF79AA50, 00A8 (r1  AMIER ABC_HEST 20110105 MSFT       97) 
    (XEN) System RAM: 10231MB (10476620kB) 
    (XEN) Domain heap initialised 
    (XEN) Processor #0 6:12 APIC version 21 
    (XEN) Processor #2 6:12 APIC version 21 
    (XEN) Processor #18 6:12 APIC version 21 
    (XEN) Processor #20 6:12 APIC version 21 
    (XEN) IOAPIC[0]: apic_id 1, version 32, address 0xfec00000, GSI 0-23 
    (XEN) IOAPIC[1]: apic_id 3, version 32, address 0xfec8a000, GSI 24-47 
    (XEN) Enabling APIC mode:  Flat.  Using 2 I/O APICs 
    (XEN) ERST table is invalid 
    (XEN) Using scheduler: SMP Credit Scheduler (credit) 
    (XEN) Detected 2133.486 MHz processor. 
    (XEN) Initing memory sharing. 
    (XEN) I/O virtualisation disabled 
    (XEN) Enabled directed EOI with ioapic_ack_old on! 
    (XEN)  -> Using old ACK method 
    (XEN) Platform timer is 14.318MHz HPET 
    (XEN) Allocated console ring of 16 KiB. 
    (XEN) VMX: Supported advanced features: 
    (XEN)  - APIC MMIO access virtualisation 
    (XEN)  - APIC TPR shadow 
    (XEN)  - Extended Page Tables (EPT) 
    (XEN)  - Virtual-Processor Identifiers (VPID) 
    (XEN)  - Virtual NMI 
    (XEN)  - MSR direct-access bitmap 
    (XEN)  - Unrestricted Guest 
    (XEN) HVM: ASIDs enabled. 
    (XEN) HVM: VMX enabled 
    (XEN) HVM: Hardware Assisted Paging (HAP) detected 
    (XEN) HVM: HAP page sizes: 4kB, 2MB, 1GB 
    (XEN) Brought up 4 CPUs 
    (XEN) *** LOADING DOMAIN 0 *** 
    (XEN)  Xen  kernel: 64-bit, lsb, compat32 
    (XEN)  Dom0 kernel: 64-bit, PAE, lsb, paddr 0x1000000 -> 0x193f000 
    (XEN)  Dom0 alloc.:   00000002b0000000->00000002b4000000 (2532985 pages to be allocated) 
    (XEN)  Init. ramdisk: 00000002be283000->00000002bffffc00 
    (XEN)  Loaded kernel: ffffffff81000000->ffffffff8193f000 
    (XEN)  Init. ramdisk: ffffffff8193f000->ffffffff836bbc00 
    (XEN)  Phys-Mach map: ffffffff836bc000->ffffffff84a3dfb0 
    (XEN)  Start info:    ffffffff84a3e000->ffffffff84a3e4b4 
    (XEN)  Page tables:   ffffffff84a3f000->ffffffff84a68000 
    (XEN)  Boot stack:    ffffffff84a68000->ffffffff84a69000 
    (XEN)  TOTAL:         ffffffff80000000->ffffffff84c00000 
    (XEN)  ENTRY ADDRESS: ffffffff816aa200 
    (XEN) Dom0 has maximum 4 VCPUs 
    (XEN) Scrubbing Free RAM: .done. 
    (XEN) Xen trace buffers: disabled 
    (XEN) Std. Loglevel: Errors and warnings 
    (XEN) Guest Loglevel: Nothing (Rate-limited: Errors and warnings) 
    (XEN) Xen is relinquishing VGA console. 
    (XEN) *** Serial input -> DOM0 (type 'CTRL-a' three times to switch input to Xen) 
    (XEN) Freed 240kB init memory. 
    (XEN) physdev.c:168: dom0: wrong map_pirq type 3 


  6. Konfigur bridging
    • Instal bridge-utils
      apt-get install bridge-utils
    • Edit file /etc/network/interfaces
      auto lo 
      iface lo inet loopback 
      # The primary network interface 
      auto eth0
      iface eth0 inet manual 
      auto xenbr0 
      iface xenbr0 inet static 
      	bridge_ports eth0 
      	bridge_stp off 
      	bridge_fd 0
    • Restart network.
    • Pastikan interface bridge xenbr0 telah up.
      root@server:~# ip add sh xenbr0 
      4: xenbr0:  mtu 1500 qdisc noqueue state UP 
          link/ether 00:25:90:36:90:f8 brd ff:ff:ff:ff:ff:ff 
          inet brd scope global xenbr0 
          inet6 fe80::225:90ff:fe36:90f8/64 scope link 
             valid_lft forever preferred_lft forever 
      root@server:~# brctl show 
      bridge name	bridge id		STP enabled	interfaces 
      xenbr0		8000.0025903690f8	no		eth0 
  7. Konfigur memori dan cpu Domain 0 (dom0).
    Jika kita inginkan dom0 mempunyai memori statik 1024M dan jumlah cpu 1 maka edit file-file berikut:

    • Edit file /etc/xen/xend-config.sxp seperti contoh di bawah:
      # (dom0-min-mem 196) 
      (dom0-min-mem 1024) 
      # (enable-dom0-ballooning yes) 
      (enable-dom0-ballooning no) 
      # (dom0-cpus 0) 
      (dom0-cpus 1) 
    • Edit file /etc/default/grub tambahkan baris ini:
      GRUB_CMDLINE_XEN="dom0_mem=1024M dom0_max_vcpus=1 dom0_vcpus_pin"
    • Kemudian lakukan update-grub dan reboot server.
      root@server:~# update-grub 
      Generating grub.cfg ... 
      Found linux image: /boot/vmlinuz-3.2.0-4-amd64 
      Found initrd image: /boot/initrd.img-3.2.0-4-amd64 
      Found linux image: /boot/vmlinuz-3.2.0-4-amd64 
      Found initrd image: /boot/initrd.img-3.2.0-4-amd64 
      root@server:~# reboot
  8. Usai reboot tampilkan isi virtual server (host dan guests) dengan perintah xm list.
    root@server:~# xm list
    Name                                  ID   Mem VCPUs      State   Time(s) 
    Domain-0                               0  1023     1     r-----      9.2

    Saat ini belum ada guests yang ditampilkan hanya host Domain-0 atau dom0. Jika tadi telah melakukan langkah 7 maka memori dan jumlah cpu untuk dom0 telah disesuaikan.

Setup LVM

  1. Lakukan inisialisasi untuk partisi disk yang akan disetup sebagai LVM.
    root@server:~# pvcreate -v /dev/sda3
        Set up physical volume for "/dev/sda3" with 1904291840 available sectors
        Zeroing start of device /dev/sda3
      Writing physical volume data to disk "/dev/sda3"
      Physical volume "/dev/sda3" successfully created
  2. Buat volume group vg0.
    root@server:~# vgcreate -v vg0 /dev/sda3
        Wiping cache of LVM-capable devices
        Adding physical volume '/dev/sda3' to volume group 'vg0'
        Creating directory "/etc/lvm/archive"
        Archiving volume group "vg0" metadata (seqno 0).
        Creating directory "/etc/lvm/backup"
        Creating volume group backup "/etc/lvm/backup/vg0" (seqno 1).
      Volume group "vg0" successfully created
  3. Tampilkan isi volume group.
    root@server:~# vgdisplay 
      --- Volume group ---
      VG Name               vg0
      System ID             
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  1
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                0
      Open LV               0
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               908.04 GiB
      PE Size               4.00 MiB
      Total PE              232457
      Alloc PE / Size       0 / 0   
      Free  PE / Size       232457 / 908.04 GiB
      VG UUID               qZivjn-OdUs-nAF7-0dST-7weg-n05g-ARO0ag

Instalasi paket tambahan

apt-get install nfs-kernel-server
apt-get install ntfs-3g
apt-get install rsync
apt-get install rdiff
apt-get install rdiff-backup
apt-get install kpartx
apt-get install lzop
apt-get install smartmontools
apt-get install sysv-rc-conf
apt-get install partclone
apt-get install mc
apt-get install vim

Last update: 2016-09-06 20:00 +07:00


Written by awarmanf

September 7, 2016 at 3:30 am

Posted in Linux, virtualization, xen

One Response

Subscribe to comments with RSS.

  1. […] yang kedua tentu instal Xen Hypervisor dahulu (Instalasi Xen Hypervisor pada Debian Wheezy). Selesai instal berikut ini […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: