How to clean up /boot?
silver.bullet at zoho.com
Wed Jan 11 10:10:20 UTC 2017
On Wed, 11 Jan 2017 10:54:01 +0100, Ralf Mardorf wrote:
>On Wed, 11 Jan 2017 10:45:43 +0100, Ralf Mardorf wrote:
>>On Wed, 11 Jan 2017 09:05:54 +0100, Sascha Manns wrote:
>>>On 08.01.2017 17:18, Peng Yu wrote:
>>>> It doesn't work.
>>>Maybe this one works for you.
>>>1.) create a new textfile in a editor and place it in ~/home (eg vim
>>>2.) Fill it with that:
>>>dpkg -l 'linux-[ihs]*' | sed '/^ii/!d;/'"$(uname -r | sed
>>>"s/\([-0-9]*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^
>>>]*\).*/\1/;/[0-9]/!d' | tee to_removed
>>>cat to_be_removed | xargs sudo apt-get -y purge
>>>It deletes all kernels in /boot and holds the last one.
>>_warning_ this script is dangerous!
>>Firs of all, regarding to the typo and the fact that a novice unlikely
>>will be able to fix the line wrapping issues, the script does nothing
>>at all. However, if you fix the script, get rid of the wrapped lines
>>and edit "tee to_removed" to "tee to_be_removed" the script could
>>automatically purge all kernels and render the install unbootable.
>>For demonstration I replaced "-y" by "--dry-run", then I didn't boot
>>Ubuntu, but run it in a container, so when "uname -r" does show the
>>running kernel, it's a kernel that is not a kernel installed by
>>Ubuntu, ergo what ever sed should do (I didn't check if it's correct,
>>but assuming it should be), "uname -r" not necessarily does keeps the
>>latest kernel. If it should keep a kernel, than the kernel that is
>>running. Even if you don't run Ubuntu in a container, it might not
>>keep the latest kernel. Such a script at least should first show what
>>it will do and than require interaction, so at least the "-y" option
>>should be removed.
>>[root at archlinux rocketmouse]# systemd-nspawn -qD /mnt/moonstudio
>>[root at moonstudio ~]# lsb_release -d
>>Description: Ubuntu 16.04.1 LTS
>>[root at moonstudio ~]# ls -hl /boot/vmlinuz-*
>>-rw------- 1 root root 6.8M Jan 7
>>03:36 /boot/vmlinuz-4.4.0-59-lowlatency lrwxrwxrwx 1 root root 27
>>Jan 10 17:44 /boot/vmlinuz-lowlatency -> vmlinuz-4.4.0-59-lowlatency
>>[root at moonstudio ~]# uname -r 4.8.13-1-ARCH
>>[root at moonstudio ~]# cd /home/weremouse/Desktop/
>>[root at moonstudio Desktop]# cat crappy_script.sh
>>dpkg -l 'linux-[ihs]*' | sed '/^ii/!d;/'"$(uname -r | sed
>>"s/\([-0-9]*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^
>>]*\).*/\1/;/[0-9]/!d' | tee to_be_removed
>>cat to_be_removed | xargs sudo apt-get --dry-run purge
>>[root at moonstudio Desktop]# ./crappy_script.sh
>>Reading package lists... Done
>>Building dependency tree
>>Reading state information... Done
>>The following packages will be REMOVED:
>> linux-headers-4.4.0-59* linux-headers-4.4.0-59-lowlatency*
>> linux-headers-lowlatency* linux-image-4.4.0-59-lowlatency*
>> linux-image-lowlatency* linux-lowlatency*
>>0 upgraded, 0 newly installed, 6 to remove and 0 not upgraded.
>>Purg linux-lowlatency [220.127.116.11.62]
>>Purg linux-headers-lowlatency [18.104.22.168.62]
>>Purg linux-headers-4.4.0-59-lowlatency [4.4.0-59.80]
>>Purg linux-headers-4.4.0-59 [4.4.0-59.80]
>>Purg linux-image-lowlatency [22.214.171.124.62]
>>Purg linux-image-4.4.0-59-lowlatency [4.4.0-59.80]
>>[root at moonstudio Desktop]#
>>Btw. does the script remove modules build manually with dkms, too?
>PS: Sascha also forgot to mention to make the script executable and
>another user recommended to rm the kernels. Don't! However, follow
PPS: FWIW I assume that /lib/modules will be automatically tidied up by
dkms hooks? It doesn't matter, the topic is to clean boot/. I just want
to point out, that following Nils advice, not the latest kernel is
kept, but it at least keeps linux-image-3.11.0-20-generic, so after
fixing the broken dependencies and upgrading you should be able to tidy
up using "autoremove".
More information about the ubuntu-users