Compilação do kernel linux-libre 4.4.6 com cflags -march=native + -Ofast

Publicado por Mário RPG (última atualização em 07/04/2016)

[ Hits: 2.864 ]

Homepage: www.fsfla.org

Download 6397.scriptkernel-libre-4.4.6.sh




Script em bash para compilação automática do kernel Linux-libre 4.4.6 no Ubuntu/Debian/Mint/Trisquel 32/64 bits para PC/notebooks que tenham no mínimo 2 GB de memória RAM. Ele baixa e compila tudo automaticamente usando "CFLAGS -MARCH=NATIVE +  Ofast", só sendo necessário escolher a arquitetura exata do seu processador no menuconfig.

Como executar no terminal:

$ time sudo bash scriptkernel-libre-4.4.6.sh

Página do projeto:

http://sourceforge.net/projects/scriptkernel/

  



Esconder código-fonte

#!/bin/bash

# GPLv3
# 
# DEBIAN LIKE
#
# NECESSARIO versão GCC-4.7 ou superior
#
# Tamanho final da pasta /usr/src/linux-x.xx.xx = 9.6 GB
#
# Tempo de compilação ~250 min
#
###########################################################

#versão do kernel a ser compilado
kernel=4.4

#path de atualização
patchkernel=4.4.6

#patch BFQ
#bfq=3.4.0-v4

#patch do kernel ubuntu site: http://kernel.ubuntu.com/~kernel-ppa/mainline/ ################
P1=0001-base-packaging.patch
P2=0002-debian-changelog.patch
P3=0003-configs-based-on-Ubuntu-4.4.0-5.20.patch
#P4=0004-configs-based-on-Ubuntu-3.4.0-5.11.patch 


#apelido do kernel ubuntu
apelido=wily

#patch ck
#patchck=3.4-ck3

#sufixo
ckk=aaa


#.config antigo
kernelantigo=atual

##################################

##################################
#arquitetura: amd64 ou i386 # criado por Stivekx - forum ubuntu-br #######
arqt=$(dpkg --print-architecture)


#CL=CONCURRENCY_LEVEL do processador # criado por Stivekx  ############
CL=$(grep -c processor /proc/cpuinfo)
##################################

########baixando compiladores e dependencias########################################################
sudo apt-get update
sudo apt-get install kernel-package libncurses5 libncurses5-dev build-essential patch gcc make gzip bzip2 lzip lzma lzop lrzip lrzsz xz-utils -y
#sudo apt-get install gcc-4.9 -y
####################################################################################################


####### backup dos patchs antigos ######################
sudo mkdir /usr/src/bkpatch
sudo mv /usr/src/*.patch /usr/src/bkpatch
########################################################


############ download kernel linux-libre ################
cd /usr/src
wget -c http://www.linux-libre.fsfla.org/pub/linux-libre/releases/$kernel-gnu/linux-libre-$kernel-gnu.tar.bz2



sudo tar -jxpvf /usr/src/linux-libre-$kernel-gnu.tar.bz2
sudo mv /usr/src/linux-$kernel /usr/src/linux-libre-$patchkernel-$ckk


########### download patchs #############################
wget -c http://www.linux-libre.fsfla.org/pub/linux-libre/releases/$patchkernel-gnu/patch-$kernel-gnu-$patchkernel-gnu.xz
#wget -c http://www.kernel.org/pub/linux/kernel/v3.x/patch-$patchkernel.xzy
#wget -c http://ck.kolivas.org/patches/3.0/$kernel/$patchck/patch-$patchck.bz2
#wget -c http://algo.ing.unimo.it/people/paolo/disk_sched/patches/$bfq/0001-block-cgroups-kconfig-build-bits-for-BFQ-v4-$kernel.patch
#wget -c http://algo.ing.unimo.it/people/paolo/disk_sched/patches/$bfq/0002-block-introduce-the-BFQ-v4-I-O-sched-for-$kernel.patch



########### ubuntu patchs ###############################
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v$patchkernel-$apelido/$P1
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v$patchkernel-$apelido/$P2
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v$patchkernel-$apelido/$P3
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v$patchkernel-$apelido/$P4



########## descompactando patch #########################
sudo xz -d /usr/src/patch-$kernel-gnu-$patchkernel-gnu.xz



cd /usr/src/linux-libre-$patchkernel-$ckk


########## aplicando patchs #############################
sudo patch -p1 < /usr/src/patch-$kernel-gnu-$patchkernel-gnu
#sudo patch -p1 < /usr/src/patch-$patchck
#sudo patch -p1 < /usr/src/0001-block-cgroups-kconfig-build-bits-for-BFQ-v4-$kernel.patch
#sudo patch -p1 < /usr/src/0002-block-introduce-the-BFQ-v4-I-O-sched-for-$kernel.patch
sudo patch -p1 < /usr/src/$P1
sudo patch -p1 < /usr/src/$P2
sudo patch -p1 < /usr/src/$P3
sudo patch -p1 < /usr/src/$P4

######################

sleep 2

########## removendo .config antigo #####################
sudo rm /boot/download
cd /boot

########## baixando .config do site  http://sourceforge.net/projects/scriptkernel/files ########
sudo wget -c http://sourceforge.net/projects/scriptkernel/files/config-core2/download

#sudo wget -c http://sourceforge.net/projects/scriptkernel/files/config-atom3/download

#sudo wget -c http://sourceforge.net/projects/scriptkernel/files/config-14-atom2/download

#sudo wget -c http://sourceforge.net/projects/scriptkernel/files/config-14-x86/download

#sudo wget -c http://sourceforge.net/projects/scriptkernel/files/config-14-atom32/download

#sudo wget -c http://sourceforge.net/projects/scriptkernel/files/config-kernel-12/download


########## copiando .config para /usr/src/linux-libre-xx-xx ####################################
sudo cp /boot/download /usr/src/linux-libre-$patchkernel-$ckk/.config




############# Editando o Makefile ######################

sudo sed -e 's/EXTRAVERSION\([ = ]\+\)/EXTRAVERSION = -aaa/g' /usr/src/linux-libre-$patchkernel-$ckk/Makefile  > /usr/src/linux-libre-$patchkernel-$ckk/mk && mv /usr/src/linux-libre-$patchkernel-$ckk/mk /usr/src/linux-libre-$patchkernel-$ckk/Makefile

cd /usr/src/linux-libre-$patchkernel-$ckk

#sudo gedit Makefile  

sleep 3

sudo make menuconfig

sleep 2




######## Retirando Modulos Problematicos  ############

sudo sed 's/CONFIG_RTS5139=m/# CONFIG_RTS5139 is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/aa && mv /usr/src/linux-libre-$patchkernel-$ckk/aa /usr/src/linux-libre-$patchkernel-$ckk/.config

sleep 2

sudo sed 's/CONFIG_IGB=m/# CONFIG_IGB is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/bb && mv /usr/src/linux-libre-$patchkernel-$ckk/bb /usr/src/linux-libre-$patchkernel-$ckk/.config

sleep 2

sudo sed 's/CONFIG_IGB_DCA=y/# CONFIG_IGB_DCA is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/cc && mv /usr/src/linux-libre-$patchkernel-$ckk/cc /usr/src/linux-libre-$patchkernel-$ckk/.config

sleep 2

sudo sed 's/CONFIG_IGBVF=m/# CONFIG_IGBVF is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/dd && mv /usr/src/linux-libre-$patchkernel-$ckk/dd /usr/src/linux-libre-$patchkernel-$ckk/.config

sleep 2

sudo sed 's/CONFIG_E1000E=m/# CONFIG_E1000E is not set/g' /usr/src/linux-libre-$patchkernel-$ckk/.config > /usr/src/linux-libre-$patchkernel-$ckk/ee && mv /usr/src/linux-libre-$patchkernel-$ckk/ee /usr/src/linux-libre-$patchkernel-$ckk/.config




sleep 3

######################################################


############ script criado por Stivekx #######################

#!/bin/bash

#Script para automatizar a mudança das flags na hora de compilar o kernel.
#Mais informações sobre como compilar o kernel para seu processador:
#http://ubuntuforum-br.org/index.php/topic,81718.0.html

#Modo de usar:
#Após baixar o kernel, descompactar, criar um link simbólico para ele no /usr/src/linux:
# cd /usr/src/linux   
# sudo su
# chmod +x script.sh
# ./script.sh
#O script deve ser executado como root. Recomendo que use sudo su - e rode o script ao invés de sudo sh script.sh


#Script criado por André Steinn

#Aqui é a lista de arquivos que ele vai dar replace no -march= por -march=native. Você pode mudar essa lista de arquivos passando a lista pela opção a e separados pro virgula
#e.g.: ./script.sh -a arch/x86/boot/compressed/Makefile,arch/x86/boot/Makefile,arquivo1,arquivo2,arquivo3

arquivos=( "arch/x86/boot/compressed/Makefile" "arch/x86/boot/Makefile" "arch/x86/kernel/acpi/realmode/Makefile" "arch/x86/Kconfig.cpu" "arch/x86/Makefile" "arch/x86/Makefile_32.cpu")

#Aqui eu verifico se a pessoa passou algum argumento na hora de executar o script
while getopts ":a:c" opt; do
  case $opt in
    a)
      echo "Você setou uma lista de arquivos personalizada: $OPTARG" >&2
   IFS=',' read -ra arquivos <<< "$OPTARG"
      ;;
    \?)
      echo "Opção inválida: -$OPTARG" >&2
      exit 1
      ;;
  esac
done

#Aqui eu faço um loop e altero os arquivos, removendo o -march=() por -march=native
for i in "${arquivos[@]}"
do
   echo "Path no arquivo:"$i
   sed -e 's/-march=\([A-Z0-9a-z]\+\)/-march=native -Ofast /g'  $i > "$i.file_changed"
   mv "$i.file_changed" $i
done



################

sleep 3


#time sudo CONCURRENCY_LEVEL=2 make-kpkg --initrd kernel_image kernel_headers modules_image

#time sudo CONCURRENCY_LEVEL=$CL make-kpkg --initrd kernel_image kernel_headers modules_image

#cd /usr/src
#sudo dpkg -i linux-image-$patchkernel-$ckk\_$patchkernel-$ckk-10.00.Custom_$arqt.deb linux-headers-$patchkernel-$ckk\_$patchkernel-$ckk-10.00.Custom_$arqt.deb

cd /usr/src/linux-libre-$patchkernel-$ckk


############## compilando e instalando kernel e modulos #####################
time sudo make -j2 
time sudo make modules_install
time sudo make install


sleep 3

cd /lib/modules
ls

#sudo mkinitramfs -o /boot/initrd.img-$patchkernel-$ckk $patchkernel-$ckk
sudo update-grub

sleep 3


echo -e '






\033[01;32m######################### KERNEL COMPILADO COM SUCESSO #############################\033[00;37m







'


Scripts recomendados

Xvnx4viewer

Speedy Business - HowTo 2.0

aMule :: HighID e Firewall

Instalar o screenFetch em qualquer distribuição

script para tirar ss


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts