On 28 Aug 2023 at 18:37, ToddAndMargo via users wrote: Date sent: Mon, 28 Aug 2023 18:37:11 -0700 To: Community support for Fedora users <users@xxxxxxxxxxxxxxxxxxxxxxx> Subject: /usr/lib/modules cleanup? Send reply to: Community support for Fedora users <users@xxxxxxxxxxxxxxxxxxxxxxx> From: ToddAndMargo via users <users@xxxxxxxxxxxxxxxxxxxxxxx> Copies to: ToddAndMargo <ToddAndMargo@xxxxxxxx> > Hi All, > > Fedora 38 > > I got stuff all the way back to fc31. > > Can I delete all the non fc38 directories? > Can't say sure, but what I have done on my machines. I generally use /lib/modules that is link t /usr/lib/modules. Generally found that only 3 of the directories are actually valid linked to the 3 latest kernels. The other ones are generally much smaller and just left offer stuff that somehow stopped the automatic removal from working. Have a script cleanmodules2 #!/bin/bash x=$(du . -d 1 | sort -n|grep -v "[0-9][0-9][0-9][0-9][0-9][0-9]" | cut -s -f2 -d/) for a in $x; do echo "$a"; rm ./"$a"/* -f -r; rmdir "$a"; done But would recommend running it without the rm and rmdir lines to make sure it isn't going to remove anything that is valid first. Example of results I get. Current directory is already clean so nothing removed. du . -d 1 | sort -n 128640 ./6.4.11-100.fc37.x86_64 128652 ./6.4.12-100.fc37.x86_64 128668 ./6.4.10-100.fc37.x86_64 385968 . Generally old directories would have sizes smaller that 6 digits, grep -v "[0-9][0-9][0-9][0-9][0-9][0-9]" filters out all directories with 6 digits or more for size. cut -s elimanates the last line that doesn't have a second field after the / The loop then processes each of the resulting directories to remove the files and then remove directory. That has worked for me, but you setup might be different. Might be way to validate against kernel files in /boot or entries in /boot/local/entries but this works for me. getting the ones to keep ls -1 /boot | grep vmlinuz | grep -v rescue |cut -b9-100 or ls -1 /boot/loader/entries/ | grep x86_64 | cut -f2,3 -d- | sed 's/.conf//g' Both give me 6.4.10-100.fc37.x86_64 6.4.11-100.fc37.x86_64 6.4.12-100.fc37.x86_64 Would have to think about how to have it delete everything but thoses?? Good Luck. Perhaps someone else has a better process. > Many thanks, > -T > > > # cd /usr/lib/modules > # ls > 5.14.16-201.fc34.x86_64 > 5.18.10-200.fc36.x86_64 > 6.2.9-200.fc37.x86_64 > 5.14.16-301.fc35.x86_64 > 5.5.17-200.fc31.x86_64 > 6.3.11-200.fc38.x86_64 > 5.14.18-300.fc35.x86_64 > 5.6.6-200.fc31.x86_64 > 6.3.12-100.fc37.x86_64 > 5.14.9-200.fc34.x86_64 > 5.6.7-200.fc31.x86_64 > 6.3.12-200.fc38.x86_64 > 5.15.10-200.fc35.x86_64 > 6.0.11-300.fc37.x86_64 > 6.3.7-100.fc37.x86_64 > 5.15.16-200.fc35.x86_64 > 6.0.12-200.fc36.x86_64 > 6.3.8-100.fc37.x86_64 > 5.15.18-200.fc35.x86_64 > 6.2.10-200.fc37.x86_64 > 6.4.10-200.fc38.x86_64 > 5.15.4-201.fc35.x86_64 > 6.2.12-200.fc37.x86_64 > 6.4.11-200.fc38.x86_64 > 5.15.6-200.fc35.x86_64 > 6.2.13-200.fc37.x86_64 > 6.4.12-200.fc38.x86_64 > 5.16.8-200.fc35.x86_64 > 6.2.15-200.fc37.x86_64 > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Computers are like air conditioners. > They malfunction when you open windows > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > _______________________________________________ > users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx > To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx > Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines > List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx > Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue +------------------------------------------------------------+ Michael D. Setzer II - Computer Science Instructor (Retired) mailto:mikes@xxxxxxxx mailto:msetzerii@xxxxxxxxx Guam - Where America's Day Begins G4L Disk Imaging Project maintainer http://sourceforge.net/projects/g4l/ +------------------------------------------------------------+ _______________________________________________ users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue