删除旧内核

删除旧内核

我用了这个命令

echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs sudo apt-get -y purge

由此关联删除旧内核以释放磁盘空间,但在执行该命令时我收到以下消息

...
1 upgraded, 2 newly installed, 2 to remove and 288 not upgraded.
Need to get 52.0 MB of archives.
After this operation, 186 kB of additional disk space will be used.
...

此命令难道不应该释放磁盘空间而不是使用额外的磁盘空间吗?

答案1

你没做过:

echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs echo sudo apt-get -y purge
......................................................................................................................................................................................................................................................^^^^

第一的?

认真地使用/usr/bin/purge-old-kernels脚本(包的一部分byobu

答案2

尝试这个:

打开终端,

Ctrl++AltT

运行:

exec sudo -i

CONFOLD=$(dpkg -l|grep "^rc"|awk '{print $2}')

KERNELCUR=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')

PKGLINUX="linux-(image|headers|ubuntu-modules|restricted-modules)"

PKGMETALINUX="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"

KERNELSOLD=$(dpkg -l|awk '{print $2}'|grep -E $PKGLINUX |grep -vE $PKGMETALINUX|grep -v $KERNELCUR)

apt-get purge $CONFOLD

apt-get purge $KERNELSOLD

apt-get autoremove

为了释放更多磁盘空间,您可以继续运行:

apt-get install --reinstall deborphan

deborphan

apt-get --purge remove $(deborphan)

deborphan --libdevel

apt-get --purge remove $(deborphan --libdevel)

deborphan --find-config

dpkg --purge $(deborphan --find-config)

apt-get autoremove

apt-get clean

相关内容