Criando Kernel RT Ubuntu 14.04: mudanças entre as edições

De LCAD
Ir para navegação Ir para pesquisar
Sem resumo de edição
Sem resumo de edição
 
(14 revisões intermediárias por 2 usuários não estão sendo mostradas)
Linha 5: Linha 5:
This guide is a condensed reference on how to patch, compile and install the 4.1.5. kernel.
This guide is a condensed reference on how to patch, compile and install the 4.1.5. kernel.


Download kernel and patch:
Download kernel, headers and patch:
  https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.5.tar.xz
  https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.5.tar.xz
  https://www.kernel.org/pub/linux/kernel/projects/rt/4.1/patch-4.1.5-rt5.patch.xz
http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.1.5-unstable/linux-headers-4.1.5-040105_4.1.5-040105.201508101730_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.1.5-unstable/linux-headers-4.1.5-040105-generic_4.1.5-040105.201508101730_amd64.deb
  https://www.kernel.org/pub/linux/kernel/projects/rt/4.1/older/patch-4.1.5-rt5.patch.gz


use sudo mode:
use sudo mode:
  sudo su
  sudo su
cd /home/car01/Downloads
Extract kernel archive and patch file:
Extract kernel archive and patch file:
  tar -Jxf linux-4.1.5.tar.xz
  tar -Jxf linux-4.1.5.tar.xz
  tar -Jxf patch-4.1.5-rt5.patch.xz
  gzip -d patch-4.1.5-rt5.patch.gz
Put the patch file one directory level above the kernel source.
Put the patch file one directory level above the kernel source.
  cp linux-4.1.5 /usr/src
  mv linux-4.1.5 /usr/src
  cp patch-4.1.5-rt5.patch /usr/src
  cp patch-4.1.5-rt5.patch /usr/src


Linha 24: Linha 27:


  less ../patch-4.1.5-rt5.patch | patch -p1
  less ../patch-4.1.5-rt5.patch | patch -p1


Get the latest configuration of new kernel
Get the latest configuration of new kernel
  make oldconfig
  make oldconfig


The make will make some questions, answer with the default option, '''EXCEPT''' the options about real time and debug mode. When asked for:
The make will ask some questions, answer with the default option, '''EXCEPT''' the options about real time and debug mode. When asked for:


* "Preemption Model"
* "Preemption Model"
Linha 40: Linha 42:
  make menuconfig
  make menuconfig


configure the IP_TABLES NAT support:
To configure the IP_TABLES NAT support:
<pre>
On the Kernel Configuration go to:
On the Kernel Configuration go to:
  Networking support > Networking Options > Network packet filtering framework (Netfilter) > IP: Netfilter Configuration
  Networking support > Networking Options > Network packet filtering framework (Netfilter) > IP: Netfilter Configuration
  Find the option ''iptables NAT support'' and mark with <M> and the options who will apear too.
  Find the options listed below and mark with <M>
<M> IP tables support (required for filtering/masq/NAT)
Other options will apear:
<M> MASQUERADE target support
<M> NETMAP tarrget support
<M> REDIRECT target support
save and exit
</pre>
Build and install the kernel:
 
make -j 24
make -j 24 modules
make -j 24 INSTALL_MOD_STRIP=1 modules_install
make install
cd ..
 
Update the bootloader (probably grub) if not done automatically.
 
Install the new headers:
sudo dpkg -i /home/car01/Downloads/linux-headers-4.1.5*.deb
 
restart the computer.
 
 
Check if the iptables_nat is working:
 
iptables -t nat -L
<pre>
If shows the following error:
  iptables v1.4.21: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
  Perhaps iptables or your kernel needs to be upgraded.
Back to the step of menu configuration tool:make menuconfig and check the iptables options. If is ok, try the solution:
    cd /usr/src/linux-4.1.5
    sudo make menuconfig
  Go to menu Networking Support > Networking Options > Network packet filtering framework (Netfilter)
  and press spacebar to mark with star
  Entry in this menu and go to Core Netfilter Configuration. Fill all options with M EXCEPT the options
  below that should be filled with star :
"Netfilter connection tracking support",
"Connection tracking flow accounting",
"Connection mark tracking support",
"Connection tracking security mark support",
"Connection tracking events" and
"Netfilter Xtables support (required for ip_tables)"
  And the option "Enable obsolete /proc/net/ipt_recent" doesn't should be filled.
  Save changes and exit.
  BACK TO THE '''Build and install the kernel''' STEP in this tutorial.
</pre>
 
If you are using RAID and partition isn't recognized, install the package and reboot:
sudo apt-get install dmraid
 
 
=== Install Nvidia Graphics Driver (352.41) for the Realtime Kernel ===
 
<pre>After installing the realtime kernel as described above, Nvidia graphics card owners will probably want
to install the official graphics driver from Nvidia (if you're using Ardour you're going to need this driver
to get smooth GUI performance). Unfortunately, the installer will just complain about the realtime kernel and
quit. With some tweaks it is possible to install it nevertheless. This article describes the installation of the
Nvidia driver version 352.41. For different versions you will need a different patch file or perform the patch manually.
 
Warning: I found that the driver sometimes locks itself up on my system, leading to a frozen image.
If 100% stability is a requirement for you, you should not install it. During the installation you will
need to stop your desktop session so consider printing this guide or open it up on a different device.
</pre>
 
Go ahead if you're ready:
 
Remove the old nvidia instalation
sudo apt-get remove nvidia*
sudo apt-get autoremove
 
Update and download a few tools that we will need:
sudo apt-get update
sudo apt-get install dkms build-essential
 
Now its time to blacklist the nouveau driver.
sudo gedit /etc/modprobe.d/blacklist-nouveau.conf
 
And add the following lines:
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
 
Disable the Kernel nouveau by typing the following commands:
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u
 
Download the driver package from your local nvidia page:
http://www.nvidia.com/Download/index.aspx
Make a patch file as follows:
[[nvidia-352.41-rt.patch]]
 
Open a console and change directory to the folder where you downloaded the driver package to.
Make the driver package executable:
chmod +x NVIDIA-Linux-x86_64-352.41.run
 
Extract the driver source:
./NVIDIA-Linux-x86_64-352.41.run --extract-only
 
Apply the patch file:
less nvidia-352.41-rt.patch | patch NVIDIA-Linux-x86_64-352.41/kernel/nv-linux.h
 
Press Ctrl+Alt+F1 to open up a terminal session and login as root to stop your X Sever. If you're using XFCE (UbuntuStudio) this is LightDM. Beware that this kills all programs running in the GUI session, including the browser you might be reading this article in:
/etc/init.d/lightdm stop
 
Set this environment variable to disable the a check for the realtime kernel patch in the installer:
export IGNORE_PREEMPT_RT_PRESENCE=1
 
Change directory to the folder where the nvidia driver source was extracted to.
Run the installer just like you normally would:
./nvidia-installer
Restart your desktop manager:
/etc/init.d/lightdm start
 
Check if the driver was install correctly,  deve mostrar as informações da placa de video
$ nvidia-settings
 
Your system should now use the freshly installed driver!
 
<pre>If you want to adapt this process for a different driver version, you will need to take a look what the patch actually
does and make those changes to the nv-linux.h file manually. If you do so, it would be very nice of you to create a new patch
file and post it here in the comments. Of course, there's no guarantee that this will work for newer driver versions.
</pre>
 
Para instalar o cuda siga as instruções do Getting_Started: http://developer.download.nvidia.com/compute/cuda/6_5/rel/docs/CUDA_Getting_Started_Linux.pdf
 
Use o instador .run
 
Na instalação vai aparecer algumas perguntas, Siga essas respostas.
 
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 340.29? ((y)es/(n)o/(q)uit): n
Install the CUDA 6.5 Toolkit? ((y)es/(n)o/(q)uit): y
Enter Toolkit Location [ default is /usr/local/cuda-6.5 ]:
Do you want to install a symbolic link at /usr/local/cuda? ((y)es/(n)o/(q)uit): y
Install the CUDA 6.5 Samples? ((y)es/(n)o/(q)uit): y
Enter CUDA Samples Location [ default is /home/car01 ]:
 
References:
http://linuxaudioproduction.blogspot.com.br/2015/09/how-to-patching-and-compiling-nvidia.html
 
https://devtalk.nvidia.com/default/topic/572468/nvidia-325-15-linux-rt-old-amp-amp-new-nvidia-rt-patch-methods-questions-about-nvidia-installer/
 
 
== Possíveis problemas ==
 
Error NVRM/VGA com o driver da nvidia:
 
use o comando:
sudo dmesg | tail
Se ocorrer os seguintes erros:
<pre>
[  15.458823] NVRM: Your system is not currently configured to drive a VGA console
[  15.458830] NVRM: on the primary VGA device. The NVIDIA Linux graphics driver
[  15.458834] NVRM: requires the use of a text-mode VGA console. Use of other console
[  15.458838] NVRM: drivers including, but not limited to, vesafb, may result in
[  15.458841] NVRM: corruption and stability problems, and is not supported.
</pre>
 
Adicione a seguinte linha no arquivo  /boot/grub/grub.cfg ao fim da linha do kernel
video=vesa:off vga=normal
 
e.g.
 
menuentry 'Ubuntu' --class ubuntu...
 
(...)
 
linux    /boot/vmlinuz-4.1.5-rt5 root=UUID=f5a99a1a-15a4-4a83-a3fb-2adbee7f8311 ro quiet splash $vt_handoff '''video=vesa:off vga=normal'''
 
(..)
 
verificar nesse link
https://bbs.archlinux.org/viewtopic.php?id=143569
 
Erro na resolução do monitor.
Entre na configurações da nvidia como super usuário
   
   
 
$ sudo nvidia-settings
    Build and install the kernel:


make
Em X Server Display Configuration, restaure a configuração do X server clicando no botão de "Reset". Após isso reinicie a maquina.
make modules
sudo make INSTALL_MOD_STRIP=1 modules_install
sudo make install


    Update the bootloader (probably grub) if not done automatically.
Feito isso, volte na mesma aba da nvidia-settings. Verifique no campo "Selection" se o aparece o seu monitor. Depois mude a resolução do monitor para uma configuração maior e salve a configuração em "Save to X Configuration File".

Edição atual tal como às 17h05min de 30 de novembro de 2017

Todas as informacoes aqui foram retiradas de: http://linuxaudioproduction.blogspot.com.br/2015/09/patching-compiling-and-installing.html

Testado com o Ubuntu 14.04.1

This guide is a condensed reference on how to patch, compile and install the 4.1.5. kernel.

Download kernel, headers and patch:

https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.5.tar.xz
http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.1.5-unstable/linux-headers-4.1.5-040105_4.1.5-040105.201508101730_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.1.5-unstable/linux-headers-4.1.5-040105-generic_4.1.5-040105.201508101730_amd64.deb
https://www.kernel.org/pub/linux/kernel/projects/rt/4.1/older/patch-4.1.5-rt5.patch.gz

use sudo mode:

sudo su
cd /home/car01/Downloads

Extract kernel archive and patch file:

tar -Jxf linux-4.1.5.tar.xz
gzip -d patch-4.1.5-rt5.patch.gz

Put the patch file one directory level above the kernel source.

mv linux-4.1.5 /usr/src
cp patch-4.1.5-rt5.patch /usr/src

Change directory to the newly created kernel source directory

cd /usr/src/linux-4.1.5

Apply the patch to the kernel.

less ../patch-4.1.5-rt5.patch | patch -p1

Get the latest configuration of new kernel

make oldconfig

The make will ask some questions, answer with the default option, EXCEPT the options about real time and debug mode. When asked for:

  • "Preemption Model"
    • Choose "5. Fully Preemptible Kernel (RT) (PREEMPT_RT_FULL) (NEW)"
  • "Debug preemptible kernel (DEBUG_PREEMPT)"
    • Choose "n"

Open up the kernel configuration tool:

make menuconfig

To configure the IP_TABLES NAT support:

On the Kernel Configuration go to:
 Networking support > Networking Options > Network packet filtering framework (Netfilter) > IP: Netfilter Configuration
 Find the options listed below and mark with <M>
 	<M> IP tables support (required for filtering/masq/NAT) 
 Other options will apear:
	<M> MASQUERADE target support
	<M> NETMAP tarrget support
	<M> REDIRECT target support
 save and exit
 

Build and install the kernel:

make -j 24
make -j 24 modules
make -j 24 INSTALL_MOD_STRIP=1 modules_install
make install
cd ..

Update the bootloader (probably grub) if not done automatically.

Install the new headers:

sudo dpkg -i /home/car01/Downloads/linux-headers-4.1.5*.deb

restart the computer.


Check if the iptables_nat is working:

iptables -t nat -L
 If shows the following error:
   iptables v1.4.21: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
   Perhaps iptables or your kernel needs to be upgraded.
Back to the step of menu configuration tool:make menuconfig and check the iptables options. If is ok, try the solution:
     cd /usr/src/linux-4.1.5
     sudo make menuconfig
  Go to menu Networking Support > Networking Options > Network packet filtering framework (Netfilter)
  and press spacebar to mark with star
  Entry in this menu and go to Core Netfilter Configuration. Fill all options with M EXCEPT the options 
  below that should be filled with star :
	"Netfilter connection tracking support", 
	"Connection tracking flow accounting", 
	"Connection mark tracking support", 
	"Connection tracking security mark support", 
	"Connection tracking events" and 
	"Netfilter Xtables support (required for ip_tables)"
   And the option "Enable obsolete /proc/net/ipt_recent" doesn't should be filled.
   Save changes and exit. 
  BACK TO THE '''Build and install the kernel''' STEP in this tutorial.

If you are using RAID and partition isn't recognized, install the package and reboot:

sudo apt-get install dmraid


Install Nvidia Graphics Driver (352.41) for the Realtime Kernel

After installing the realtime kernel as described above, Nvidia graphics card owners will probably want
 to install the official graphics driver from Nvidia (if you're using Ardour you're going to need this driver 
 to get smooth GUI performance). Unfortunately, the installer will just complain about the realtime kernel and
 quit. With some tweaks it is possible to install it nevertheless. This article describes the installation of the
 Nvidia driver version 352.41. For different versions you will need a different patch file or perform the patch manually.

 Warning: I found that the driver sometimes locks itself up on my system, leading to a frozen image.
 If 100% stability is a requirement for you, you should not install it. During the installation you will 
 need to stop your desktop session so consider printing this guide or open it up on a different device.

Go ahead if you're ready:

Remove the old nvidia instalation

sudo apt-get remove nvidia*
sudo apt-get autoremove

Update and download a few tools that we will need:

sudo apt-get update
sudo apt-get install dkms build-essential

Now its time to blacklist the nouveau driver.

sudo gedit /etc/modprobe.d/blacklist-nouveau.conf

And add the following lines:

blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off

Disable the Kernel nouveau by typing the following commands:

echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u

Download the driver package from your local nvidia page:

http://www.nvidia.com/Download/index.aspx

Make a patch file as follows:

nvidia-352.41-rt.patch

Open a console and change directory to the folder where you downloaded the driver package to. Make the driver package executable:

chmod +x NVIDIA-Linux-x86_64-352.41.run

Extract the driver source:

./NVIDIA-Linux-x86_64-352.41.run --extract-only

Apply the patch file:

less nvidia-352.41-rt.patch | patch NVIDIA-Linux-x86_64-352.41/kernel/nv-linux.h

Press Ctrl+Alt+F1 to open up a terminal session and login as root to stop your X Sever. If you're using XFCE (UbuntuStudio) this is LightDM. Beware that this kills all programs running in the GUI session, including the browser you might be reading this article in:

/etc/init.d/lightdm stop

Set this environment variable to disable the a check for the realtime kernel patch in the installer:

export IGNORE_PREEMPT_RT_PRESENCE=1

Change directory to the folder where the nvidia driver source was extracted to. Run the installer just like you normally would:

./nvidia-installer

Restart your desktop manager:

/etc/init.d/lightdm start

Check if the driver was install correctly, deve mostrar as informações da placa de video

$ nvidia-settings

Your system should now use the freshly installed driver!

If you want to adapt this process for a different driver version, you will need to take a look what the patch actually
 does and make those changes to the nv-linux.h file manually. If you do so, it would be very nice of you to create a new patch 
 file and post it here in the comments. Of course, there's no guarantee that this will work for newer driver versions.

Para instalar o cuda siga as instruções do Getting_Started: http://developer.download.nvidia.com/compute/cuda/6_5/rel/docs/CUDA_Getting_Started_Linux.pdf

Use o instador .run

Na instalação vai aparecer algumas perguntas, Siga essas respostas.

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 340.29? ((y)es/(n)o/(q)uit): n
Install the CUDA 6.5 Toolkit? ((y)es/(n)o/(q)uit): y
Enter Toolkit Location [ default is /usr/local/cuda-6.5 ]: 
Do you want to install a symbolic link at /usr/local/cuda? ((y)es/(n)o/(q)uit): y
Install the CUDA 6.5 Samples? ((y)es/(n)o/(q)uit): y
Enter CUDA Samples Location [ default is /home/car01 ]: 

References: http://linuxaudioproduction.blogspot.com.br/2015/09/how-to-patching-and-compiling-nvidia.html

https://devtalk.nvidia.com/default/topic/572468/nvidia-325-15-linux-rt-old-amp-amp-new-nvidia-rt-patch-methods-questions-about-nvidia-installer/


Possíveis problemas

Error NVRM/VGA com o driver da nvidia:

use o comando: sudo dmesg | tail Se ocorrer os seguintes erros:

[   15.458823] NVRM: Your system is not currently configured to drive a VGA console
[   15.458830] NVRM: on the primary VGA device. The NVIDIA Linux graphics driver
[   15.458834] NVRM: requires the use of a text-mode VGA console. Use of other console
[   15.458838] NVRM: drivers including, but not limited to, vesafb, may result in
[   15.458841] NVRM: corruption and stability problems, and is not supported.

Adicione a seguinte linha no arquivo /boot/grub/grub.cfg ao fim da linha do kernel

video=vesa:off vga=normal

e.g.

menuentry 'Ubuntu' --class ubuntu...

(...)

linux /boot/vmlinuz-4.1.5-rt5 root=UUID=f5a99a1a-15a4-4a83-a3fb-2adbee7f8311 ro quiet splash $vt_handoff video=vesa:off vga=normal

(..)

verificar nesse link

https://bbs.archlinux.org/viewtopic.php?id=143569

Erro na resolução do monitor. Entre na configurações da nvidia como super usuário

$ sudo nvidia-settings 

Em X Server Display Configuration, restaure a configuração do X server clicando no botão de "Reset". Após isso reinicie a maquina.

Feito isso, volte na mesma aba da nvidia-settings. Verifique no campo "Selection" se o aparece o seu monitor. Depois mude a resolução do monitor para uma configuração maior e salve a configuração em "Save to X Configuration File".