Mostrando postagens com marcador Kernel. Mostrar todas as postagens
Mostrando postagens com marcador Kernel. Mostrar todas as postagens

Sistemas Operacionais -> Ubuntu -> Como apagar um kernel no Ubuntu

Como apagar um kernel no Ubuntu

Com o passar do tempo vão surgindo novas atualizações de kernel, isso vai enchendo o HD de imagens, deixando os kernels antigos ociosos no computador, acumulando espaço. Aqui vou deixar uma maneira bem rápida de como remover estes kernels que não são mais usados por você.

O primeiro passo é listar todas as versões de kernel instaladas. Para isso devemos utilizar o comando:

$ dpkg --get-selections | grep linux-image

Vai aparecer uma lista com todas as imagens de kernel instaladas, então é só identificar aquelas que você quer apagar. Depois use o comando:

$ sudo aptitude purge nome_do_pacote

Este comando serve para desinstalar o pacote do HD. Mas se preferir desinstalar em modo gráfico é só abrir o gerenciador de pacotes Synaptic e digitar no campo "Busca rápida" o nome do kernel que quer desinstalar.

Se preferir não desinstalar, mas só retirar da inicialização do Grub (caso tenha boot com Windows e/ou outros), edite o menu.lst e remova as imagens que você quer que não apareçam no boot. Utilize este comando para abrir o menu.lst do grub:

$ sudo gedit /boot/grub/menu.lst

Exemplo com base no meu menu.lst após digitar o comando:

$ sudo gedit /boot/grub/menu.lst:

# menu.lst - See: grub(8), info grub, update-grub(8)
# grub-install(8), grub-floppy(8),
# grub-md5-crypt, /usr/share/doc/grub
# and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.
default 0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout 5

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu

# Pretty colours
#color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line) and entries protected by the
# command 'lock'
# e.g. password topsecret
# password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title Windows 95/98/NT/2000
# root (hd0,0)
# makeactive
# chainloader +1
#
# title Linux
# root (hd0,1)
# kernel /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
## kopt_2_6_8=root=/dev/hdc1 ro
## kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=UUID=a92fdbc4-b35e-426f-b283-798a3674bd53 ro

## default grub root device
## e.g. groot=(hd0,0)
# groot=a92fdbc4-b35e-426f-b283-798a3674bd53

## should update-grub create alternative automagic boot options
## e.g. alternative=true
## alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
## lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
## lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
## altoptions=(recovery) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
## howmany=7
# howmany=all

## specify if running in Xen domU or have grub detect automatically
## update-grub will ignore non-xen kernels when running in domU and vice versa
## e.g. indomU=detect
## indomU=true
## indomU=false
# indomU=detect

## should update-grub create memtest86 boot option
## e.g. memtest86=true
## memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##


title Ubuntu 9.04, kernel 2.6.28-15-generic
uuid a92fdbc4-b35e-426f-b283-798a3674bd53
kernel /boot/vmlinuz-2.6.28-15-generic root=UUID=a92fdbc4-b35e-426f-b283-798a3674bd53 ro quiet splash
initrd /boot/initrd.img-2.6.28-15-generic
quiet

title Ubuntu 9.04, kernel 2.6.28-15-generic (recovery mode)
uuid a92fdbc4-b35e-426f-b283-798a3674bd53
kernel /boot/vmlinuz-2.6.28-15-generic root=UUID=a92fdbc4-b35e-426f-b283-798a3674bd53 ro single
initrd /boot/initrd.img-2.6.28-15-generic

title Ubuntu 9.04, kernel 2.6.28-14-generic
uuid a92fdbc4-b35e-426f-b283-798a3674bd53
kernel /boot/vmlinuz-2.6.28-14-generic root=UUID=a92fdbc4-b35e-426f-b283-798a3674bd53 ro quiet splash
initrd /boot/initrd.img-2.6.28-14-generic
quiet

title Ubuntu 9.04, kernel 2.6.28-14-generic (recovery mode)
uuid a92fdbc4-b35e-426f-b283-798a3674bd53
kernel /boot/vmlinuz-2.6.28-14-generic root=UUID=a92fdbc4-b35e-426f-b283-798a3674bd53 ro single
initrd /boot/initrd.img-2.6.28-14-generic

title Ubuntu 9.04, memtest86+
uuid a92fdbc4-b35e-426f-b283-798a3674bd53
kernel /boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title Windows XP
rootnoverify (hd0,0)
savedefault
makeactive
chainloader +1

Reparem na linha:

## ## End Default Options ##

As imagens são listadas após ela.

Neste caso eu só quero apagar duas imagens do menu.lst, então vou apagar após a opção:

## ## End Default Options ##

toda a linha, title, uuid, kernel e initrd, ficando assim:

## ## End Default Options ##

title Ubuntu 9.04, kernel 2.6.28-15-generic
uuid a92fdbc4-b35e-426f-b283-798a3674bd53
kernel /boot/vmlinuz-2.6.28-15-generic root=UUID=a92fdbc4-b35e-426f-b283-798a3674bd53 ro quiet splash
initrd /boot/initrd.img-2.6.28-15-generic
quiet

title Ubuntu 9.04, kernel 2.6.28-15-generic (recovery mode)
uuid a92fdbc4-b35e-426f-b283-798a3674bd53
kernel /boot/vmlinuz-2.6.28-15-generic root=UUID=a92fdbc4-b35e-426f-b283-798a3674bd53 ro single
initrd /boot/initrd.img-2.6.28-15-generic


title Ubuntu 9.04, memtest86+
uuid a92fdbc4-b35e-426f-b283-798a3674bd53
kernel /boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title Other operating systems:
root


# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title Windows XP
rootnoverify (hd0,0)
savedefault
makeactive
chainloader +1

Se quiser alterar o tempo de espera para entrar no Linux, vá para a opção timeout. Ex.:

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).

timeout 5

Altere o timeout para quantos segundos quiser, no meu caso deixei com 5, mas você escolhe no seu.

Se você quer alterar a ordem do boot, vá para a opção default. Ex.:

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not use 'savedefault' or your
# array will desync and will not let you boot your system.

default 6

Observe o número 6, isso quer disser que a title número 7 será a iniciada por padrão, no meu caso seria o Windows XP, antes de ter retirado as outras title.

Por que a 7 e não 6?
Porque ele começa a contar a partir do 0, e o 0 é o número inicial da sua contagem, que para nós seria o 1. Se você deixar o número 0 (zero) ele vai iniciar por padrão a title mais recente instalada, ou seja, o kernel mais recente.

Se você quer alterar o nome que aparece na hora do boot, é só alterar o nome que aparece depois do title. No meu caso fiz com a title do Windows, que era:

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title Microsoft Windows XP Profissional
rootnoverify (hd0,0)
savedefault
makeactive
chainloader +1

E deixei somente assim:

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title Windows XP
rootnoverify (hd0,0)
savedefault
makeactive
chainloader +1

Espero ter ajudado!

Sistemas Operacionais -> Ubuntu -> Alterando a versão do Kernel do Ubuntu

Considerações iniciais

O texto pode ser usado para instalar em outras distros, mas eu não garanto nada, caso tenha dúvidas, problemas, ou quer acrescentar algo poste um comentário. Vale deixar claro que alguns programas param de funcionar e devem serem reinstalados, bons exemplos disso são os drivers da NVIDIA e o VMware, mas fique tranquilo a maioria dos problemas tem solução.

Baixando o kernel

Aperte ALT + F2, em seguida digite o seguinte comando:

gnome-terminal

Quando o terminal aparecer digite o seguinte comando:

$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.37.tar.bz2

E aguarde o download ser concluído.

Isto vai demorar um pouco, dependendo da sua conexão com a internet.

Preparando a instalação

Após ter acabado o download, digite o seguinte:

$ sudo su

Será necessário colocar sua senha, coloque-a.

# cp linux-2.6.37.tar.bz2 /usr/src

Depois disso entre na pasta onde foi copiado o pacote linux-2.6.37.tar.bz2:

# cd /usr/src

Descompacte o arquivo do kernel com o comando:

# tar jxvf linux-2.6.37.tar.bz2

Após ter descompactado entre na pasta do kernel:

# cd linux-2.6.37

Feito isso rode o comando:

# make xconfig

Esse comando te dará a opção de alterar as configurações do novo kernel, ele é baseado em interface gráfica e precisa do QT3 para rodar, a instalação do pacote qt3-dev-tools deve ser suficiente para o programa rodar.

Ali é carregado a estrutura do kernel atual, caso você queira mudar mude, mas é importante saber o que você está mudando. Aqui no meu PC eu só coloquei o suporte ao PAE, caso você queira ativá-lo, procure na coluna a esquerda "Processor types and features", depois na coluna da direita procure por "High Memory Support" e mude de 4GB, que é o padrão, para 64 GB. Clique no disquete e feche o programa.


Compilando, instalando e finalizando a instalação

Essa parte vai fazer com que o kernel possa ser executado no seu computador. Crie o kernel com o comando:

# make

NOTA: Antes de iniciar a compilação certifique-se o PC estar conectado a uma fonte de energia, e que as configurações de energia estejam definidas para que o computador não hiberne ou diminua a atividade do computador.

Isso vai demorar muito tempo para ser concluído. Faça um cafezinho e vá dar uma volta no parque, isso leva em média 1 hora para ser concluído dependendo do seu PC. Eu não recomendo rodar outras tarefas junto com a instalação pois só vai estender o tempo levado na compilação, mas se não se incomodar pode fazer normalmente suas tarefas.

Após ter compilado o kernel é necessário fazer a instalação do kernel compilado, entre com o comando:

# make modules_install

Este comando copia os módulos do kernel, nas devidas pastas.

É necessário:

# make install

Esse comando vai copiar alguns arquivos na pasta /boot.

É necessário criar um initrd para o sistema possa iniciar com o novo Kernel, para criá-lo basta rodar o comando:

# update-initramfs -k 2.6.37 -u

E agora para finalizar o grub deve ser atualizado:

# update-grub

Agora reinicie o seu computador e teste o novo kernel.

Pronto! O kernel está instalado.


Limpando a sujeira

Após instalar o kernel a pasta que contém as fontes não são mais necessárias e elas ocupam cerca de 3 GB ou mais, o melhor a se fazer é removê-las.

Para apagá-las abra o gnome-terminal novamente e digite:

$ sudo su

Ele vai pedir a sua senha. Coloque-a.

# cd /usr/src

E depois:

# rm -rf linux-2.6.37
# rm linux-2.6.37.tar.bz2


Pronto, agora se quiser você pode remover as imagens anteriores do kernel, eu recomendo a dica do colega mazureki:
Pronto pessoal, é isso aí, qualquer coisa é só escrever!