Меню Рубрики

Установка gentoo linux virtualbox

win-linux

Установка Gentoo на VirtualBox — поможет вам ближе познакомиться с данной операционной системой, а также вы сможете экспериментировать не боясь повредить важные файлы(ведь ее всегда можно быстро восстановить из снимков).

Чтобы установить Gentoo вам потребуется установочный диск, VirtualBox и около 2-3 часов свободного времени.

Разбивка диска:
parted -a optimal /dev/sda
mklabel gpt
unit mib
mkpart primary 1 3
name 1 grub
set 1 bios_grub on
mkpart primary 3 131
name 2 boot
mkpart primary 131 643
name 3 swap
mkpart primary 643 -1
name 4 rootfs
quit

Форматрование разделов:
mkfs.vfat /dev/sda1
mkfs.ext2 /dev/sda2
mkfs.ext4 /dev/sda4
mkswap /dev/sda3
swapon /dev/sda3

Монтирование:
mount /dev/sda4 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda2 /mnt/gentoo/boot

Скачивание архива stage3:
cd /mnt/gentoo
links http://mirror.yandex.ru/gentoo-distfiles/releases/amd64/autobuilds/current-stage3-amd64/
В открывшемся окне найти файл stage3-amd64. tar.bz2, с помощью стрелок на клавиатуре выделить его и нажать кнопку D, чтобы скачать. После закачки нажмите Q чтобы закрыть браузер.

Распаковка архива stage3:
tar xvjpf stage3-*.tar.bz2 —xattrs

Настройка параметров компиляции:
nano -w /mnt/gentoo/etc/portage/make.conf
CFLAGS=»-march=native -O2 -pipe»
MAKEOPTS=»-j4″
После изменения настроек нажмите Ctrl + O, чтобы сохранить изменения. Затем Ctrl + X, чтобы закрыть файл.

Выбор ближайшего зеркала:
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
Откроется окно в котором вам нужно будет пролистать список зеркал с помощью кнопки ↓ и выбрать ближайшее к вам. когда выберите нужное нажмите Пробел, затем Enter

mkdir /mnt/gentoo/etc/portage/repos.conf
cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

Копирование информации о DNS:
cp -L /etc/resolv.conf /mnt/gentoo/etc/

Подключение необходимых файловых систем:
mount -t proc proc /mnt/gentoo/proc
mount —rbind /sys /mnt/gentoo/sys
mount —make-rslave /mnt/gentoo/sys
mount —rbind /dev /mnt/gentoo/dev
mount —make-rslave /mnt/gentoo/dev

Переход в новое окружение:
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1=»(chroot) $PS1″

Обновление Portage:
emerge-webrsync

Выбор подходящего профиля:
eselect profile list
eselect profile set 3

Настройка USE переменной:
nano -w /etc/portage/make.conf
USE=»-gnome -kde -minimal qt4 dbus virtualbox X xorg hal python udev alsa opengl»
INPUT_DEVICES=»virtualbox evdev keyboard mouse»
V

Часовой пояс:
echo «Europe/Moscow» > /etc/timezone
emerge —config sys-libs/timezone-data

Настройка локалей:
nano -w /etc/locale.gen
en_US ISO-8859-1
en_US.UTF-8 UTF-8
ru_RU.UTF-8 UTF-8

Обновление локалей:
locale-gen
eselect locale list
eselect locale set 5
env-update && source /etc/profile && export PS1=»(chroot) $PS1″

Настройка ядра Linux:
emerge —ask sys-kernel/gentoo-sources
emerge —ask sys-kernel/genkernel

nano -w /etc/fstab
/dev/sda2 /boot ext2 defaults 0 2

nano -w /etc/fstab
/dev/sda2 /boot ext2 defaults,noatime 0 2
/dev/sda3 none swap sw 0 0
/dev/sda4 / ext4 noatime 0 1
/dev/cdrom /mnt/cdrom auto noauto,user 0 0

Информация о хосте и домене:
nano -w /etc/conf.d/hostname
hostname=»Gentoo»

Настройка сети:
emerge —ask —noreplace net-misc/netifrc

Файл hosts:
nano -w /etc/hosts
127.0.0.1 Gentoo localhost

Установка пароля Root:
passwd

Установка дополнительных пакетов:
emerge —ask app-admin/sysklogd
rc-update add sysklogd default
emerge —ask sys-fs/dosfstools
emerge —ask net-misc/dhcpcd

Установка загрузчика Grub2:
emerge —ask —verbose sys-boot/grub:2
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Отмонтирование дисков и выход:
exit
cd
umount -l /mnt/gentoo/dev
umount -R /mnt/gentoo
shutdown -h now

Заходим в настройки виртуальной машины переходим в раздел «Носители» и выбираем пункт «Изъять диск из привода». После чего можете запускать виртуальную машину Gentoo.

Добавляем нового пользователя:
useradd -m -G users,wheel,audio,video -s /bin/bash test
passwd test

Установка необходимых программ, добавление в автозагрузку, запуск:
emerge —ask media-sound/alsa-utils
rc-update add alsasound boot
/etc/init.d/alsasound start

Настройка звука:
alsamixer

Кнопками ↑ ↓ устанавливаем уровень звука, кнопками ← → выбираем каналы, где отрегулировать звук. Клавишей M включаем или выключаем канал. Чтобы выйти нажимаем Esc

Теперь чтобы проверить как все работает установите какой-нибудь консольный плеер допустим moc:
emerge moc

Скачайте аудиофайл с помощью программы wget:
wget http://адрес аудио файла

Запуск проигрывателя и проверка звука:
mocp

источник

Install Gentoo in VirtualBox

Installing Gentoo as a VirtualBox VM

Gentoo is one of the most esoteric distributions out there. It offers customizability at the expense of user-friendliness. It does, however, shed light on the internal workings of a Linux installation. To experiment with a Gentoo environment inside a VM is probably a great way to start learning about operating systems in general.

Let’s go through a step-by-step process of installing the base OS along with the explanation behind every step.

1. Getting the right installation media

The easiest way to install Gentoo is by using the Hybrid ISO (LiveDVD). Which means that the disk image can be used for installing the operating system onto another disk or it can just be used as a live environment to boot into for diagnostic purposes.

You can get the image file here. Pick the one that belongs to your hardware platform. Modern Intel and AMD processors usually offer AMD64 architecture.

Next you need to create a VM on VirtualBox. Open VirtualBox, and click on the button that says “New” now you can enter the name of the VM and select ‘Type’ as Linux and ‘Version’ as Gentoo 64-bit.

Set the memory size to 2048MB and then click on “Create” to proceed with the creation of virtual hard disk.

The default values would work just fine in this case (although we are going to work with 32GB of disk space instead of 8GB) and now you can click on ‘Create’ one last time to finalize the details.

Now, select the newly created VM from VirtualBox dashboard and you will be prompted with a start-up disk. Click on the file icon beside it and in the file explorer that opens after that navigate to the gentoo livecd iso file that you have downloaded earlier.

Once you start up the VM you will see the boot menu with the following options:

Selecting x86_64 is the most appropriate option in this case.

After that you will be greeted with a login screen with default gentoo user, click on login without entering any password (as indicated in the screenshot below).

You are now technically inside a Gentoo Operating System. However, this is a live media, which means you can’t use it as a system installed in your (virtual) hard disk. But you can use this environment to install Gentoo onto your virtual hard disk.

2. Partitioning the virtual hard disk

The .vdi disk that we created earlier is just a raw disk at this point, attached to the virtual machine and the VM itself is running the Gentoo live media. Now to install the Gentoo environment onto this disk so that it can boot itself we would need to do several things.

  1. Make the disk bootable.
  2. Format the disk with a filesystem
  3. Install the base Gentoo image onto the root filesystem.

To accomplish the 1st task we just need to make 4 partitions of the following size and preferably in the following order.

  1. Bootloader partition for grub: 50MB in size
  2. Boot partition formatted ext4: 500MB in size
  3. Swap partition for swap file: 2000MB in size
  4. Root partition for main OS and related binaries to reside. Formatted with ext4 filesystem and is going to take the remaining majority of the space of the virtual disk.

To make the partitions we first need to get the name of the virtual disk attached to the system. Open terminal (konsole) and run sudo -i to become root user and then run lsblk to list all the block storage devices.The device name in our case is sda is sda and it is of size 32GB. Next we need to enter parted utility to partition this disk. To do so run, as root:

Now we are in parted utility CLI, let’s start by listing all the partitions by typing print:

And we get an error message saying that the disk is not recognized. This is to be expected since the installation process with Gentoo is not automated, you get to manually configure every little detail including the partitioning details for your base system. First things first, let’s give our disk a proper label.

GPT labels are essential for uniquely identifying a device even after, say, the system reboots and the device is plugged in a different port this label will be responsible for telling the operating system that the disk has just changed SATA ports but it’s still the same data and format as before.

Partition the disk by running the following commands (Lines starting with ‘#’ symbol are comments to explain the command above them):

( parted ) unit MB
#Sets the unit to MegaBytes

( parted ) mkpart primary 1 20
#Makes a primary partition starting from 1 MegaByte to #20th for bios

( parted ) mkpart primary 21 500
#Partition /boot filesystem

( parted ) mkpart primary 501 2500
#Partition of size 2000MB made for swap

( parted ) mkpart primary 2501 -1
#Partition for the /(root) filesystem. -1 indicates that
#this partition goes upto the very end of the disk.

You can see that each partition has a number and is of the type primary. However, they are not formatted with any particular file system or have any use names given or flags set to them. Let’s do that.

After setting appropriate names to all the 4 partitions and 1 bios_grub flag to the first partition we quit the parted utility. Now we move on to formatting the partitions with an appropriate filesystem in our usual bash shell (still as root user) by first running the following command:

You can see that the partitioning scheme has labeled the first partition sda1 which corresponds to grub partition and so on and so forth until sda4. The devices are present in /dev directory as /dev/sda1 , /dev/sda2 and so on.

To format them accordingly, run the commands:

Now we can mount these partitions into the current live environment so that all the necessary operations like building the kernel can be performed in there and stored persistently.

Our would be root partition is mounted at /mnt/gentoo of the current livecd environment and similarly our would be boot partition is mounted on /mnt/gentoo/boot.

3. Getting tarball and using chroot

Now that we have our disk prepared for us, it is time for us to get the tarball of gentoo source code and place it in there. In the live CD environment, open the browser open this link and click on the Stage3 archives under the amd64 section at the top of the page.

Once the download is complete, copy the tarball to the /mnt/gentoo directory and extract it’s content in there.

In the second command, the tar utility is used to uncompress the tarball. xpf tells the tar command that we want to x extract, p preserve permissions on the files and f to imply that we are extracting files and not standard input.

The file extension may not be tar.xz in your case. Observe the name of your tarball file and type in accordingly.

The —xattrs-include part of the command preserves the attributes (read, write and execute) of individual files

And the —numeric-owner ensures a group and user ID number as approved by the Gentoo convention for a typical setup.

If you see the contents that would be extracted in your /mnt/gentoo directory they would resemble a typical Unix root environment with directory like /etc /sbin, etc. The > /mnt/gentoo use tools and package managers to configure it. The package manager would make changes in the / directory but it would be cheated into making changes in /mnt/gentoo directory instead.

Since our would be root partition is mounted on this directory, all the changes would be made over there and then we would boot off this new environment once we are done.

But first, let’s make a few changes in the configuration files:

After the CFLAGS line you should add the following lines which would let portage to treat c++ files the same way as c files. Portage is gentoo’s package manager, loosely speaking. It is used to fetch source code of programs so you can compile them all (automatically) on your native system.

Also copy the resolv.conf file from your livecd environment to the new root.

Now we make sure that all the filesystems necessary for the Linux kernel to gather information about the system are available when it tries to boot. So we take the information gathered by the livecd image about our virtual machine and its hardware and we bind those to our new root filesystem.

It’s time for us to chroot (change root) to /mnt/gentoo.

4. Compiling the Linux kernel

Let’s sync our portage tree (software repository) with the official version. This is similar to apt update in Ubuntu.

Once that finishes, we can select a profile for our system. Which essentially tunes the system for a specific use-case (server, workstation, etc.). We will be going with a KDE plasma environment listed at number six.

Time zone and locale configurations are next:

Locate your location in this directory. In this case, it was Asia/Dili

Next uncomment the location specific character set and language that you want to use from the file /etc/locale.gen. We uncommented the line en US.UTF-8 UTF-8.

Now, we can get Linux kernel sources and start compiling them:

The last command will start compiling the kernel which would take a long time, especially if you have limited hardware resources.

5. Finishing touches

After the kernel compilation we just need to make a few more changes like installing grub, adding a user and making sure that the operating system mounts the essential filesystems automatically during the boot process.

To make sure that the last of those things happen, in the chrooted environment edit the file /etc/fstab where fstab stands for filesystem table:

At the bottom of the file add the following lines:

Install DHCP client so your VM will have network connectivity.

Make sure that the DHCP client starts at the boot process:

Setting a password for the root user is as simple as entering the command below and entering your new password when prompted:

To add a new user named bob enter the command:

We would also need sudo so let’s install that:

And then allow the members of wheel group to execute any arbitrary command, we need to edit the /etc/sudoers file:

Lastly, we need to install and configure grub bootloader:

Now we can exit the chroot environment, and unmount the filesystems:

Go to the VM’s setting and in the storage section, remove the livedvd image attached to the VM.

Upon starting the VM again you will be greeted with a tty interface to your newly installed Gentoo operating system. Login as using the username and password that you chose during the installation.

Conclusion

Just the installation process for Gentoo reveals a lot more about the internal workings and structure underneath most Unix environments. If one desires to attain a deeper knowledge of the system the Gentoo Handbook would be a great place to start!

About the author

Ranvir Singh

I am a tech and science writer with quite a diverse range of interests. A strong believer of the Unix philosophy. Few of the things I am passionate about include system administration, computer hardware and physics.

источник

VirtualBox

VirtualBox is cross-platform virtualization software that allows users to run guest operating systems inside a host operating system without having to reboot. Since 2010 VirtualBox software has been written and maintained by the Oracle Corporation.

Contents

Terminology

/dev/sda1 vfat 2mb bios раздел
/dev/sda2 ext2 128mb boot раздел
/dev/sda3 swap 512mb swap раздел
/dev/sda4 ext4
Term Explanation
Host operating system The host computer. Most likely the physical hardware present in the room. For Gentoo users the host operating system would be Gentoo Linux
Guest operating system The operating system to be installed or currently installed inside the VirtualBox emulation environment. Possible alternative operating systems include Microsoft Windows, Solaris, BSD, Debian, Ubuntu, etc.
VirtualBox Guest Additions Drivers for the guest operating system. These drivers provide smoother operation with the Host operating system compared to the standard drivers installed by the Guest operating system.

Installation

There is a source based package (app-emulation/virtualbox) and a binary package (app-emulation/virtualbox-bin) available in the Portage tree. The binary version is available so 64bit no-multilib users can use VirtualBox, too. The binary package contains some extensions which are not available in the source package. To get identical functionality with the source package, additionally emerge the package app-emulation/virtualbox-extpack-oracle.

The qt5 USE controls installation of the graphical user interface (GUI) which is enabled by default.

USE flags

VirtualBox

USE flags for app-emulation/virtualbox Family of powerful x86 virtualization products for enterprise and home use

alsa Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture)
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
dtrace Install dtrace Extension Pack
gtk-doc Build and install gtk-doc based developer documentation for dev-util/devhelp, IDE and offline use
headless Build without any graphic frontend
java Add support for Java
libressl Use dev-libs/libressl instead of dev-libs/openssl when applicable (see also the ssl useflag)
lvm Build VBoxVolInfo that needs devicemapper from sys-fs/lvm2.
opengl Add support for OpenGL (3D graphics)
opus Enable Opus audio codec support
pam Add support for PAM (Pluggable Authentication Modules) — DANGEROUS to arbitrarily flip
pax_kernel Apply patch needed for pax enabled kernels.
pulseaudio Add support for PulseAudio sound server
python Add optional support/bindings for the Python language
qt5 Add support for the Qt 5 application and UI framework
sdk Enable building of SDK
udev Controls installation of special USB udev rules.
vboxwebsrv Build and install the VirtualBox webservice
vnc Enable VNC (remote desktop viewer) support

VirtualBox-bin

USE flags for app-emulation/virtualbox-bin Family of powerful x86 virtualization products for enterprise and home use

additions Install Guest System Tools ISO
chm Install kchmviewer binary to enable online help (in MS CHM format)
headless Install without any graphic frontend
python Add optional support/bindings for the Python language
rdesktop-vrdp Install the rdesktop client integration
sdk Enable building of SDK
vboxwebsrv Install the VirtualBox webservice

Emerge

VirtualBox

Virtualbox requires some kernel configuration options.

Once the kernel is built and you’ve rebooted, install Virtualbox:

VirtualBox-bin

Accept PUEL license before installing:

Windows guests

Emerge the app-emulation/virtualbox-additions package on the host system to get the Guest Additions ISO image that contains all necessary Windows guest drivers:

Gentoo guests

Kernel configuration

When running Gentoo as a guest system, enable the following kernel options on the guest system (either built-in or as modules) to get proper support for the hardware emulated by VirtualBox:

Guest Additions

To install the Guest Additions, invoke the following command on the Gentoo guest system:

Make it persistently start accross reboots:

As well as the D-Bus service:

To enable the shared clipboard, display resizing, seamless mode, and drag and drop make sure the user running the X session (on the Gentoo guest system) belongs to the vboxguest group:

Changes will not take effect until the user signs out and then signs in again (re-logins).

To install other Linux distributions as guest operating systems please refer to the distribution’s documentation on how to install the drivers needed by VirtualBox or consult the official VirtualBox documentation.

Resizing doesn’t work

If the Guest Additions are installed correctly, the shared clipboard is working, etc., but the display can’t be resized, open the VM’s settings in the host-s >[1]

GPU acceleration

VirtualBox shared folders in a Gentoo guest

VirtualBox shared folders can only be mounted after the virtualbox-guest-additions service has been started. Since this happens towards the end of the bootup sequence (OpenRC), a shared folder mount in /etc/fstab will fail. Either:

  • Make the noauto mount option and add a mount/unmount pair of scripts in /etc/local.d
  • View /etc/rc.conf for information about adding extra dependencies for services.

If it is desired to let a user manually mount a shared folder, that user must be added to the vboxsf group

Advanced networking-related

According to the ebuild’s message after VirtualBox is installed sys-apps/usermode-utilities and net-misc/bridge-utils can be installed for advanced network configuration. Install them only if advanced networking is required:

Configuration

Kernel modules

Users will not be able to run and use VirtualBox if they are not a member of the vboxusers group:

Changes will not take effect until the user re-login.

Load the required driver module into the kernel. This module is made available when app-emulation/virtualbox-modules has been emerged:

It is possible to automatically load the modules each time the system boots. Create a new file under the /etc/modules-load.d directory and list, separated by newlines, the kernel modules to load:

systemd

Modules can be loaded immediately on systemd systems by running:

Enable port forwarding to guest machines

When booting LiveCDs or other live media, it can be handy to enable port forwarding from the host machine to the guest machine. None of the additional network configuration modes are necessary to for a simple port forwarding setup, so do not dig too deep into upstream docs. Port forwarding can be handy when running a web server, an SSH daemon, or any other service that runs on a specific port.

First, be sure the guest VM is shutdown, then from the command line issue:

Be sure to replace «VM name» with the proper name of the guest virtual machine. The first number ( 2222 ) will be the port on the host machine. The second number ( 22 ) will be the port on the guest machine. Adjust accordingly, then reboot the virtual machine. This can also be performed via the GUI by clicking Settings -> Network -> Advanced (drop down) -> Port Forwarding .

More details can be found in the upstream documentation.

Usage

There are many options which can influence behavior and performance of the virtual machines. If you don’t know what these options are doing, leave them to their defaults. Virtual machines may become unbootable if the wrong options are set.

Here is a list of options that are safe to use:

  • Host I/O cache can safely be enabled for all virtual storage controllers.
  • If the host system’s CPU supports hardware virtualization, enable the ‘VT-x/AMD-V’ option. It can drastically increase the performance of the virtual machines.

Troubleshooting

virtualbox fails to build

When the app-emulation/virtualbox package fails to build because the javac command cannot be found (even with a Java JDK (Java Development Kit) and a Java JRE (Java Runtime Environment) installed), it is likely the JRE has been set as the default system-vm. JRE packages do not contain javac . Make sure the correct system-vm (JDK) has been selected using the java-config command and then try rebuilding virtualbox. More information can be found in the Installing a virtual machine section of the Java User Guide.

virtualbox-modules fails to build

Some users have issues with the app-emulation/virtualbox-modules package failing to build. This can be caused by an improper kernel/profile configuration. Verify the chosen kernel and the selected profile match each other. For example, if a hardened profile is set, a hardened kernel should be used. If a default AMD64 profile is set, then the default gentoo-sources should be used. Run the eselect command to view the list of profile options:

Then use the eselect command again to display which kernel is selected:

Looking at the output of these two commands, a user can determine if the system is setup properly (the profile matches the kernel) and should have no issues installing app-emulation/virtualbox-modules. Remember: Make sure the system profile and the selected kernel match!

virtualbox-modules permission denied errors

The following «Permission denied» errors can be caused by a strict file mode creation mask (e.g. umask 077 ):

The easiest solution would be to backup .config , run make distclean and use the default umask 022 .

Host key failing to operate in the virtual machine

If the host key (typically the right Ctrl key) is failing to operate within the virtual (guest) machine, be sure any desktop environment or window manager hooks to host key have been disabled from the host machine’s desktop environment or window manager.

For example, the GNOME 3 desktop environment includes a «Show location of the [mouse] pointer» option in the Keyboard and Mouse section of the Tweak Tool (gnome-extra/gnome-tweak-tool). This option will enable a ripple effect to be displayed around the mouse when either the right or left Ctrl key is pressed. This mouse locator handle conflicts with the virtual machine’s handle on the right Ctrl key. Disabling this setting (via switching the rocker switch to Off in the Tweak Tool interface) should fix the problem by re-assigning the right Ctrl key as the handle for the host key within the virtual machine.

Performance problems

Microsoft Windows guests

  • According to the documentation, the I/O APIC feature (VM -> Settings -> System -> Motherboard -> Enable I/O APIC), which is enabled by default, ‘slightly increases the overhead of virtualization and therefore slows down the guest OS a little’. However, there have been reports that the performance impact may actually be quite severe on some host/guest system combinations (e.g. forum post). Be aware that disabling this feature might require additional steps on the guest system as described by this forum post.
  • Using a SATA controller, it is necessary to choose the right driver version from Intel’s SATA drivers. Using a wrong version will cause performance problems along with blue screen errors! Refer to this post for a list of working SATA drivers.
  • Slow performance using SATA driver? Only use the SATA controller interface for the hard disk. Remove any CDROMs from the SATA controller and place them onto a > Note
    This can also be a problem of using the wrong SATA-driver version.

Linux guests

  • When running Gentoo as a guest system make sure you start the virtualbox-guest-additions init script during bootup.
  • Having the guest VDI images on a btrfs filesystem might slow down Linux guests up to the point where the guest kernel remounts its filesystems readonly and no longer performs any I/O. This can be fixed by disabling btrfs’ copy on write for the VDI image files on the host.

Kernel driver not installed

This may occur after building a new kernel and causes an error message:

Solution: Rebuild the VirtualBox kernel modules via:

The system may need rebooted for changes to take effect.

Nonexistent host networking interface, named ‘vboxnet0’

Newly created interface will now be shown as available, but not activated (down):

An IP will need to be assigned to it:

Kernel Panic when suspending the HOST while Virtualbox is running

If you experience such behavior, try removing the vbox family of modules before suspending. If this solves the kernel panic, you can add the vbox modules to the list of permanently removed modules before suspend, these modules are loaded automatically after suspend:

источник

Читайте также:  Установка ssd imac retina

Добавить комментарий