How do I cleanup a boot partition that can't be cleaned up with package-cleanup?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I recently reinstalled CentOS 7 on a lab/development machine. I wanted to keep the /home partition from the previous installation, so I manually configured the partitioning to allow me to do that. In the process, I accidentally also kept the previous installation's /boot partition.



After installation was successful, I have a very busy Grub2 boot screen. In addition to my "new" clean CentOS install, all of my old kernel images appear in the boot screen:



CentOS Linux (3.10.0-693.11.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.5.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core) <--- this is the new/reinstalled OS
CentOS Linux (3.10.0-693.11.1.el7.x86_64.debug) 7 (Core)
CentOS Linux (0-rescue-7859fc0fbe934b91b11ea69046b5d787) 7 (Core)
CentOS Linux (0-rescue-6c92bef5457049e5a42e5609c540d753) 7 (Core)
CentOS Linux (0-rescue-e7a05dc4cdda4e778a344945ef1ed391) 7 (Core)


Simply running package-cleanup won't work, because there is really only one kernel installed (as far as the new OS is concerned):



$ package-cleanup --oldkernels --count=1
No old kernels to remove

$ uname -r
3.10.0-693.el7.x86_64

$ rpm -qa kernel*
kernel-debug-devel-3.10.0-693.11.6.el7.x86_64
kernel-3.10.0-693.el7.x86_64
kernel-headers-3.10.0-693.11.6.el7.x86_64
kernel-tools-libs-3.10.0-693.el7.x86_64
kernel-tools-3.10.0-693.el7.x86_64


Thus, I don't believe this is a dupe of regular "how do I clean up my /boot partition?" questions (such as How do I safely delete old kernel versions in CentOS 7?)



Normally I'd be fine with just dealing with a messy Grub2 menu, but my /boot partition only has 11 MiB left, so I'm unable to update my kernel.



I'm not sure what is safe to delete from the /boot partition. How do I clean it up when package-cleanup won't?







share|improve this question
















  • 1




    Assuming your reused the /boot partition instead of created a second partition?
    – jdwolf
    Jan 5 at 21:57






  • 1




    @jdwolf Correct. Sorry I didn’t make that clear.
    – scottbb
    Jan 5 at 21:59














up vote
0
down vote

favorite












I recently reinstalled CentOS 7 on a lab/development machine. I wanted to keep the /home partition from the previous installation, so I manually configured the partitioning to allow me to do that. In the process, I accidentally also kept the previous installation's /boot partition.



After installation was successful, I have a very busy Grub2 boot screen. In addition to my "new" clean CentOS install, all of my old kernel images appear in the boot screen:



CentOS Linux (3.10.0-693.11.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.5.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core) <--- this is the new/reinstalled OS
CentOS Linux (3.10.0-693.11.1.el7.x86_64.debug) 7 (Core)
CentOS Linux (0-rescue-7859fc0fbe934b91b11ea69046b5d787) 7 (Core)
CentOS Linux (0-rescue-6c92bef5457049e5a42e5609c540d753) 7 (Core)
CentOS Linux (0-rescue-e7a05dc4cdda4e778a344945ef1ed391) 7 (Core)


Simply running package-cleanup won't work, because there is really only one kernel installed (as far as the new OS is concerned):



$ package-cleanup --oldkernels --count=1
No old kernels to remove

$ uname -r
3.10.0-693.el7.x86_64

$ rpm -qa kernel*
kernel-debug-devel-3.10.0-693.11.6.el7.x86_64
kernel-3.10.0-693.el7.x86_64
kernel-headers-3.10.0-693.11.6.el7.x86_64
kernel-tools-libs-3.10.0-693.el7.x86_64
kernel-tools-3.10.0-693.el7.x86_64


Thus, I don't believe this is a dupe of regular "how do I clean up my /boot partition?" questions (such as How do I safely delete old kernel versions in CentOS 7?)



Normally I'd be fine with just dealing with a messy Grub2 menu, but my /boot partition only has 11 MiB left, so I'm unable to update my kernel.



I'm not sure what is safe to delete from the /boot partition. How do I clean it up when package-cleanup won't?







share|improve this question
















  • 1




    Assuming your reused the /boot partition instead of created a second partition?
    – jdwolf
    Jan 5 at 21:57






  • 1




    @jdwolf Correct. Sorry I didn’t make that clear.
    – scottbb
    Jan 5 at 21:59












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I recently reinstalled CentOS 7 on a lab/development machine. I wanted to keep the /home partition from the previous installation, so I manually configured the partitioning to allow me to do that. In the process, I accidentally also kept the previous installation's /boot partition.



After installation was successful, I have a very busy Grub2 boot screen. In addition to my "new" clean CentOS install, all of my old kernel images appear in the boot screen:



CentOS Linux (3.10.0-693.11.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.5.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core) <--- this is the new/reinstalled OS
CentOS Linux (3.10.0-693.11.1.el7.x86_64.debug) 7 (Core)
CentOS Linux (0-rescue-7859fc0fbe934b91b11ea69046b5d787) 7 (Core)
CentOS Linux (0-rescue-6c92bef5457049e5a42e5609c540d753) 7 (Core)
CentOS Linux (0-rescue-e7a05dc4cdda4e778a344945ef1ed391) 7 (Core)


Simply running package-cleanup won't work, because there is really only one kernel installed (as far as the new OS is concerned):



$ package-cleanup --oldkernels --count=1
No old kernels to remove

$ uname -r
3.10.0-693.el7.x86_64

$ rpm -qa kernel*
kernel-debug-devel-3.10.0-693.11.6.el7.x86_64
kernel-3.10.0-693.el7.x86_64
kernel-headers-3.10.0-693.11.6.el7.x86_64
kernel-tools-libs-3.10.0-693.el7.x86_64
kernel-tools-3.10.0-693.el7.x86_64


Thus, I don't believe this is a dupe of regular "how do I clean up my /boot partition?" questions (such as How do I safely delete old kernel versions in CentOS 7?)



Normally I'd be fine with just dealing with a messy Grub2 menu, but my /boot partition only has 11 MiB left, so I'm unable to update my kernel.



I'm not sure what is safe to delete from the /boot partition. How do I clean it up when package-cleanup won't?







share|improve this question












I recently reinstalled CentOS 7 on a lab/development machine. I wanted to keep the /home partition from the previous installation, so I manually configured the partitioning to allow me to do that. In the process, I accidentally also kept the previous installation's /boot partition.



After installation was successful, I have a very busy Grub2 boot screen. In addition to my "new" clean CentOS install, all of my old kernel images appear in the boot screen:



CentOS Linux (3.10.0-693.11.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.5.2.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core) <--- this is the new/reinstalled OS
CentOS Linux (3.10.0-693.11.1.el7.x86_64.debug) 7 (Core)
CentOS Linux (0-rescue-7859fc0fbe934b91b11ea69046b5d787) 7 (Core)
CentOS Linux (0-rescue-6c92bef5457049e5a42e5609c540d753) 7 (Core)
CentOS Linux (0-rescue-e7a05dc4cdda4e778a344945ef1ed391) 7 (Core)


Simply running package-cleanup won't work, because there is really only one kernel installed (as far as the new OS is concerned):



$ package-cleanup --oldkernels --count=1
No old kernels to remove

$ uname -r
3.10.0-693.el7.x86_64

$ rpm -qa kernel*
kernel-debug-devel-3.10.0-693.11.6.el7.x86_64
kernel-3.10.0-693.el7.x86_64
kernel-headers-3.10.0-693.11.6.el7.x86_64
kernel-tools-libs-3.10.0-693.el7.x86_64
kernel-tools-3.10.0-693.el7.x86_64


Thus, I don't believe this is a dupe of regular "how do I clean up my /boot partition?" questions (such as How do I safely delete old kernel versions in CentOS 7?)



Normally I'd be fine with just dealing with a messy Grub2 menu, but my /boot partition only has 11 MiB left, so I'm unable to update my kernel.



I'm not sure what is safe to delete from the /boot partition. How do I clean it up when package-cleanup won't?









share|improve this question











share|improve this question




share|improve this question










asked Jan 5 at 21:48









scottbb

22817




22817







  • 1




    Assuming your reused the /boot partition instead of created a second partition?
    – jdwolf
    Jan 5 at 21:57






  • 1




    @jdwolf Correct. Sorry I didn’t make that clear.
    – scottbb
    Jan 5 at 21:59












  • 1




    Assuming your reused the /boot partition instead of created a second partition?
    – jdwolf
    Jan 5 at 21:57






  • 1




    @jdwolf Correct. Sorry I didn’t make that clear.
    – scottbb
    Jan 5 at 21:59







1




1




Assuming your reused the /boot partition instead of created a second partition?
– jdwolf
Jan 5 at 21:57




Assuming your reused the /boot partition instead of created a second partition?
– jdwolf
Jan 5 at 21:57




1




1




@jdwolf Correct. Sorry I didn’t make that clear.
– scottbb
Jan 5 at 21:59




@jdwolf Correct. Sorry I didn’t make that clear.
– scottbb
Jan 5 at 21:59










2 Answers
2






active

oldest

votes

















up vote
2
down vote













You can use yum whatprovides /boot/* to determine which kernels are still installed and ones that are not owned by a package you can safely delete. However this assumes grub is being autoconfigured.






share|improve this answer
















  • 1




    I'm not sure how you recreate the initrd on CentOS. But basically you can delete those and regenerate the latest one however you do it on CentOS.
    – jdwolf
    Jan 5 at 22:05


















up vote
2
down vote













jdwolf's answer produced a listing of which packages (on the old system) that provided the entries in /boot/*, but it was a bit voluminous, and not immediately apparent what files were not pertinent to my reinstall of CentOS. And example of some of the output:



$ yum whatprovides /boot/*

kernel-3.10.0-693.5.2.el7.x86_64 : The Linux kernel
Repo : updates
Matched from:
Filename : /boot/config-3.10.0-693.5.2.el7.x86_64

kernel-3.10.0-693.el7.x86_64 : The Linux kernel
Repo : base
Matched from:
Filename : /boot/config-3.10.0-693.el7.x86_64

fwupdate-efi-9-8.el7.x86_64 : UEFI binaries used by libfwup
Repo : base
Matched from:
Filename : /boot/efi

[... truncated output ...]


But that led me to use rpm -q --whatprovides /boot/* instead, which was much more useful to determine if the file was needed:



$ rpm -q --whatprovides /boot/*
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
file /boot/elf-memtest86+-5.01 is not owned by any package
file /boot/grub is not owned by any package
grub2-common-2.02-0.65.el7.centos.2.noarch
[... truncated output ...]


Note that rpm -q --whatprovides doesn't print the name of the input file if it matches a package that provides it. But it does return 0 if the file is provided by a package, and 1 if the file is not provided by a package. Thus, solution was trivially:



$ for f in /boot/*; do rpm -q --whatprovides $f || rm -f $f; done
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
rm: cannot remove ‘/boot/efi’: Is a directory
file /boot/elf-memtest86+-5.01 is not owned by any package
[... truncated output ...]

$ ls -1 /boot
config-3.10.0-693.el7.x86_64
efi
grub
grub2
initramfs-3.10.0-693.el7.x86_64.img
symvers-3.10.0-693.el7.x86_64.gz
System.map-3.10.0-693.el7.x86_64
vmlinuz-3.10.0-693.el7.x86_64


After running grub2-mkconfig -o /boot/grub2/grub.cfg, my Grub menu is clean, and I have a clean /boot directory.



Note: It would probably have been better or safer to use find /boot -type f -exec ... (or perhaps find ... -xargs ...), but my solution worked fine enough since rm -f doesn't delete directories.






share|improve this answer
















  • 1




    You made your /boot beautiful again :> Even if you borked the whole directory it should only be a matter of reinstalling linux package, generating initrd, installing grub and making grub config.
    – jdwolf
    Jan 5 at 23:24











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f415097%2fhow-do-i-cleanup-a-boot-partition-that-cant-be-cleaned-up-with-package-cleanup%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote













You can use yum whatprovides /boot/* to determine which kernels are still installed and ones that are not owned by a package you can safely delete. However this assumes grub is being autoconfigured.






share|improve this answer
















  • 1




    I'm not sure how you recreate the initrd on CentOS. But basically you can delete those and regenerate the latest one however you do it on CentOS.
    – jdwolf
    Jan 5 at 22:05















up vote
2
down vote













You can use yum whatprovides /boot/* to determine which kernels are still installed and ones that are not owned by a package you can safely delete. However this assumes grub is being autoconfigured.






share|improve this answer
















  • 1




    I'm not sure how you recreate the initrd on CentOS. But basically you can delete those and regenerate the latest one however you do it on CentOS.
    – jdwolf
    Jan 5 at 22:05













up vote
2
down vote










up vote
2
down vote









You can use yum whatprovides /boot/* to determine which kernels are still installed and ones that are not owned by a package you can safely delete. However this assumes grub is being autoconfigured.






share|improve this answer












You can use yum whatprovides /boot/* to determine which kernels are still installed and ones that are not owned by a package you can safely delete. However this assumes grub is being autoconfigured.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 5 at 22:00









jdwolf

2,392116




2,392116







  • 1




    I'm not sure how you recreate the initrd on CentOS. But basically you can delete those and regenerate the latest one however you do it on CentOS.
    – jdwolf
    Jan 5 at 22:05













  • 1




    I'm not sure how you recreate the initrd on CentOS. But basically you can delete those and regenerate the latest one however you do it on CentOS.
    – jdwolf
    Jan 5 at 22:05








1




1




I'm not sure how you recreate the initrd on CentOS. But basically you can delete those and regenerate the latest one however you do it on CentOS.
– jdwolf
Jan 5 at 22:05





I'm not sure how you recreate the initrd on CentOS. But basically you can delete those and regenerate the latest one however you do it on CentOS.
– jdwolf
Jan 5 at 22:05













up vote
2
down vote













jdwolf's answer produced a listing of which packages (on the old system) that provided the entries in /boot/*, but it was a bit voluminous, and not immediately apparent what files were not pertinent to my reinstall of CentOS. And example of some of the output:



$ yum whatprovides /boot/*

kernel-3.10.0-693.5.2.el7.x86_64 : The Linux kernel
Repo : updates
Matched from:
Filename : /boot/config-3.10.0-693.5.2.el7.x86_64

kernel-3.10.0-693.el7.x86_64 : The Linux kernel
Repo : base
Matched from:
Filename : /boot/config-3.10.0-693.el7.x86_64

fwupdate-efi-9-8.el7.x86_64 : UEFI binaries used by libfwup
Repo : base
Matched from:
Filename : /boot/efi

[... truncated output ...]


But that led me to use rpm -q --whatprovides /boot/* instead, which was much more useful to determine if the file was needed:



$ rpm -q --whatprovides /boot/*
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
file /boot/elf-memtest86+-5.01 is not owned by any package
file /boot/grub is not owned by any package
grub2-common-2.02-0.65.el7.centos.2.noarch
[... truncated output ...]


Note that rpm -q --whatprovides doesn't print the name of the input file if it matches a package that provides it. But it does return 0 if the file is provided by a package, and 1 if the file is not provided by a package. Thus, solution was trivially:



$ for f in /boot/*; do rpm -q --whatprovides $f || rm -f $f; done
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
rm: cannot remove ‘/boot/efi’: Is a directory
file /boot/elf-memtest86+-5.01 is not owned by any package
[... truncated output ...]

$ ls -1 /boot
config-3.10.0-693.el7.x86_64
efi
grub
grub2
initramfs-3.10.0-693.el7.x86_64.img
symvers-3.10.0-693.el7.x86_64.gz
System.map-3.10.0-693.el7.x86_64
vmlinuz-3.10.0-693.el7.x86_64


After running grub2-mkconfig -o /boot/grub2/grub.cfg, my Grub menu is clean, and I have a clean /boot directory.



Note: It would probably have been better or safer to use find /boot -type f -exec ... (or perhaps find ... -xargs ...), but my solution worked fine enough since rm -f doesn't delete directories.






share|improve this answer
















  • 1




    You made your /boot beautiful again :> Even if you borked the whole directory it should only be a matter of reinstalling linux package, generating initrd, installing grub and making grub config.
    – jdwolf
    Jan 5 at 23:24















up vote
2
down vote













jdwolf's answer produced a listing of which packages (on the old system) that provided the entries in /boot/*, but it was a bit voluminous, and not immediately apparent what files were not pertinent to my reinstall of CentOS. And example of some of the output:



$ yum whatprovides /boot/*

kernel-3.10.0-693.5.2.el7.x86_64 : The Linux kernel
Repo : updates
Matched from:
Filename : /boot/config-3.10.0-693.5.2.el7.x86_64

kernel-3.10.0-693.el7.x86_64 : The Linux kernel
Repo : base
Matched from:
Filename : /boot/config-3.10.0-693.el7.x86_64

fwupdate-efi-9-8.el7.x86_64 : UEFI binaries used by libfwup
Repo : base
Matched from:
Filename : /boot/efi

[... truncated output ...]


But that led me to use rpm -q --whatprovides /boot/* instead, which was much more useful to determine if the file was needed:



$ rpm -q --whatprovides /boot/*
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
file /boot/elf-memtest86+-5.01 is not owned by any package
file /boot/grub is not owned by any package
grub2-common-2.02-0.65.el7.centos.2.noarch
[... truncated output ...]


Note that rpm -q --whatprovides doesn't print the name of the input file if it matches a package that provides it. But it does return 0 if the file is provided by a package, and 1 if the file is not provided by a package. Thus, solution was trivially:



$ for f in /boot/*; do rpm -q --whatprovides $f || rm -f $f; done
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
rm: cannot remove ‘/boot/efi’: Is a directory
file /boot/elf-memtest86+-5.01 is not owned by any package
[... truncated output ...]

$ ls -1 /boot
config-3.10.0-693.el7.x86_64
efi
grub
grub2
initramfs-3.10.0-693.el7.x86_64.img
symvers-3.10.0-693.el7.x86_64.gz
System.map-3.10.0-693.el7.x86_64
vmlinuz-3.10.0-693.el7.x86_64


After running grub2-mkconfig -o /boot/grub2/grub.cfg, my Grub menu is clean, and I have a clean /boot directory.



Note: It would probably have been better or safer to use find /boot -type f -exec ... (or perhaps find ... -xargs ...), but my solution worked fine enough since rm -f doesn't delete directories.






share|improve this answer
















  • 1




    You made your /boot beautiful again :> Even if you borked the whole directory it should only be a matter of reinstalling linux package, generating initrd, installing grub and making grub config.
    – jdwolf
    Jan 5 at 23:24













up vote
2
down vote










up vote
2
down vote









jdwolf's answer produced a listing of which packages (on the old system) that provided the entries in /boot/*, but it was a bit voluminous, and not immediately apparent what files were not pertinent to my reinstall of CentOS. And example of some of the output:



$ yum whatprovides /boot/*

kernel-3.10.0-693.5.2.el7.x86_64 : The Linux kernel
Repo : updates
Matched from:
Filename : /boot/config-3.10.0-693.5.2.el7.x86_64

kernel-3.10.0-693.el7.x86_64 : The Linux kernel
Repo : base
Matched from:
Filename : /boot/config-3.10.0-693.el7.x86_64

fwupdate-efi-9-8.el7.x86_64 : UEFI binaries used by libfwup
Repo : base
Matched from:
Filename : /boot/efi

[... truncated output ...]


But that led me to use rpm -q --whatprovides /boot/* instead, which was much more useful to determine if the file was needed:



$ rpm -q --whatprovides /boot/*
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
file /boot/elf-memtest86+-5.01 is not owned by any package
file /boot/grub is not owned by any package
grub2-common-2.02-0.65.el7.centos.2.noarch
[... truncated output ...]


Note that rpm -q --whatprovides doesn't print the name of the input file if it matches a package that provides it. But it does return 0 if the file is provided by a package, and 1 if the file is not provided by a package. Thus, solution was trivially:



$ for f in /boot/*; do rpm -q --whatprovides $f || rm -f $f; done
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
rm: cannot remove ‘/boot/efi’: Is a directory
file /boot/elf-memtest86+-5.01 is not owned by any package
[... truncated output ...]

$ ls -1 /boot
config-3.10.0-693.el7.x86_64
efi
grub
grub2
initramfs-3.10.0-693.el7.x86_64.img
symvers-3.10.0-693.el7.x86_64.gz
System.map-3.10.0-693.el7.x86_64
vmlinuz-3.10.0-693.el7.x86_64


After running grub2-mkconfig -o /boot/grub2/grub.cfg, my Grub menu is clean, and I have a clean /boot directory.



Note: It would probably have been better or safer to use find /boot -type f -exec ... (or perhaps find ... -xargs ...), but my solution worked fine enough since rm -f doesn't delete directories.






share|improve this answer












jdwolf's answer produced a listing of which packages (on the old system) that provided the entries in /boot/*, but it was a bit voluminous, and not immediately apparent what files were not pertinent to my reinstall of CentOS. And example of some of the output:



$ yum whatprovides /boot/*

kernel-3.10.0-693.5.2.el7.x86_64 : The Linux kernel
Repo : updates
Matched from:
Filename : /boot/config-3.10.0-693.5.2.el7.x86_64

kernel-3.10.0-693.el7.x86_64 : The Linux kernel
Repo : base
Matched from:
Filename : /boot/config-3.10.0-693.el7.x86_64

fwupdate-efi-9-8.el7.x86_64 : UEFI binaries used by libfwup
Repo : base
Matched from:
Filename : /boot/efi

[... truncated output ...]


But that led me to use rpm -q --whatprovides /boot/* instead, which was much more useful to determine if the file was needed:



$ rpm -q --whatprovides /boot/*
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
file /boot/elf-memtest86+-5.01 is not owned by any package
file /boot/grub is not owned by any package
grub2-common-2.02-0.65.el7.centos.2.noarch
[... truncated output ...]


Note that rpm -q --whatprovides doesn't print the name of the input file if it matches a package that provides it. But it does return 0 if the file is provided by a package, and 1 if the file is not provided by a package. Thus, solution was trivially:



$ for f in /boot/*; do rpm -q --whatprovides $f || rm -f $f; done
file /boot/config-3.10.0-693.11.1.el7.x86_64 is not owned by any package
file /boot/config-3.10.0-693.11.1.el7.x86_64.debug is not owned by any package
file /boot/config-3.10.0-693.5.2.el7.x86_64 is not owned by any package
kernel-3.10.0-693.el7.x86_64
file /boot/efi is not owned by any package
rm: cannot remove ‘/boot/efi’: Is a directory
file /boot/elf-memtest86+-5.01 is not owned by any package
[... truncated output ...]

$ ls -1 /boot
config-3.10.0-693.el7.x86_64
efi
grub
grub2
initramfs-3.10.0-693.el7.x86_64.img
symvers-3.10.0-693.el7.x86_64.gz
System.map-3.10.0-693.el7.x86_64
vmlinuz-3.10.0-693.el7.x86_64


After running grub2-mkconfig -o /boot/grub2/grub.cfg, my Grub menu is clean, and I have a clean /boot directory.



Note: It would probably have been better or safer to use find /boot -type f -exec ... (or perhaps find ... -xargs ...), but my solution worked fine enough since rm -f doesn't delete directories.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 5 at 23:20









scottbb

22817




22817







  • 1




    You made your /boot beautiful again :> Even if you borked the whole directory it should only be a matter of reinstalling linux package, generating initrd, installing grub and making grub config.
    – jdwolf
    Jan 5 at 23:24













  • 1




    You made your /boot beautiful again :> Even if you borked the whole directory it should only be a matter of reinstalling linux package, generating initrd, installing grub and making grub config.
    – jdwolf
    Jan 5 at 23:24








1




1




You made your /boot beautiful again :> Even if you borked the whole directory it should only be a matter of reinstalling linux package, generating initrd, installing grub and making grub config.
– jdwolf
Jan 5 at 23:24





You made your /boot beautiful again :> Even if you borked the whole directory it should only be a matter of reinstalling linux package, generating initrd, installing grub and making grub config.
– jdwolf
Jan 5 at 23:24













 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f415097%2fhow-do-i-cleanup-a-boot-partition-that-cant-be-cleaned-up-with-package-cleanup%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)