Виртуальная машина linux fedora

Getting started with virtualization

Fedora uses the libvirt family of tools as its virtualization solution.

Enabling hardware virtualization support

This section covers setting up libvirt on your system. After setting up libvirt , you can create virtualized guest operating systems, also known as virtual machines.

System requirements

To run virtualization on Fedora, you need:

  • At least 600MB of hard disk storage per guest. A minimal command-line Fedora system requires 600MB of storage. Standard Fedora desktop guests require at least 3GB of space.
  • At least 256MB of RAM per guest, plus 256MB for the base operating system. At least 756MB is recommended for each guest of a modern operating system. A good way to estimate this is to think about how much memory is required for the operating system normally, and allocate that amount to the virtualized guest.

KVM requires a CPU with virtualization extensions, found on most consumer CPUs. These extensions are called Intel VT or AMD-V. To check whether you have CPU support, run the following command:

$ egrep '^flags.*(vmx|svm)' /proc/cpuinfo

If this command results in nothing printed, your system does not support the relevant virtualization extensions. You can still use QEMU/KVM, but the emulator will fall back to software virtualization, which is much slower.

Installing virtualization software

When installing Fedora, you can install the virtualization packages by selecting Virtualization in the Base Group in the installer. See Installing Using Anaconda.

For existing Fedora installations, you can install the virtualization tools via the command line using the Virtualization Package Group. To view the packages, run:

$ dnf groupinfo virtualization Group: Virtualization Description: These packages provide a graphical virtualization environment. Mandatory Packages: virt-install Default Packages: libvirt-daemon-config-network libvirt-daemon-kvm qemu-kvm virt-manager virt-viewer Optional Packages: libguestfs-tools python3-libguestfs virt-top
  1. Run the following command to install the mandatory and default packages in the virtualization group:
# sudo dnf install @virtualization
# sudo dnf group install --with-optional virtualization
# sudo systemctl start libvirtd
# sudo systemctl enable libvirtd
$ lsmod | grep kvm kvm_amd 114688 0 kvm 831488 1 kvm_amd

Networking Support

By default, libvirt will create a private network for your guests on the host machine. This private network will use a 192.168.x.x subnet and not be reachable directly from the network the host machine is on. However, virtual guests can use the host machine as a gateway and can connect out via it. If you need to provide services on your guests that are reachable via other machines on your host network you can use iptables DNAT rules to forward in specific ports, or you can set up a bridged environment.

Читайте также:  Rtl wifi driver linux

See the libvirt networking setup page for more information on how to setup a bridged network.

Creating virtual machines

The installation of Fedora guests using Anaconda is supported. The installation can be started on the command-line using the virt-install program or in the user interface program virt-manager .

Creating a guest with virt-install

virt-install is a command-line based tool for creating virtualized guests. Execute virt-install —help for command line help, or you can find the manual page at man 1 virt-install .

To use the virt-install command, you should first download an ISO of the Fedora version you wish to install. You can find the latest Fedora images at https://getfedora.org. This ISO is only needed during Fedora installation, and can be deleted to free up storage space afterwards if desired. More information about Fedora installation can be found in the Installation Guide. In this example we’ll use Fedora Workstation.

Planning VM Resources

Adjust the ram, vcpus, and disk size parameters according to the resources you have available.

  • Storage: An easy way to check your disk size from a bash shell is using the df(1)` utility from the shell:

When allocating resources to your VM, keep in mind the minimum system requirements for the version of Fedora you are installing as well as your use case requirements. For Fedora 38, you can find this in the Release Notes.

Create Storage for the VM

The libvirt default storage pool is located at `/var/lib/libvirt/images — which is the parent file path we use in this example. For individuals who are lacking enough storage in that path, you can simply mount a new disk or partition to that directory path (from the BASH shell, type man 1 mount ) or select a new path. In the example virt-install command below, the disk did not exist prior to running virt-install. When the specified disk is not pre-existing, you must specify the size so virt-install can create a disk for you. If your disk already exists, you can safely remove the ,size=20 parameter from the disk argument.

You have several disk storage options for your VM. While it’s outside the scope of this article to discuss these in detail, the following are a few common options. These examples use 20G as the upper limit for disk size, but you can adjust this size to fit your needs.

Читайте также:  Linux get cpu serial number

Again, you do not need to manually allocate storage using the example options shown below if you specify the size parameter in the virt-install example shown below.

Raw File (Non-Sparse)

To create a fully allocated (non-sparse) raw file:

# sudo dd if=/dev/zero of=/var/lib/libvirt/images/guest.img bs=1M count=20480

you can also use fallocate(1):

# sudo fallocate -l 20480M /var/lib/libvirt/images/guest.img
Raw File (Sparse)

To create a dynamically allocated (sparse) raw file:

# sudo rm -f /var/lib/libvirt/images/guest.img # sudo truncate --size=20480M /var/lib/libvirt/images/guest.img
QCOW2

To create a new qcow2-formatted disk separately, you can use qemu-img (the example below specifies a disk size of 20G):

# sudo qemu-img create -f qcow2 /var/lib/libvirt/images/guest.qcow2 20480

More information about libvirt storage options can be found at https://libvirt.org/storage.html.

Finally, run the virt-install command using the following format (adjusting parameters as needed):

# sudo virt-install --name Fedora38 \ --description 'Fedora 38 Workstation' \ --ram 4096 \ --vcpus 2 \ --disk path=/var/lib/libvirt/images/Fedora-Workstation-38/Fedora-Workstation-38-20180518.0.x86_64.qcow2,size=20 \ --os-type linux \ --os-variant fedora38 \ --network bridge=virbr0 \ --graphics vnc,listen=127.0.0.1,port=5901 \ --cdrom /var/lib/libvirt/images/Fedora-Workstation-38/Fedora-Workstation-Live-x86-64-38-1.1.iso \ --noautoconsole

Note: For the graphics parameter, we’re setting the vnc listener to localhost because it’s more secure to tunnel your VNC connection through SSH so that you don’t expose VNC to everyone with access to the network.

virt-install can use kickstart files, for example, virt-install -x ks=kickstart-file-name.ks .

If graphics were enabled, a VNC window will open and present the graphical installer. If graphics were not enabled, a text installer will appear. Proceed with the Fedora installation.

Creating a guest with virt-manager

  1. Start Virtual Machine Manager by navigating to ApplicationsSystem Tools , or by running the following command:

Источник

Устанавливаем Virtualbox в Fedora 36

VirtualBox является популярным продуктом для виртуализации, позволяющий запускать виртуальные машины с разным программным обеспечением. Для него существуют даже подготовленные сборки, например, тот же дистрибутив Kali Linux.

В данной статье мы рассмотрим рекомендуемый способ установки VirtualBox в дистрибутиве Fedora 36, из репозитория RPM Fusion. Репозиторий RPM Fusion содержит многое программное обеспечение, которое по тем или иным причинам не включено в официальный репозиторий Fedora, в том числе и проприетарные драйвера.

Подключаем RPM Fusion в Fedora 36

Если вы уже подключили данный репозиторий, то этот шаг можно пропустить, но для полноты картины так сказать, считаю, что стоит об этом упомянуть. Итак, открываем терминал и вводим команду для подключения репозитория RPM Fusion:

sudo dnf install --nogpgcheck https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

После чего обновляем систему выполнив команду:

Читайте также:  Veeam backup linux host

Устанавливаем VirtualBox

Теперь, когда репозиторий RPM Fusion подключен в Fedora 36, можно приступить к установке VirtualBox со всеми необходимыми зависимостями. Итак, возвращаемся в терминал и вводим команду на установку:

 sudo dnf install gcc kernel-devel kernel-headers akmod-VirtualBox VirtualBox

Virtualbox в Fedora 36 1

Когда все пакеты установятся, необходимо добавить вашего пользователя в группу vboxusers и vboxsf, для этого выполняем следующие команды:

sudo usermod -a -G vboxusers $(whoami) sudo usermod -a -G vboxsf $(whoami)

Virtualbox в Fedora 36 2

На этом можно было бы закончить установку VirtualBox в Fedora 36, но, для полноценного использования необходимо установить расширение extension pack. Для этого можно перейти на официальный сайт VirtualBox и скачать данное расширение:

Virtualbox в Fedora 36 3

А можно воспользоваться консольной утилитой wget, тут стоит обратить внимание на то, какая версия VirtuelBox установилась в Fedora 36, это можно узнать из справки самой программы:

Virtualbox в Fedora 36 4

Как можно увидеть, у нас на данный момент установлен VirtualBox версии 6.1.34, а значит и расширение extension pack нам нужно скачивать именно под эту версию. Отправляемся в терминал и вводим команду на скачивания:

wget https://download.virtualbox.org/virtualbox/6.1.34/Oracle_VM_VirtualBox_Extension_Pack-6.1.34.vbox-extpack

Обращаю ваше внимания на версию расширения, которое мы скачиваем, версия выделена жирным шрифтом, если у вас версия будет другая, то просто отредактируйте ссылку. Ну а мы продолжаем, скачиваем расширение:

Virtualbox в Fedora 36 5

Когда оно скачается, открываем VirtualBox и нажимаем на кнопку “Настройки”, затем переходим на вкладку “Плагины” и нажимаем на крестик, что бы добавить расширение:

Virtualbox в Fedora 36 6

По умолчанию расширение скачается в домашнюю директорию, по этому переходим в нее и добавляем его в VirtualBox:

Virtualbox в Fedora 36 7

Появится окно в котором нажимаем на кнопку “Установить”:

Virtualbox в Fedora 36 8

Принимаем лицензионное соглашения пролистав в самый низ, после чего активируется кнопка “Я согласен”, на которую собственно и необходимо нажать для установки extension pack :

Virtualbox в Fedora 36 9

Вводим пароль и нас радует сообщение об успешной установки расширения:

Virtualbox в Fedora 36 10

Заключение

Некоторые рекомендуют использовать в дистрибутиве Fedora вместо VirtualBox систему виртуализации KVM, в частности она уже предустановлена в виде приложения Boxes о котором написано тут. О том как конвертировать образы VirtualBox для KVM виртуализации, которые также можно загрузить в Boxes, читайте тут.

А на этом сегодня все, если статья оказалась вам полезна, подписывайтесь на рассылку журнала в pdf формате, а так же на социальные сети журнала Cyber-X:

Юморилка, Telegram канал с анекдотами:
Telegram

По вопросам работы сайта, сотрудничества, а так же по иным возникшим вопросам пишите на E-Mail. Если вам нравится журнал и вы хотите отблагодарить за труды, вы можете перечислить донат на развитие проекта.

С уважением, редакция журнала Cyber-X

Источник

Оцените статью
Adblock
detector