-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleankernel
More file actions
executable file
·43 lines (34 loc) · 1.06 KB
/
Copy pathcleankernel
File metadata and controls
executable file
·43 lines (34 loc) · 1.06 KB
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
#!/usr/bin/env python
# Cleankernel 0.1 - display a list of files and directories that belong
# to old unused kernels
#
# Copyright 2008 Erik Hahn
#
# WARNING: Don't trust this script, always check it's output before
# you delete anything.
import os
from os import path
# Build the list of kernels to be kept
os.chdir("/boot")
keep = [ s.replace("vmlinuz-","") for s in [
path.basename(path.realpath("vmlinuz")),
path.basename(path.realpath("vmlinuz.old")),
path.basename(path.realpath("vmlinuz.boots"))
]
]
# Create the list of vmlinuz/System.map/config files in /boot to be kept
keep_in_boot=[]
for f in os.listdir("."):
for k in keep:
if f.count(k) != 0:
keep_in_boot.append(f)
for f in os.listdir("."):
if not keep_in_boot.count(f) and (f.count("vmlinuz-") or
f.count("config-") or f.count("System.map-")):
print path.realpath(f)
# Purge old module dirs
keep = [ s.replace("-dirty","") for s in keep ]
os.chdir("/lib/modules")
for d in os.listdir("."):
if not keep.count(d):
print path.realpath(d)