Saturday, January 22, 2022

Ubuntu – Increase number of old kernels to keep on autoremove

So I looked into the script a little bit and some minor changes was enough to get what you want.

First create a backup of: /etc/kernel/postinst.d/apt-auto-removal:

sudo cp /etc/kernel/postinst.d/apt-auto-removal{,.bk}

Then find this line:

previous_version="$(echo "$debverlist" | sed -n 2p)"

and change it to:

previous_version="$(echo "$debverlist" | sed -n 2,4p)"
  • Now it should keep 3 old kernel + Running + Newly installed one
  • Of course you have to run it once manually or install a new kernel to make it take effect.

Git get all remote branches

git branch -r \ | grep -v '\->' \ | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" \ | while read remote; do \ git branc...