Created
April 20, 2017 01:58
-
-
Save jonbrouse/4336bd14fe55dd522f24801581a65734 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Remove old kernels and clean up inode count. | |
[ "$(whoami)" = root ] || { echo "Please run this script as root" && exit 1; } | |
CURRENT_KERNEL=$(uname -r | sed s/-generic//g) | |
OLD_KERNEL_LIST=$(find /usr/src -maxdepth 1 -mindepth 1 -type d -not -name "*$CURRENT_KERNEL*" -exec basename {} \;) | |
echo -e "Current kernel: $(uname -r)\n" | |
echo -e "Old kernels: \n$OLD_KERNEL_LIST\n" | |
OLD_KERNELS=$(find /usr/src -maxdepth 1 -mindepth 1 -type d -not -name "*$CURRENT_KERNEL*" -exec basename {} \; | tr '\n' ' ') | |
echo "Removing old kernels..." | |
apt-get remove -y $OLD_KERNELS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment