Difference between pages "Create a boot option for easy nvidia or nouveau display driver switching" and "Genkernel Quick Start Tutorial"

From Funtoo
(Difference between pages)
Jump to: navigation, search
 
 
Line 1: Line 1:
This howto describes how to use nvidia and nouveau drivers on the same computer and kernel
+
Genkernel is a tool which help you to build a Linux kernel and deploy it along with a ramdisk image which contains all of the necessary modules to make the kernel being able to mount the different partitions of your harddrives in the VFS at the system startup.
<br>
+
{{Fancynote|You must know how to install {{Package|x11-drivers/nvidia-drivers}} and {{package|x11-drivers/nouveau}} (references at the end of the page). First, you need to configure your kernel and install nvidia drivers and nouveau. We assume that this stage is successfully passed.}}
+
  
== boot-update ==
+
== Concepts ==
Next, the most important change:
+
{{File
+
|/etc/boot.conf|<pre>
+
boot {
+
generate grub
+
default "Funtoo Linux [nvidia]"
+
# or
+
# default "Funtoo Linux [nouveau]"
+
timeout 3
+
}
+
  
color {
+
TBC
normal cyan/blue
+
highlight blue/cyan
+
}
+
  
display {
+
== Recompiling the Gentoo kernel sources from a SystemRescue CD chroot ==
#gfxmode 1280x800
+
#font unifont.pf2
+
}
+
  
"Funtoo Linux [nvidia]" {
+
A second case that many Funtoo users will face to is to compile their own kernel when installing a brand new Funtoo instance from a stage 3 archive (the most common scenario is to boot the machine with SystemRescue CD).
kernel vmlinuz[-v]
+
params += ro console=tty1 quiet <other standard boot options>
+
params += nouveau.blacklist=true vga=791 # nouveau.blacklist=true is important
+
# or
+
# params += nouveau.blacklist=true video=uvesafb:1440x900-8,mtrr:2
+
}
+
  
"Funtoo Linux [nouveau]" {
+
{{Fancynote| If you want to use the System rescue CD sources provided by Funtoo {{Package|sys-kernel/sysrescue-std-sources}}, the philosophy remains exactly the same.}}
kernel vmlinuz[-v]
+
params += ro console=tty1 quiet <other standard boot options>
+
params += nvidia.blacklist=true # nvidia.blacklist=true is important
+
}  
+
</pre>}}
+
  
After boot-update with the new settings, you should have something like:
+
== First step emerging the required packages ==
 +
 
 +
The first step is to emerge:
 +
 
 +
# The Gentoo kernel sources: {{Package|sys-kernel/gentoo-sources}}
 +
# Genkernel itself: {{Package|sys-kernel/genkernel}}
 +
 
 +
This is achieved by running the following:
 
<console>
 
<console>
###i## grep menuentry /boot/grub/grub.cfg | wc -l
+
###i## emerge sys-kernel/gentoo-sources sys-kernel/genkernel
2
+
###i## grep menuentry /boot/grub/grub.cfg
+
menuentry "Funtoo Linux [nouveau] - vmlinuz-2.6.32.71_p14-rh" {
+
menuentry "Funtoo Linux [nvidia] - vmlinuz-2.6.32.71_p14-rh" {
+
 
</console>
 
</console>
  
== xcfgmaker deamon ==
+
Once the Gentoo kernel sources are deployed, you should find a directory named '''linux-''version''-gentoo''' (e.g. linux-2.6.39-gentoo) under ''<code>/usr/src</code>''. Update the ''<code>linux</code>'' symlink to point to this directory:
 
+
 
<console>
 
<console>
###i## mkdir /etc/X11/video/;
+
###i## cd /usr/src
###i## cd /etc/X11/video/;
+
###i## rm linux
###i## nano 10-monitor.conf.nouveau # make default config for nouveau. or copy existing config…
+
###i## ln -s linux-2.6.39-gentoo linux
###i## nano 10-monitor.conf.nvidia # also for nvidia
+
 
</console>
 
</console>
  
Then create a new daemon:
+
== Second step: Grabbing and tweaking a configuration file ==
{{File
+
|/etc/init.d/xcfgmaker |<pre>
+
#!/sbin/runscript
+
  
# by http://wiki.sabayon.org/index.php?title=HOWTO:_Create_a_boot_option_for_easy_dual_to_single_display_switching
+
How to start your kernel configuration? Simply by using the same configuration template the running System Rescue CD kernel had been built with! Before chrooting in your Funtoo instance, you did something like:
# To be placed in /etc/init.d/
+
# Run Command: rc-update add xcfgmaker boot
+
  
depend()
+
<console>
{
+
###i## mount -o bind /proc /mnt/gentoo/proc
  need localmount
+
</console>
  before xdm-setup
+
Or:
  before xdm
+
<console>
  before alsasound
+
###i## mount -t proc none /mnt/gentoo/proc
}
+
</console>
  
start()
+
In your chroot environment (or from a System Rescue CD virtual terminal) if you look what ''<code>/proc</code>'' contains you will notice a file named ''<code>config.gz</code>'':
{
+
  
  cmdline_display_mode_exist=$(cat /proc/cmdline | grep -e "nouveau.blacklist=" -e "nvidia.blacklist=")
+
<console>
  display_mode_nvidia_exist=$(ls /etc/X11/video/ | grep "10-monitor.conf.nvidia")
+
###i## ls /proc
  display_mode_nouveau_exist=$(ls /etc/X11/video/ | grep "10-monitor.conf.nouveau")
+
  cmdline_display_mode=$(cat /proc/cmdline | awk -Fnvidia.blacklist= '{print $2}' | awk '{print $1}')
+
  if [ -n "$cmdline_display_mode_exist" ]; then
+
      if [ -n "$display_mode_nvidia_exist" ] && [ -n "$display_mode_nouveau_exist" ]; then
+
            #Choose the xorg file to be copied over
+
            if [ "$cmdline_display_mode" == "true" ]; then
+
              ebegin "Configuring X display with nouveau"
+
              cp /etc/X11/video/10-monitor.conf.nouveau /etc/X11/xorg.conf.d/10-monitor.conf
+
              eselect opengl set xorg-x11 >/dev/null 2>&1;
+
            else
+
              ebegin "Configuring X display with nvidia"
+
              cp /etc/X11/video/10-monitor.conf.nvidia /etc/X11/xorg.conf.d/10-monitor.conf
+
              eselect opengl set nvidia >/dev/null 2>&1;
+
            fi
+
        sleep 5
+
        eend 0
+
      else
+
        ebegin "Xorg file missing. Exitting"
+
        eend 0
+
      fi
+
  fi
+
  
}
+
...
 +
dr-xr-xr-x  7 root      root                    0 May 23 03:13 952
 +
dr-xr-xr-x  7 root      root                    0 May 23 03:13 953
 +
dr-xr-xr-x  7 root      root                    0 May 23 18:42 9834
 +
...
 +
-r--r--r--  1 root      root                16024 May 23 22:27 config.gz
 +
-r--r--r--  1 root      root                    0 May 23 22:27 consoles
 +
-r--r--r--  1 root      root                    0 May 23 22:27 cpuinfo
 +
...
 +
</console>
  
</pre>}}
+
''<code>config.gz</code>'' holds the running kernel (System Rescue CD) configuration, just copy the unziped content into the Gentoo sources directory:
 +
<console>
 +
###i## cd /usr/src/linux
 +
###i## zcat /proc/config.gz > .config
 +
</console>
  
Do not forget:
+
Next, run ''<code>make oldconfig</code>'' to set all newly added options:
 
<console>
 
<console>
###i## chmod +x /etc/init.d/xcfgmaker
+
###i## make oldconfig
###i## rc-update add xcfgmaker boot
+
 
</console>
 
</console>
  
== Additional Resources ==
+
Next, tweak the kernel configuration in the way you prefer (manually edition of the .config file, make nconfig, make menuconfig....) if you wish. You are not ready yet! A final step is required: '''you ''must'' either set CONFIG_INITRAMFS_SOURCE to a blank value (CONFIG_INITRAMFS_SOURCE="") either delete the statement in the .config file'''. Forgotting to do that will make Genkernel abort the compilation process with a message like:
 +
<console>
 +
/usr/src/linux-2.6.39-gentoo/scripts/gen_initramfs_list.sh: Cannot open '/var/tmp/genkernel/initramfs-2.6.32.14-std155-i386.cpio.gz'
 +
make[1]: *** [usr/initramfs_data.cpio.lzma] Error 1
 +
</console>
 +
 
 +
== Third step: Building and installing the kernel ==
 +
 
 +
This is simply achieved by:
 +
<console>
 +
###i## genkernel --no-mrproper all
 +
</console>
  
*[http://en.gentoo-wiki.com/wiki/Nvidia Nvidia how-to on gentoo-wiki]
+
The same remarks written in the [[Genkernel_Quick_Start_Tutorial#Third_step:_Building_and_installing_the_kernel|third paragraph]] of the first use case are still valid here.
*[http://en.gentoo-wiki.com/wiki/Nouveau Nouveau how-to on gentoo-wiki]
+
*[http://sudormrf.wordpress.com/2011/02/14/create-a-boot-option-for-easy-nvidia-or-nouveau-display-driver-switching The same text on my blog(in Russian)]
+
  
[[Category:HOWTO]]
+
[[Category:Kernel]]

Latest revision as of 21:41, 28 January 2014

Genkernel is a tool which help you to build a Linux kernel and deploy it along with a ramdisk image which contains all of the necessary modules to make the kernel being able to mount the different partitions of your harddrives in the VFS at the system startup.

Contents

[edit] Concepts

TBC

[edit] Recompiling the Gentoo kernel sources from a SystemRescue CD chroot

A second case that many Funtoo users will face to is to compile their own kernel when installing a brand new Funtoo instance from a stage 3 archive (the most common scenario is to boot the machine with SystemRescue CD).

Note: If you want to use the System rescue CD sources provided by Funtoo sys-kernel/sysrescue-std-sources, the philosophy remains exactly the same.

[edit] First step emerging the required packages

The first step is to emerge:

  1. The Gentoo kernel sources: sys-kernel/gentoo-sources
  2. Genkernel itself: sys-kernel/genkernel

This is achieved by running the following:

# emerge sys-kernel/gentoo-sources sys-kernel/genkernel

Once the Gentoo kernel sources are deployed, you should find a directory named linux-version-gentoo (e.g. linux-2.6.39-gentoo) under /usr/src. Update the linux symlink to point to this directory:

# cd /usr/src
# rm linux
# ln -s linux-2.6.39-gentoo linux

[edit] Second step: Grabbing and tweaking a configuration file

How to start your kernel configuration? Simply by using the same configuration template the running System Rescue CD kernel had been built with! Before chrooting in your Funtoo instance, you did something like:

# mount -o bind /proc /mnt/gentoo/proc

Or:

# mount -t proc none /mnt/gentoo/proc

In your chroot environment (or from a System Rescue CD virtual terminal) if you look what /proc contains you will notice a file named config.gz:

# ls /proc

...
dr-xr-xr-x  7 root       root                     0 May 23 03:13 952
dr-xr-xr-x  7 root       root                     0 May 23 03:13 953
dr-xr-xr-x  7 root       root                     0 May 23 18:42 9834
...
-r--r--r--  1 root       root                 16024 May 23 22:27 config.gz
-r--r--r--  1 root       root                     0 May 23 22:27 consoles
-r--r--r--  1 root       root                     0 May 23 22:27 cpuinfo
...

config.gz holds the running kernel (System Rescue CD) configuration, just copy the unziped content into the Gentoo sources directory:

# cd /usr/src/linux
# zcat /proc/config.gz > .config

Next, run make oldconfig to set all newly added options:

# make oldconfig

Next, tweak the kernel configuration in the way you prefer (manually edition of the .config file, make nconfig, make menuconfig....) if you wish. You are not ready yet! A final step is required: you must either set CONFIG_INITRAMFS_SOURCE to a blank value (CONFIG_INITRAMFS_SOURCE="") either delete the statement in the .config file. Forgotting to do that will make Genkernel abort the compilation process with a message like:

/usr/src/linux-2.6.39-gentoo/scripts/gen_initramfs_list.sh: Cannot open '/var/tmp/genkernel/initramfs-2.6.32.14-std155-i386.cpio.gz'
make[1]: *** [usr/initramfs_data.cpio.lzma] Error 1

[edit] Third step: Building and installing the kernel

This is simply achieved by:

# genkernel --no-mrproper all

The same remarks written in the third paragraph of the first use case are still valid here.