CentOS8 で古いカーネルを削除する
CentOS7 までは yum-utils に含まれる package-cleanup を使うことで (残しておきたいカーネルの世代数を指定して) 不要になったカーネルを削除することが出来ました。
| package-cleanup --oldkernels --count=1 -y
|
CentOS8 系ではパッケージ管理が yum から dnf へ変更されましたが、dnf-utils をインストールし、dnf-utils に含まれる package-cleanup の man を見ても --oldkernels
オプションがありません。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 | PACKAGE-CLEANUP(1) dnf-plugins-core PACKAGE-CLEANUP(1)
NAME
package-cleanup - clean up locally installed, duplicate, or orphaned packages.
A DNF-based shim imitating the original YUM-based package-cleanup utility.
SYNOPSIS
package-cleanup [options]
OPTIONS
--leaves
List leaf nodes in the local RPM database. Leaf nodes are RPMs that are not
relied upon by any other RPM. Maps to dnf repoquery --unneeded.
--orphans
List installed packages which are not available from currently configured
repositories. Maps to dnf repoquery --extras.
--problems
List dependency problems in the local RPM database. Maps to dnf repoquery
--unsatisfied.
--dupes
Scan for duplicates in the local RPM database. Maps to dnf repoquery --dupli‐
cates.
--cleandupes
Scan for duplicates in the local RPM database and clean out the older versions.
Maps to dnf remove --duplicates.
EXAMPLES
package-cleanup --problems
List all dependency problems.
package-cleanup --orphans
List all packages that are not in any DNF repository.
package-cleanup --cleandupes
Remove all packages that have a duplicate installed.
AUTHOR
See AUTHORS in your Core DNF Plugins distribution
COPYRIGHT
2014, Red Hat, Licensed under GPLv2+
4.0.2.2 May 14, 2019 PACKAGE-CLEANUP(1)
|
CentOS8 の場合は dnf-utils を追加しなくても、標準の dnf を以下のように実行することで (カーネルに限らず) 重複した古いバージョンのパッケージを削除することが出来ます。
| dnf -y remove $(dnf repoquery --installonly --latest-limit=-1 -q)
|
参考
CentOS7 の man package-cleanup
実行結果
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 | package-cleanup(1) package-cleanup(1)
NAME
package-cleanup - clean up locally installed, duplicate, or orphaned packages
SYNOPSIS
package-cleanup [options] <item ...>
DESCRIPTION
package-cleanup is a program for cleaning up the locally-installed RPMs.
GENERAL OPTIONS
-c <config file>
Use alternative config file (default is /etc/yum.conf).
-h, --help
Help; display a help message and then quit.
-q, --quiet
Print out nothing unnecessary.
-v, --version
Report program version and exit.
-y Agree to anything asked.
--leaves
List leaf nodes in the local RPM database. Leaf nodes are RPMs that are not
relied upon by any other RPM.
--orphans
List installed packages which are not available from currently configured
repositories. This is identical to "yum list extras", which may provide better
output.
--oldkernels
Remove old kernel and kernel-devel packages.
--problems
List dependency problems in the local RPM database. If any problems are found
it will exit with an exit code of 1.
--dupes
Scan for duplicates in the local RPM database.
--cleandupes
Scan for duplicates in the local RPM database and clean out the older versions.
--removenewestdupes
Remove the newest dupes instead of the oldest dupes when cleaning duplicates.
--noscripts
Disable rpm scriptlets from running when cleaning duplicates.
--count <COUNT>
Number of duplicate/kernel packages to keep on the system (default 2)
LEAVES OPTIONS
--all When listing leaf nodes also list leaf nodes that are not libraries.
--leaf-regex
A package name that matches this regular expression will be considered a leaf.
--exclude-devel
When listing leaf nodes do not list development packages.
--exclude-bin
When listing leaf nodes do not list packages with files in bin directories.
OLDKERNELS OPTIONS
--keepdevel
Do not remove kernel-devel packages when removing kernels
EXAMPLES
List all dependency problems:
package-cleanup --problems
List all packages that are not in any Yum repository:
package-cleanup --orphans
Remove old kernels keeping 3 and leaving old kernel-devel packages installed:
package-cleanup --oldkernels --count=3 --keepdevel
List all leaf packages with no files in a bin directory whose name begins with either
'perl' or 'python':
package-cleanup --leaves --exclude-bin --leaf-regex="^(perl)|(python)"
FILES
As package-cleanup uses YUM libraries for retrieving all the information, it relies on
YUM configuration for its default values like which repositories to use. Consult YUM
documentation for details:
/etc/yum.conf
/etc/yum/repos.d/
/var/cache/yum/
SEE ALSO
yum.conf (5)
http://yum.baseurl.org/
AUTHORS
See the Authors file included with this program.
BUGS
There are of course no bugs, but should you find any, you should first consult the FAQ
section on http://yum.baseurl.org/wiki/Faq and if unsuccessful in finding a resolution
contact the mailing list: yum-devel@lists.baseurl.org. To file a bug use
http://bugzilla.redhat.com for Fedora/RHEL/Centos related bugs and
http://yum.baseurl.org/report for all other bugs.
Gijs Hollestelle 03 November 2005 package-cleanup(1)
|