Re:Ubuntu 16.04: “Out of memory” errors after upgrade to 4.4...
by mianos on Sunday January 29, 2017 @04:00AM
(#13513171)
I used to use this to clean boot.
dpkg -l 'linux-' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]\)./\1/;/[0-9]/!d' | xargs -p sudo apt-get -y purge
[ Parent
| on HN ]
Re:Ubuntu 16.04: “Out of memory” errors after upgrade to 4.4...
by pacifika on Sunday January 29, 2017 @06:12AM
(#13513628)
What does it do?
Re:Ubuntu 16.04: “Out of memory” errors after upgrade to 4.4...
by cagey on Sunday January 29, 2017 @11:50AM
(#13514983)
I tried it on Lubuntu 16.04; it required modification:
# mystery one-liner from https://news.ycombinator.com/item?id=13513171
# dpkg -l 'linux-' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]\)./\1/;/[0-9]/!d' | xargs -p sudo apt-get -y purge
# my corrected/improved version:
noncurrent_kernel_pkgs() { dpkg -l 'linux-*[0-9]*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.\)-\([^0-9]\+\)/\1/")"'/d;s/^ii *\([^ ][^ ]*\)[^ ]*.*/\1/' ; }
# corrections/(possible-)improvements:
# - dpkg -l 'linux-' # returns nothing
# - dpkg -l 'linux-*[0-9]*' # moves 'pkgnm must contain a number' rule (last sed cmd in orig: '/[0-9]/!d') forward
# - pkgnm isolation/extraction was broken (did dpkg output change?)
output: kg@kg-VirtualBox:~$ noncurrent_kernel_pkgs
linux-headers-4.4.0-43
linux-headers-4.4.0-43-generic
linux-headers-4.4.0-45
linux-headers-4.4.0-45-generic
linux-headers-4.4.0-53
linux-headers-4.4.0-53-generic
linux-headers-4.4.0-57
linux-headers-4.4.0-57-generic
linux-image-4.4.0-43-generic
linux-image-4.4.0-45-generic
linux-image-4.4.0-53-generic
linux-image-4.4.0-57-generic
linux-image-extra-4.4.0-43-generic
linux-image-extra-4.4.0-45-generic
linux-image-extra-4.4.0-53-generic
linux-image-extra-4.4.0-57-generic
kg@kg-VirtualBox:~$ uname -r
4.4.0-59-generic
kg@kg-VirtualBox:~$
Re:Ubuntu 16.04: “Out of memory” errors after upgrade to 4.4...
by mianos on Sunday January 29, 2017 @04:20PM
(#13516747)
Sorry about that, the '*' got removed from a non marked up paste. You are 100% correct. Just a little script to remove all but the current unused kernels that I use on 14.04.
Yep, just take the xargs off to see what it will remove (which would always be good advice when pasting a random script LOL ).
Re:Ubuntu 16.04: “Out of memory” errors after upgrade to 4.4...
by alyandon on Sunday January 29, 2017 @11:45AM
(#13514965)
Take off the xargs part of the command and run it to see. :-D
Just looking at it though, it looks like it'll purge kernel packages that are the currently booted one. I don't have a system handy to check though so take that with a grain of salt.