Como ou o que posso remover de / boot considerando que está quase cheio? [duplicado]

2

Como posso limpar / inicializar ou o que posso remover considerando que está quase cheio e recebo uma mensagem dizendo que há apenas 5,1 MB restantes. Porque se eu for ao analisador de uso do disco, como ele diz, não há abertura para limpeza.

Aqui está o conteúdo da partição:

username@hostname:~$ ls -l /boot/
total 423041
-rw-r--r-- 1 root root  1443719 Aug  9 07:08 abi-4.10.0-32-generic
-rw-r--r-- 1 root root  1443962 Aug 11 13:59 abi-4.10.0-33-generic
-rw-r--r-- 1 root root  1443962 Sep 13 07:16 abi-4.10.0-35-generic
-rw-r--r-- 1 root root  1407843 Feb  5  2017 abi-4.8.0-36-generic
-rw-r--r-- 1 root root  1408375 Mar 31 14:01 abi-4.8.0-46-generic
-rw-r--r-- 1 root root  1408671 Apr 20 09:07 abi-4.8.0-49-generic
-rw-r--r-- 1 root root  1408813 Jun 14 11:17 abi-4.8.0-56-generic
-rw-r--r-- 1 root root  1408813 Jun 26 17:31 abi-4.8.0-58-generic
-rw-r--r-- 1 root root   204970 Aug  9 07:08 config-4.10.0-32-generic
-rw-r--r-- 1 root root   204970 Aug 11 13:59 config-4.10.0-33-generic
-rw-r--r-- 1 root root   204970 Sep 13 07:16 config-4.10.0-35-generic
-rw-r--r-- 1 root root   199575 Feb  5  2017 config-4.8.0-36-generic
-rw-r--r-- 1 root root   199564 Mar 31 14:01 config-4.8.0-46-generic
-rw-r--r-- 1 root root   199588 Apr 20 09:07 config-4.8.0-49-generic
-rw-r--r-- 1 root root   199564 Jun 14 11:17 config-4.8.0-56-generic
-rw-r--r-- 1 root root   199564 Jun 26 17:31 config-4.8.0-58-generic
drwxr-xr-x 3 root root     1024 Apr  9 12:00 efi
drwxr-xr-x 5 root root     1024 Sep 20 05:03 grub
-rw-r--r-- 1 root root 42058341 Aug 28 10:57 initrd.img-4.10.0-32-generic
-rw-r--r-- 1 root root 42056847 Aug 29 02:58 initrd.img-4.10.0-33-generic
-rw-r--r-- 1 root root 42056820 Sep 20 05:03 initrd.img-4.10.0-35-generic
-rw-r--r-- 1 root root 40647942 Aug 28 10:56 initrd.img-4.8.0-36-generic
-rw-r--r-- 1 root root 40638652 Aug 28 10:55 initrd.img-4.8.0-46-generic
-rw-r--r-- 1 root root 40637975 Aug 28 10:55 initrd.img-4.8.0-49-generic
-rw-r--r-- 1 root root 40644972 Aug 28 10:55 initrd.img-4.8.0-56-generic
-rw-r--r-- 1 root root 40643997 Aug 28 10:55 initrd.img-4.8.0-58-generic
drwx------ 2 root root    12288 Apr  9 12:00 lost+found
-rw-r--r-- 1 root root   182704 Jan 28  2016 memtest86+.bin
-rw-r--r-- 1 root root   184380 Jan 28  2016 memtest86+.elf
-rw-r--r-- 1 root root   184840 Jan 28  2016 memtest86+_multiboot.bin
-rw------- 1 root root  3718993 Aug  9 07:08 System.map-4.10.0-32-generic
-rw------- 1 root root  3721812 Aug 11 13:59 System.map-4.10.0-33-generic
-rw------- 1 root root  3721891 Sep 13 07:16 System.map-4.10.0-35-generic
-rw------- 1 root root  4060748 Feb  5  2017 System.map-4.8.0-36-generic
-rw------- 1 root root  4066103 Mar 31 14:01 System.map-4.8.0-46-generic
-rw------- 1 root root  4066773 Apr 20 09:07 System.map-4.8.0-49-generic
-rw------- 1 root root  4068016 Jun 14 11:17 System.map-4.8.0-56-generic
-rw------- 1 root root  4068043 Jun 26 17:32 System.map-4.8.0-58-generic
-rw------- 1 root root  7398816 Aug  9 07:08 vmlinuz-4.10.0-32-generic
-rw------- 1 root root  7404416 Aug 11 13:59 vmlinuz-4.10.0-33-generic
-rw------- 1 root root  7405152 Sep 13 07:16 vmlinuz-4.10.0-35-generic
-rw-r--r-- 1 root root  7297312 Apr  9 12:08 vmlinuz-4.8.0-36-generic
-rw------- 1 root root  7305856 Mar 31 14:01 vmlinuz-4.8.0-46-generic
-rw------- 1 root root  7305856 Apr 20 09:07 vmlinuz-4.8.0-49-generic
-rw------- 1 root root  7309536 Jun 14 11:17 vmlinuz-4.8.0-56-generic
-rw------- 1 root root  7310848 Jun 26 17:31 vmlinuz-4.8.0-58-generic
username@hostname:~$ 
    
por UbuntuUser009 22.09.2017 / 06:54

1 resposta

1

Aqui está um script que faz isso automaticamente.

A maneira mais fácil de liberar espaço em / boot é livrar-se de kernels antigos e não utilizados. Não é importante quando excluo os kernels para nunca deletar o kernel que você está usando atualmente (cheque com uname -r) e você não quer deletar o kernel mais novo, senão você irá baixá-lo novamente na próxima atualização.

Cada kernel e os recursos de disco relacionados a ele ocupam cerca de 50 MB de espaço. Você também deseja excluir os kernels usando apenas o apt purgar, pois remove as dependências e atualiza o grub no final. Você pode ver uma lista de kernels instalados usando dpkg -l | grep linux-image.

O Autoremove nem sempre obtém todos os kernels antigos.

#!/bin/bash

# create the clean-boot command line utility, if it doesn't exist
if [ ! -f /usr/sbin/clean-boot ]; then
    cp "$0" /usr/sbin/clean-boot
    chown root.root /usr/sbin/clean-boot
    chmod 0770 /usr/sbin/clean-boot
fi

# add clean-boot cron job to root's crontab, if it doesn't exist
if [[  'crontab -l | grep "/usr/sbin/clean-boot" | wc -l' -eq 0 ]]; then    
    (crontab -l 2>/dev/null; echo "0 10 * * 3,4 /usr/sbin/clean-boot") | crontab -
fi


# array of kernels installed on the system
kernels=($(dpkg --list | grep 'linux-image-[0-9]' | awk '{ print $2 }'))

# kernel currently being used by the system 
current_kernel=linux-image-'uname -r'

# newest kernel installed (currently being initialized to current_kernel)
newest_kernel=$current_kernel


# for loop below used to find the newest insitalled kernel
for i in "${kernels[@]}"
do

    # since newest is initialized to current, there is no need to parse through kernels same version as the one currently loaded
    if [[ $i != $current_kernel*  ]]; then

        # each iteration of the for loop is for each version number (kernel version, major, minor, incidental numbers) example 4.8.0-56-generic
        for counter in 1 2 3 4
        do

            # if statement extracts the version numbers
            if [[ $counter -lt 3 ]]; then

                compare_number=$(echo ${i#"linux-image-"} | cut -d'.' -f$counter)
                newest_number=$(echo  ${newest_kernel#"linux-image-"} | cut -d'.' -f$counter)

            elif [[ $counter -eq 3 ]]; then

                compare_number=$(echo ${i#"linux-image-"} | cut -d'.' -f$counter)
                newest_number=$(echo  ${newest_kernel#"linux-image-"} | cut -d'.' -f$counter)

                compare_number=$(echo ${compare_number} | cut -d'-' -f1)
                newest_number=$(echo  ${newest_number} | cut -d'-' -f1)             

            else

                compare_number=$(echo ${i#"linux-image-"} | cut -d'-' -f2)
                newest_number=$(echo  ${newest_kernel#"linux-image-"} | cut -d'-' -f2)

            fi

            # this if statement does the comparison
            if [[ $compare_number -eq $newest_number ]]; then
                continue
            elif [[ $compare_number -lt $newest_number ]]; then
                break
            else
                newest_kernel=$i
                break
            fi

        done

    fi

done


# for every kernel
for i in "${kernels[@]}"
do

    # delete the kernel if the kernel is not the one in use and is not the newest one installed
    if [[ $i != $current_kernel* && $i != $newest_kernel* ]]; then

        apt-get purge "$i" -y

    fi 

done
    
por Andrew 22.09.2017 / 08:47