Difference between pages "How to set up a binary package server" and "User:Renich/Funtoo on KVM/Qemu and Virtio"

(Difference between pages)
 
(expanded the instructions on how to boot the guest)
 
Line 1: Line 1:
=== Why would you want a binary package server? ===
+
{{Fancynote | This article is still in development}}
  
Even though Funtoo is a source-based distribution, it does not mean that compiling from source every single time is beneficial. For instance, if you have multiple computers in your home network, and they all need upgrades, it wouldn't be convenient to  compile the same package over and over again on each machine. Rather you could make your fastest computer compile the packages, and then just share those packages over the network or via USB drive (sneakernet).
+
Funtoo is [[KVM]]/[[wikipedia:Qemu | Qemu]] ready.  
  
=== Recommendations ===
+
In order for it to work, you need to make sure that you've enabled Virtio support on the kernel.
  
In order to make the most use of this, I recommend the following:
+
== Pre-Requisites ==
 +
* You are following the [[Funtoo_Linux_Installation | Funtoo Linux Installation]] Guide.
 +
* You figured out how to use [[Genkernel]] by reading the [[Genkernel_Quick_Start_Tutorial | Genkernel Quick Start Tutorial]].
 +
* You are using the most current vanilla-sources
  
# Set all USE flags on all machines to be the same (Lowest Common Denominator)
+
== Procedure ==
# Compile for a generic subarch. (For example, if all your machines are amd64, compile for amd64 not no specific ABIs like core2, etc.)
+
Carry on until you reach the [[Funtoo_Linux_Installation#Configuring_and_installing_the_Linux_kernel | Configuring and installing the linux kernel]] section.
  
=== Configuring the make.conf for host machine ===
+
=== Step 1: Install Genkernel ===
 +
emerge sys-kernel/genkernel
  
We first need to enable automatic binary packaging on the host. This means that when portage compiles the package,
+
=== Step 2: Install the vanilla sources ===
it will put it into a <tt>.tbz2</tt> file right after. To do this we will add <tt>buildpkg</tt> to the <tt>FEATURES var</tt> in <tt>/etc/make.conf</tt>.
+
emerge sys-kernel/vanilla-sources
  
My <tt>make.conf</tt> looks like this::
+
=== Step 3: Start configuring and building the kernel ===
 +
genkernel --menuconfig all
  
<pre>
+
=== Step 4: Search and enable the essential Virtio drivers ===
CFLAGS="-mtune=generic -O2 -pipe"
+
To be able to search for all Virtio options, just type ''/'' on the ''TUI'' (Terminal User Interface) and, then, type 'virtio'. Please, consult: [http://www.linux-kvm.org/page/Virtio KVM's website] in order to get a list of options available in the Kernel's config.
CXXFLAGS="${CFLAGS}"
+
USE="mmx sse sse2"
+
MAKEOPTS="-j9"
+
FEATURES="buildpkg userfetch"
+
EMERGE_DEFAULT_OPTS="--quiet-build=y"
+
VIDEO_CARDS="nvidia nouveau intel"
+
INPUT_DEVICES="evdev synaptics"
+
LINGUAS="en en_US"
+
</pre>
+
  
Now that <tt>FEATURES="buildpkg"</tt> is set, from now on, every time you build a new package, it will automatically package it and you can find the <tt>.tbz2</tt> file in <tt>/usr/portage/packages</tt> by default. You can change the destination by using the <tt>PKGDIR</tt> setting in <tt>make.conf</tt>.
+
{{Note | The console will let you know what is available. Pay special attention to the location section.}}
  
=== What will you need? ===
+
=== Step 5: Continue with [[Funtoo_Linux_Installation#Installing_a_Bootloader | Funtoo Linux Installation]] Guide ===
  
Besides the above advice, you will need one of the protocols that can be used for sharing (Like FTP, HTTP, or ssh).I recommend HTTP, so we will be using lighttpd server since it's small, quick, and efficient for these basic tasks.
+
== Testing ==
 +
=== Boot the Guest ===
 +
You should be able to boot the guest without problems. If you're using virt-manager, then just hit "play" on the Guest. If you're a commandline dude, please, issue the following command:
  
=== Setting up the host machine ===
+
qemu-kvm -boot c -drive file=/var/lib/libvirt/images/funtoo.img,if=virtio -m 512
  
Install lighttpd
+
== Troubleshooting ==
  
<console>
+
=== Determining root device fails ===
# ##i##emerge lighttpd
+
For some reason, on kernel 3.4.5, it fails to load the modules automatically. You can workaround it by adding:
</console>
+
  
After you install lighttpd, we will set a symlink in the htdocs folder to point to your packages folder (By default it's <tt>/usr/portage/packages</tt>):
+
doload=virtio_pci,virtio_blk
  
<console>
+
to the kernel line; at the grub prompt; at boot time. It should look something like this:
# ##i##cd /var/www/localhost/htdocs
+
# ##i##mkdir funtoo && cd funtoo
+
# ##i##ln -s /usr/portage portage
+
# ##i##ln -s /usr/portage/distfiles distfiles
+
# ##i##ln -s /usr/portage/packages packages
+
</console>
+
  
Now that that's set, the link to your packages will be <tt>http://ip-of-computer/funtoo/packages</tt>.
+
<pre>
 +
set timeout=3
 +
set default=0
  
If the lighttpd server were on now and you navigated to the above address, you would get a 404 error because lighttpd by default doesn't show the directory listing. Add the following line to your /etc/lighttpd/lighttpd.conf so that if you request a page that doesn't contain an index page, it will just show the directory contents:
+
menuentry "Funtoo Linux genkernel - kernel-genkernel-x86_64-3.4.5" {
 +
  insmod part_gpt
 +
  insmod ext2
 +
  set root=(hd0,2)
 +
  search --no-floppy --fs-uuid --set 22b809f0-86be-422a-8bdd-6f4362da83ed
 +
  linux /kernel-genkernel-x86_64-3.4.5 real_root=/dev/vda4 doload=virtio_pci,virtio_blk
 +
  initrd /initramfs-genkernel-x86_64-3.4.5
 +
  set gfxpayload=keep
 +
}
 +
</pre>
  
<console>
+
Once you boot, a permanent workaround should look like this:
# Activate directory listings globally
+
<pre>
dir-listing.activate = "enable"
+
mount /dev/vda2 /boot
</console>
+
  
Add the service to your start up process and start it up:
+
cat /boot/grub/grub.cfg
 +
set timeout=3
 +
set default=0
  
<console>
+
menuentry "Funtoo Linux genkernel - kernel-genkernel-x86_64-3.4.5" {
# ##i##rc-config add lighttpd default
+
  insmod part_gpt
# ##i##rc
+
  insmod ext2
</console>
+
  insmod virtio_pci
 
+
  insmod virtio_blk
Your host machine is now ready to serve out binaries.
+
  insmod virtio_net
 
+
  set root=(hd0,2)
=== Setting up the client machine ===
+
  search --no-floppy --fs-uuid --set 22b809f0-86be-422a-8bdd-6f4362da83ed
 
+
  linux /kernel-genkernel-x86_64-3.4.5 real_root=/dev/vda4 doload=virtio_pci,virtio_blk
Basically the client machine will be receiving packages from a server that might not necessarily have the exact same USE flags that the client machine has. Even thought we set all the USE flags on all machines to the Lowest Common Denominator, sometimes things deviate. In order to solve this problem, we will make portage not respect USE flags. Meaning that if there are different USE flags on machines, it will still install those packages.
+
  initrd /initramfs-genkernel-x86_64-3.4.5
 
+
  set gfxpayload=keep
To do this we need to add the <tt>--binpkg-respect-use=n</tt> to the end of emerge.
+
}
 
+
Before we use the above option, we also need to tell emerge to not only search for ebuilds, but also to search for packages as well. In order for it to search for packages, emerge will need to know where to look (the host) and set an option on portage to actually let it know to look for binaries.
+
 
+
We do this by adding the <tt>--getbinpkg</tt> option to the end of emerge, and setting the <tt>PACKAGE_BINHOST</tt> variable in <tt>/etc/make.conf</tt>.
+
 
+
This is how my client's <tt>/etc/make.conf</tt> looks:
+
 
+
<pre>
+
CFLAGS="-mtune=generic -O2 -pipe"
+
CXXFLAGS="${CFLAGS}"
+
USE="mmx sse sse2"
+
MAKEOPTS="-j5"
+
FEATURES="buildpkg userfetch getbinpkg"
+
EMERGE_DEFAULT_OPTS="--quiet-build=y --binpkg-respect-use=n"
+
VIDEO_CARDS="nvidia intel"
+
INPUT_DEVICES="evdev synaptics"
+
LINGUAS="en en_US"
+
PORTAGE_BINHOST="http://ip-address-of-build-server/gentoo/packages"
+
 
</pre>
 
</pre>
  
After you set the package host (via <tt>PORTAGE_BINHOST</tt>), set the <tt>getbinpkg</tt> option in <tt>FEATURES</tt>, and add <tt>--binpkg-respect-use=n</tt> to <tt>EMERGE_DEFAULT_OPTS</tt>, you are then set. Just do a emerge <tt>--sync</tt>, and <tt>emerge -uDav world</tt> or whatever you want. You should now see all your
+
== Reference ==
packages being pulled from the host server.
+
* [[wikipedia: KVM]]
 
+
* [[wikipedia: Qemu]]
Normally you could just do a
+
* http://www.linux-kvm.org/page/Virtio
<console>
+
# ##i##emerge <package> --binpkg-respect-use=n
+
</console>
+
 
+
But you will have to do that each time you want to install a binary with different use flags, so in order to automate this, we add it to the <tt>EMERGE_DEFAULT_OPTS</tt>.
+
 
+
[[Category:HOWTO]]
+

Revision as of 22:26, August 1, 2012

Funtoo is KVM/ Qemu ready.

In order for it to work, you need to make sure that you've enabled Virtio support on the kernel.

Pre-Requisites

Procedure

Carry on until you reach the Configuring and installing the linux kernel section.

Step 1: Install Genkernel

emerge sys-kernel/genkernel

Step 2: Install the vanilla sources

emerge sys-kernel/vanilla-sources

Step 3: Start configuring and building the kernel

genkernel --menuconfig all

Step 4: Search and enable the essential Virtio drivers

To be able to search for all Virtio options, just type / on the TUI (Terminal User Interface) and, then, type 'virtio'. Please, consult: KVM's website in order to get a list of options available in the Kernel's config.

Note

The console will let you know what is available. Pay special attention to the location section.

Step 5: Continue with Funtoo Linux Installation Guide

Testing

Boot the Guest

You should be able to boot the guest without problems. If you're using virt-manager, then just hit "play" on the Guest. If you're a commandline dude, please, issue the following command:

qemu-kvm -boot c -drive file=/var/lib/libvirt/images/funtoo.img,if=virtio -m 512

Troubleshooting

Determining root device fails

For some reason, on kernel 3.4.5, it fails to load the modules automatically. You can workaround it by adding:

doload=virtio_pci,virtio_blk 

to the kernel line; at the grub prompt; at boot time. It should look something like this:

set timeout=3
set default=0

menuentry "Funtoo Linux genkernel - kernel-genkernel-x86_64-3.4.5" {
  insmod part_gpt
  insmod ext2
  set root=(hd0,2)
  search --no-floppy --fs-uuid --set 22b809f0-86be-422a-8bdd-6f4362da83ed
  linux /kernel-genkernel-x86_64-3.4.5 real_root=/dev/vda4 doload=virtio_pci,virtio_blk
  initrd /initramfs-genkernel-x86_64-3.4.5
  set gfxpayload=keep
}

Once you boot, a permanent workaround should look like this:

mount /dev/vda2 /boot

cat /boot/grub/grub.cfg
set timeout=3
set default=0

menuentry "Funtoo Linux genkernel - kernel-genkernel-x86_64-3.4.5" {
  insmod part_gpt
  insmod ext2
  insmod virtio_pci
  insmod virtio_blk
  insmod virtio_net
  set root=(hd0,2)
  search --no-floppy --fs-uuid --set 22b809f0-86be-422a-8bdd-6f4362da83ed
  linux /kernel-genkernel-x86_64-3.4.5 real_root=/dev/vda4 doload=virtio_pci,virtio_blk
  initrd /initramfs-genkernel-x86_64-3.4.5
  set gfxpayload=keep
}

Reference