Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

How to deepclean all packages except current kernel realted

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
jmanko
Tux's lil' helper
Tux's lil' helper
Posts: 139
Joined: Sun Sep 11, 2005 5:41 pm
Location: NEPA, USA

How to deepclean all packages except current kernel realted

  • Quote

Post by jmanko » Sun Jan 27, 2019 7:56 pm

I'd like to remove all old packages, except for anything related to the current kernel source and headers. I generated my kernel with genkernel.
"What stands in the way becomes the way." -- Marcus Aurelius
Top
fedeliallalinea
Administrator
Administrator
User avatar
Posts: 31985
Joined: Sat Mar 08, 2003 11:15 pm
Location: here
Contact:
Contact fedeliallalinea
Website

  • Quote

Post by fedeliallalinea » Sun Jan 27, 2019 8:00 pm

You can add kernel in your world file with emerge --noreplace sys-kernel/gentoo-sources:<slot_number> or passing --exclude=sys-kernel/gentoo-sources as option to emerge --depclean
Questions are guaranteed in life; Answers aren't.

"Those who would give up essential liberty to purchase a little temporary safety,
deserve neither liberty nor safety."
- Ben Franklin
https://www.news.admin.ch/it/nsb?id=103968
Top
Muso
Veteran
Veteran
User avatar
Posts: 1052
Joined: Tue Oct 22, 2002 7:45 am
Location: The Holy city of Honolulu
Contact:
Contact Muso
Website

Re: How to deepclean all packages except current kernel real

  • Quote

Post by Muso » Sun Jan 27, 2019 8:01 pm

jmanko wrote:I'd like to remove all old packages, except for anything related to the current kernel source and headers. I generated my kernel with genkernel.
emerge --depclean will not remove your current kernel, only your older kernel sources.

After running --depclean, you should mount /boot and clean out the old kernel images from there as well, then :

Code: Select all

cd /usr/src
Double check your current kernel with :

Code: Select all

uname -a
Then remove the old kernel... so, for example, let's say you are using 4.20.5-gentoo-sources, and you have 4.20.4 & 4.20.3 also in /usr/src. Do not remove /usr/src/linux nor your current version, but you can safely remove the older ones.
"You can lead a horticulture but you can't make her think" ~ Dorothy Parker
2021 is the year of the Linux Desktop!
Top
jmanko
Tux's lil' helper
Tux's lil' helper
Posts: 139
Joined: Sun Sep 11, 2005 5:41 pm
Location: NEPA, USA

  • Quote

Post by jmanko » Sun Jan 27, 2019 8:08 pm

Thank you both for replies! I will get on this now. :)
"What stands in the way becomes the way." -- Marcus Aurelius
Top
cboldt
Veteran
Veteran
User avatar
Posts: 1046
Joined: Wed Aug 24, 2005 2:54 pm

  • Quote

Post by cboldt » Sun Jan 27, 2019 11:25 pm

Other remnants not reached by --depclean are in /lib/modules
Top
leifbk
Guru
Guru
User avatar
Posts: 431
Joined: Mon Jan 05, 2004 9:18 am
Location: Bærum, Norway
Contact:
Contact leifbk
Website

  • Quote

Post by leifbk » Mon Jan 28, 2019 7:26 am

Use the --exclude parameter to not depclean particular packages. Here's my standard depclean:

Code: Select all

balapapa ~ # emerge -aq --depclean --exclude sys-kernel/gentoo-sources --exclude dev-db/postgresql
I've got this little script called "purge" in /root that I'm running to clean out an old kernel:

Code: Select all

#! /bin/sh

if [ "$#" -eq 0 ] ;
then
    echo -e "Usage: $0 x.y.z (kernel version)"
    exit 1
else
    emerge --depclean --quiet =sys-kernel/gentoo-sources-$1
    echo "deleting usr/src/linux-$1-gentoo ..."
    rm -r /usr/src/linux-$1-gentoo
    echo "deleting /lib64/modules/$1-gentoo ..."
    rm -r /lib64/modules/$1-gentoo
    echo "deleting /boot/*-$1-gentoo ..."
    rm /boot/*-$1-gentoo
fi
Thus, "./purge 4.20.3" will clean out that kernel version.

FYI, here's also my script for auto-generating a new kernel, "/root/newk" (named after one of my favourite old jazz saxophonists, Sonny "Newk" Rollins):

Code: Select all

#! /bin/sh

echo -ne "\033]0;Newk running\007"
zcat /proc/config.gz > /usr/src/linux/.config
cd /usr/src/linux
make olddefconfig
cd
genkernel --oldconfig all
Remember to do an "eselect kernel" first.
Grumpy old man
Top
Fitzcarraldo
Advocate
Advocate
User avatar
Posts: 2057
Joined: Sat Aug 30, 2008 9:49 pm
Location: United Kingdom
Contact:
Contact Fitzcarraldo
Website

  • Quote

Post by Fitzcarraldo » Tue Jan 29, 2019 2:37 pm

I currently have kernel 4.12.12-gentoo installed:

Code: Select all

# uname -r
4.12.12-gentoo
As I like to keep the kernel sources for the currently-installed kernel plus the newest kernel in the portage tree, I have the following in the world file:

Code: Select all

# grep gentoo-sources /var/lib/portage/world
sys-kernel/gentoo-sources
sys-kernel/gentoo-sources:4.12.12
Then depclean leaves those two installed kernel packages alone:

Code: Select all

# emerge --ask --depclean

 * Always study the list of packages to be cleaned for any obvious
 * mistakes. Packages that are part of the world set will always
 * be kept.  They can be manually added to this set with
 * `emerge --noreplace <atom>`.  Packages that are listed in
 * package.provided (see portage(5)) will be removed by
 * depclean, even if they are part of the world set.
 * 
 * As a safety measure, depclean will not remove any packages
 * unless *all* required dependencies have been resolved.  As a
 * consequence of this, it often becomes necessary to run 
 * `emerge --update --newuse --deep @world` prior to depclean.

Calculating dependencies... done!
>>> Calculating removal order...

>>> These are the packages that would be unmerged:                                                                                                                                                                                                 

 sys-kernel/gentoo-sources
    selected: 4.20.0 
   protected: none 
     omitted: 4.12.12 4.20.5 

All selected packages: =sys-kernel/gentoo-sources-4.20.0

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

Would you like to unmerge these packages? [Yes/No] Yes
>>> Waiting 5 seconds before starting...
>>> (Control-C to abort)...
>>> Unmerging in: 5 4 3 2 1
>>> Unmerging (1 of 1) sys-kernel/gentoo-sources-4.20.0...
Packages installed:   1626
Packages in world:    339
Packages in system:   43
Required packages:    1626
Number removed:       1

 * GNU info directory index is up-to-date.

Code: Select all

# eix -I gentoo-sources
[I] sys-kernel/gentoo-sources
     Available versions:  
     (4.4.164) 4.4.164^bs
     (4.4.170) (~)4.4.170^bs
     (4.4.171) (~)4.4.171^bs
     (4.4.172) (~)4.4.172^bs
     (4.9.140) 4.9.140^bs
     (4.9.150) (~)4.9.150^bs
     (4.9.151) (~)4.9.151^bs
     (4.9.152) (~)4.9.152^bs
     (4.9.153) (~)4.9.153^bs
     (4.12.12) (~)4.12.12^bs[1]
     (4.14.83) 4.14.83^bs
     (4.14.92) (~)4.14.92^bs
     (4.14.93) (~)4.14.93^bs
     (4.14.95) (~)4.14.95^bs
     (4.14.96) (~)4.14.96^bs
     (4.19.14) (~)4.19.14^bs
     (4.19.15) (~)4.19.15^bs
     (4.19.16) (~)4.19.16^bs
     (4.19.17) (~)4.19.17^bs
     (4.19.18) (~)4.19.18^bs
     (4.20.0) (~)4.20.0^bs
     (4.20.1) (~)4.20.1^bs
     (4.20.2) (~)4.20.2^bs
     (4.20.3) (~)4.20.3^bs
     (4.20.4) (~)4.20.4^bs
     (4.20.5) (~)4.20.5^bs
       {build experimental symlink}
     Installed versions:  4.12.12(4.12.12)^bs[1](23:11:38 20/01/18)(-build -experimental -symlink) 4.20.5(4.20.5)^bs(01:52:57 29/01/19)(-build -experimental -symlink)
     Homepage:            https://dev.gentoo.org/~mpagano/genpatches
     Description:         Full sources including the Gentoo patchset for the 4.20 kernel tree

[1] "local_overlay" /usr/local/portage
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.

My blog
Top
depontius
Advocate
Advocate
Posts: 3533
Joined: Wed May 05, 2004 4:06 pm

Re: How to deepclean all packages except current kernel real

  • Quote

Post by depontius » Tue Jan 29, 2019 3:21 pm

Muso wrote:
jmanko wrote:I'd like to remove all old packages, except for anything related to the current kernel source and headers. I generated my kernel with genkernel.
emerge --depclean will not remove your current kernel, only your older kernel sources.

After running --depclean, you should mount /boot and clean out the old kernel images from there as well, then :

Code: Select all

cd /usr/src
Double check your current kernel with :

Code: Select all

uname -a
Then remove the old kernel... so, for example, let's say you are using 4.20.5-gentoo-sources, and you have 4.20.4 & 4.20.3 also in /usr/src. Do not remove /usr/src/linux nor your current version, but you can safely remove the older ones.
Don't forget about the old kernel entries in /lib/modules, too. Those chew up quite a bit of space.
.sigs waste space and bandwidth
Top
Post Reply

8 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic