summaryrefslogtreecommitdiff
path: root/docs/installation/virtual/libvirt.rst
blob: 5bc1627373c2d471bbc8395e0b664af1aebaca9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
.. _libvirt:

***************************
Running on Libvirt Qemu/KVM
***************************

Libvirt is an open-source API, daemon and management tool for managing platform
virtualization. There are several ways to deploy VyOS on libvirt kvm.
Use Virt-manager and native CLI. In an example we will be use use 4 gigabytes
of memory, 2 cores CPU and default network virbr0.

CLI
===

Deploy from ISO
---------------

Create VM name ``vyos_r1``. You must specify the path to the ``ISO`` image,
the disk ``qcow2`` will be created automatically. The ``default`` network is
the virtual network (type Virtio) created by the hypervisor with NAT.

.. code-block:: none

  $ virt-install -n vyos_r1 \
    --ram 4096 \
    --vcpus 2 \
    --cdrom /var/lib/libvirt/images/vyos.iso \
    --os-variant debian10 \
    --network network=default \
    --graphics vnc \
    --hvm \
    --virt-type kvm \
    --disk path=/var/lib/libvirt/images/vyos_r1.qcow2,bus=virtio,size=8 \
    --noautoconsole

Connect to VM  with command ``virsh console vyos_r1``

.. code-block:: none

  $ virsh console vyos_r1

  Connected to domain vyos_r1
  Escape character is ^]

  vyos login: vyos
  Password:

  vyos@vyos:~$ install image

After installation - exit from the console using the key combination
``Ctrl + ]`` and reboot the system.

Deploy from qcow2
-----------------
The convenience of using :abbr:`KVM (Kernel-based Virtual Machine)`
images is that they don't need to be installed.
Download predefined VyOS.qcow2 image for ``KVM``

.. code-block:: none

  curl --url link_to_vyos_kvm.qcow2 --output /var/lib/libvirt/images/vyos_kvm.qcow2

Create VM with ``import`` qcow2 disk option.

.. code-block:: none

  $ virt-install -n vyos_r2 \
     --ram 4096 \
     --vcpus 2 \
     --os-variant debian10 \
     --network network=default \
     --graphics vnc \
     --hvm \
     --virt-type kvm \
     --disk path=/var/lib/libvirt/images/vyos_kvm.qcow2,bus=virtio \
     --import \
     --noautoconsole

Connect to VM  with command ``virsh console vyos_r2``

.. code-block:: none

  $ virsh console vyos_r2

  Connected to domain vyos_r2
  Escape character is ^]

  vyos login: vyos
  Password:

  vyos@vyos:~$

If you can not go to this screen

.. code-block:: none

  vyos login: vyos
  Password:

Stayed in this stage. This is because the KVM console is chosen as the default boot option.

.. code-block:: none

  Connected to domain vyos_r2
  Escape character is ^]

Open a secondary/parallel session and use this command to reboot the VM:

.. code-block:: none

  $ virsh reboot vyos_r2

Then go to the first session where you opened the console.
Select ``VyOS 1.4.x for QEMU (Serial console)`` and press ``Enter``

The system is fully operational.

Virt-manager
============
The virt-manager application is a desktop user interface for managing virtual
machines through libvirt. On the linux open
:abbr:`VMM (Virtual Machine Manager)`.

.. _libvirt:virt-manager_iso:

Deploy from ISO
---------------

1. Open :abbr:`VMM (Virtual Machine Manager)` and Create a new
   :abbr:`VM (Virtual Machine)`

2. Choose ``Local install media`` (ISO)

.. figure:: /_static/images/virt-libvirt-01.png

3. Choose path to iso vyos.iso. Operating System can be any Debian based.

.. figure:: /_static/images/virt-libvirt-02.png

4. Choose Memory and CPU

.. figure:: /_static/images/virt-libvirt-03.png

5. Disk size

.. figure:: /_static/images/virt-libvirt-04.png

6. Name of VM and network selection

.. figure:: /_static/images/virt-libvirt-05.png

7. Then you will be taken to the console.

.. figure:: /_static/images/virt-libvirt-06.png

.. _libvirt:virt-manager_qcow2:

Deploy from qcow2
-----------------

Download predefined VyOS.qcow2 image for ``KVM``

.. code-block:: none

  curl --url link_to_vyos_kvm.qcow2 --output /var/lib/libvirt/images/vyos_kvm.qcow2


1. Open :abbr:`VMM (Virtual Machine Manager)` and Create a new
   :abbr:`VM (Virtual Machine)`

2. Choose ``Import existing disk`` image

.. figure:: /_static/images/virt-libvirt-qc-01.png

3. Choose the path to the image ``vyos_kvm.qcow2`` that was previously
   downloaded . Operation System can be any Debian based.

.. figure:: /_static/images/virt-libvirt-qc-02.png

4. Choose Memory and CPU

.. figure:: /_static/images/virt-libvirt-03.png

5. Name of VM and network selection

.. figure:: /_static/images/virt-libvirt-05.png

6. Then you will be taken to the console.

.. figure:: /_static/images/virt-libvirt-qc-03.png