Difference between pages "Extlinux" and "User:Renich/Funtoo on KVM/Qemu and Virtio"

From Funtoo
(Difference between pages)
Jump to: navigation, search
(GPT)
 
(expanded the instructions on how to boot the guest)
 
Line 1: Line 1:
= What is ExtLinux? =
+
{{Fancynote | This article is still in development}}
  
ExtLinux is a pretty simple and modern systemloader, bundled with the syslinux tools, installation is really simple for it and fast, and thanks to our CoreTeam member Slashbeast the configuration runs automated in an awesome way.
+
Funtoo is [[KVM]]/[[wikipedia:Qemu | Qemu]] ready.  
  
= Installing ExtLinux for funtoo =
+
In order for it to work, you need to make sure that you've enabled Virtio support on the kernel.
  
Installing ExtLinux for funtoo is known to work and supported too. If you like to try it just emerge syslinux
+
== 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
  
<console>
+
== Procedure ==
# ##i##emerge syslinux
+
Carry on until you reach the [[Funtoo_Linux_Installation#Configuring_and_installing_the_Linux_kernel | Configuring and installing the linux kernel]] section.
</console>
+
  
with that you have the complete syslinux tools installed. Another helpful tool you should merge with syslinux is slashbeast's lazykernel tool, so let us merge it too:
+
=== Step 1: Install Genkernel ===
 +
emerge sys-kernel/genkernel
  
<console>
+
=== Step 2: Install the vanilla sources ===
# ##i##emerge lazykernel
+
emerge sys-kernel/vanilla-sources
</console>
+
  
== Installing extlinux ==
+
=== Step 3: Start configuring and building the kernel ===
 +
genkernel --menuconfig all
  
to install extlinux just follow these steps:
+
=== 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: [http://www.linux-kvm.org/page/Virtio KVM's website] in order to get a list of options available in the Kernel's config.
  
<console>
+
{{Note | The console will let you know what is available. Pay special attention to the location section.}}
# ##i##install -d /boot/extlinux
+
# ##i##extlinux --install /boot/extlinux
+
# ##i##cd /boot
+
# ##i##ln -s . boot
+
</console>
+
  
the next steps are different depending if you use an MBR or GPT setup and the HDD you installed on and want to boot from. Let us now for general take /dev/sda as your boot device.
+
=== Step 5: Continue with [[Funtoo_Linux_Installation#Installing_a_Bootloader | Funtoo Linux Installation]] Guide ===
  
=== MBR ===
+
== 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:
  
If you set up your disk with MBR partition scheme just do the next steps:
+
qemu-kvm -boot c -drive file=/var/lib/libvirt/images/funtoo.img,if=virtio -m 512
  
<console>
+
== Troubleshooting ==
# ##i##dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/mbr.bin of=/dev/sda
+
# ##i##cp /usr/share/syslinux/menu.c32 /boot/extlinux/
+
# ##i##cp /usr/share/syslinux/libutil.c32 /boot/extlinux/
+
# ##i##touch /boot/extlinux/extlinux.conf
+
</console>
+
  
=== GPT ===
+
=== 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:
  
<console>
+
doload=virtio_pci,virtio_blk
# ##i##sgdisk /dev/sda --attributes=1:set:2
+
# ##i##sgdisk /dev/sda --attributes=1:show
+
1:2:1 (legacy BIOS bootable)
+
# ##i##dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sda
+
# ##i##cp /usr/share/syslinux/menu.c32 /boot/extlinux/
+
# ##i##cp /usr/share/syslinux/libutil.c32 /boot/extlinux/
+
# ##i##touch /boot/extlinux/extlinux.conf
+
</console>
+
  
== Setting up the Kernel ==
+
to the kernel line; at the grub prompt; at boot time. It should look something like this:
 
+
Now if you followed our advice to install lazykernel we have a pretty nice way to solve all the setup with a bit of prework and finish it then. If not you should go to the manual part. :)
+
 
+
=== lazykernel way ===
+
 
+
As you setup lazykernel, we now need to edit /etc/lazykernel.conf
+
 
+
make it to look like somethink like that:
+
  
 
<pre>
 
<pre>
# After configuring, hash or remove line below.
+
set timeout=3
#CONFIGUREFIRST
+
set default=0
  
# Number of the kernels to keep so `lazykernel clean` will not propose to remove them. Default: 3
+
menuentry "Funtoo Linux genkernel - kernel-genkernel-x86_64-3.4.5" {
keep_kernels=5
+
  insmod part_gpt
 
+
  insmod ext2
# Sort kernels by 'version' (biggest version first) or by 'mtime' (latest images first). Default: mtime
+
  set root=(hd0,2)
# Sorting by version may fail and 3.3.0-rc2 will be marked as newer than 3.3.0.
+
  search --no-floppy --fs-uuid --set 22b809f0-86be-422a-8bdd-6f4362da83ed
#sort_by='version'
+
  linux /kernel-genkernel-x86_64-3.4.5 real_root=/dev/vda4 doload=virtio_pci,virtio_blk
sort_by=mtime
+
  initrd /initramfs-genkernel-x86_64-3.4.5
 
+
  set gfxpayload=keep
# The name for menu entry.
+
}
menu_entry_name="Funtoo Linux"
+
 
+
# Specify what initramfs image to use, if any. (Optional)
+
initramfs='initramfs.cpio.gz'
+
 
+
# Append kernel params, usualy you use it to specify rootfs device, but you can use it to pass switches to initramfs as well. (Optional)
+
#kernel_params='root=/dev/sda2'
+
#kernel_params="rootfstype=ext4 luks enc_root=/dev/sda2 lvm root=/dev/mapper/vg-rootfs uswsusp resume=/dev/mapper/vg-swap"
+
kernel_params="rootfstype=ext4 luks enc_root=/dev/sdb3 lvm root=/dev/mapper/vg-root uswsusp resume=/dev/mapper/vg-swap"
+
 
</pre>
 
</pre>
  
please make sure to comment out or delete the second line of the config file, else it will spit out an error for you... :)
+
Once you boot, a permanent workaround should look like this:
 
+
Now let us setup our kernel with lazykernel if you have a manual kernel just run:
+
 
+
<console>
+
# ##i##cd <kernel build dir>
+
# ##i##lazykernel auto
+
</console>
+
 
+
that will generate the modules for you, copy your kernel form /usr/src/linux over to /boot and generate the /boot/extlinux/extlinux.conf for you. The manual kernel will be the only supported one by lazykernel.
+
 
+
That's all you are ready to boot. :)
+
 
+
=== manual extlinux.conf ===
+
 
+
For other kernels, like those created by genkernel or by the binary USE-flag you need to edit your config by yourself. Just open /boot/extlinux/extlinux.conf in your favorite editor and setup something like the following:
+
 
+
 
<pre>
 
<pre>
TIMEOUT 30
+
mount /dev/vda2 /boot
UI menu.c32
+
  
MENU TITLE Boot Menu
+
cat /boot/grub/grub.cfg
MENU COLOR title        1;37;40
+
set timeout=3
MENU COLOR border      30;40
+
set default=0
MENU COLOR unsel        37;40
+
  
LABEL funtoo1
+
menuentry "Funtoo Linux genkernel - kernel-genkernel-x86_64-3.4.5" {
        MENU LABEL Funtoo Linux KERNEL-VERSION
+
  insmod part_gpt
        LINUX /<kernel>
+
  insmod ext2
        INITRD /<initramfs>
+
  insmod virtio_pci
        APPEND rootfstype=ext4 luks enc_root=/dev/sdb3 lvm root=/dev/mapper/vg-root uswsusp resume=/dev/mapper/vg-swap
+
  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
 +
}
 
</pre>
 
</pre>
  
That's all again you are ready for boot. You can also define several LABELs in that list to have multiple kernels been booted... :)
+
== Reference ==
 
+
* [[wikipedia: KVM]]
[[Category:HOWTO]]
+
* [[wikipedia: Qemu]]
 +
* http://www.linux-kvm.org/page/Virtio

Revision as of 22:26, 1 August 2012

Note: This article is still in development

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