linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Bhaskar Chowdhury <unixbhaskar@gmail.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	"J. Bruce Fields" <bfields@fieldses.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Michal Marek <michal.lkml@markovi.net>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system
Date: Mon, 18 Nov 2019 16:30:49 +0900	[thread overview]
Message-ID: <CAK7LNARhV9Zy20WRQmZRkcVLtWYT_LKjrpT_Pyx75auCp_veLg@mail.gmail.com> (raw)
In-Reply-To: <20191115152102.GA23525@Gentoo>

[-- Attachment #1: Type: text/plain, Size: 7311 bytes --]

On Sat, Nov 16, 2019 at 12:21 AM Bhaskar Chowdhury
<unixbhaskar@gmail.com> wrote:
>
> On 10:58 Fri 15 Nov 2019, Masahiro Yamada wrote:
> >On Sat, Nov 9, 2019 at 8:14 PM Bhaskar Chowdhury <unixbhaskar@gmail.com> wrote:
> >>
> >> On 16:25 Sat 09 Nov 2019, Masahiro Yamada wrote:
> >> >On Thu, Nov 7, 2019 at 7:39 AM Bhaskar Chowdhury <unixbhaskar@gmail.com> wrote:
> >> >>
> >> >> On 14:30 Wed 06 Nov 2019, J. Bruce Fields wrote:
> >> >> >On Wed, Nov 06, 2019 at 10:12:26AM +0530, Bhaskar Chowdhury wrote:
> >> >> >> On 23:31 Tue 05 Nov 2019, J. Bruce Fields wrote:
> >> >> >> >On Wed, Nov 06, 2019 at 11:53:28AM +0900, Masahiro Yamada wrote:
> >> >> >> >>BTW.
> >> >> >> >>Bruce,
> >> >> >> >>Does the current script expect RHEL or something?
> >> >> >> >>I do not see 'new-kernel-pkg' on my Ubuntu machine.
> >> >> >> >
> >> >> >> >I test on Fedora.  Looks like on recent Fedora that's only provided by
> >> >> >> >an rpm "grubby-deprecated", which is an inauspicious name....
> >> >> >> >
> >> >> >> >I think maybe you're supposed to use "grubby" itself now.  Do you have
> >> >> >> >that?
> >> >> >> >
> >> >> >> >>It would still work with 'new-kernel-pkg: command not found'
> >> >> >> >>warning.
> >> >> >> >>
> >> >> >> >>We could bypass it if we like.
> >> >> >> >>
> >> >> >> >>command -v new-kernel-pkg && new-kernel-pkg --remove $f
> >> >> >> >
> >> >> >> >Looks like it's what updates the grub configuration, which is probably a
> >> >> >> >nice thing to do if you can.
> >> >> >> >
> >> >> >> >--b.
> >> >> >>
> >> >> >> Bruce,
> >> >> >>
> >> >> >> Two things,
> >> >> >>
> >> >> >> If the system doesn't run grub , how the fallback policy???
> >> >> >>
> >> >> >> This binary "new-kernel-pkg" also missing in other systems too...I can
> >> >> >> confirm that... i.e gentoo,slackware,
> >> >> >>
> >> >> >> So , you are only targeting the rpm based system????
> >> >> >
> >> >> >It's just what I happen to use.  If someone wants to make it work
> >> >> >elsewhere that'd be great, as long as we don't break what already works.
> >> >> >
> >> >> >I think Debian uses grub2-mkconfig?  Might be OK for Fedora too, I
> >> >> >dunno.
> >> >> >
> >> >> >--b.
> >> >>
> >> >> Okay , thanks for the input. I was trying to write something in
> >> >> generalize way , that is why my code spins off.And if you see the
> >> >> subject line of my very first attempt to patch written was "removing
> >> >> old kernels and modules dir in selective way"... that was it.
> >> >>
> >> >> Now, there are plenty of distros around, not only rpm based one(yes I do
> >> >> agree that ,you wrote it while using and testing on it, but that is
> >> >> limited in nature),the broader user base might be using something else.
> >> >>
> >> >> we simply can not restrict it to certain packaging version or several
> >> >> packaging versions of selected distros. We are making and building this
> >> >> (worth an effort) to make it as generalized as possible.
> >> >>
> >> >> Importantly I was only thinking of people who put the stuff in standard
> >> >> places in the FSH and use it. I might be wrong.
> >> >>
> >> >> As I have said it before, I was no way trying to bypass your work ,but
> >> >> it seems very limited in nature to adopted. So trying to widen the
> >> >> spectrum.
> >> >>
> >> >> I am trying to incorporating both the pole, different kind user base in
> >> >> mind, like you , who don't like to be prompted for this operation and
> >> >> assuming things should go well, and you are right.
> >> >>
> >> >> On the other hand , I am kinda guy , sometime I need to know what is
> >> >> going on, so the prompting.
> >> >>
> >> >> Well, I have never taken into account about modifying the bootloader
> >> >> config by looking at your work. Had I been, I would have done it already
> >> >> and it would be extremely trivial in nature.
> >> >>
> >> >> Now, Grub, no doubt it's fantastic piece of software, but complexity
> >> >> is paramount with it. Don't you think so???  I HAVE NOTHING AGAINST
> >> >> GRUB!
> >> >>
> >> >> I have personally stops using it for years and using something very
> >> >> rudimentary and simple and useful. That is because I know what I am
> >> >> doing and my system well.
> >> >>
> >> >> Caveat emptor: that was me, not every one else in the wild. Grub is used
> >> >> by the most distro by default,everybody knows it,but certainly not the
> >> >> norm.
> >> >>
> >> >> I would love to give it a stab again and if you better people feel it is
> >> >> necessary, but I need some concrete understanding from you,Masahiro and
> >> >> Randy(who is helping me actively).
> >> >>
> >> >> Say, You people might come up ,
> >> >>
> >> >> We need these :
> >> >>
> >> >> a)
> >> >> b)
> >> >> c)
> >> >>
> >> >> and we don't need these:
> >> >>
> >> >> a)
> >> >> b)
> >> >> c)
> >> >>
> >> >>
> >> >> My two cents! kindly, flame me with your thoughts.
> >> >
> >> >
> >> >Honestly, I did not even know this script
> >> >before you submitted the patch.
> >> >
> >> :)
> >>
> >> >I prune stale kernel/modules with my own script,
> >> >and I guess people do similar to meet their demand.
> >> >
> >> I do the same.
> >>
> >> >I am not sure how many people are using this.
> >> Only people who look up in the kernel source scripts directory , nobody
> >> else for sure.
> >> >If somebody is passionate to improve this script
> >> >in a simple way, that is fine, but
> >> >I do not want to see messy code for covering various use-cases.
> >> Agreed. That is why need guideline from you people(You, Randy and Bruce
> >> needs to tell me clearly), like what I mentioned, we can do
> >> these and we can not do these. I am asking because you people have had more
> >> exposure ,so might come up with some valid points to build up.
> >> >
> >
> >We have two topics here.
> >
> >[1]  add the interactive option
> For that, my last patch stand , I have covered it in a sane way, please try that
> once more with options.Yes , you said, the modules directory should be
> pruned at once with kernel. But , every system keeps the modules
> directory in different names AFAIK. So, the explicitness of the calling.
> >[2]  do nice things for non-rpm systems
> Bruce's code cover the base for RPM based system , which can be applied
> to other similar distribution using that format.Provided I figure out
> the "unknown binary" in the code.
>
> I might add other packaging format distribution to cover. Those will
> append behind the existing code.
> >
> >
> >They should be done by separate patches.
> >
> Agreed. Moduler and clear.
> >I think [1] is easy to do in a few liners.
> >
> My last patch stand.AFAIK...let me know if you feel it should be done
> differently.
> >
> >For [2], I am not sure how well it goes
> >until I see an actual patch.


As I said before, your patch is replacing everything,
and breaking how it previously worked.

If you want to support the interactive mode,
what you need to do is quite simple -
1) check the command line option -i
2) if -i is given, show a prompt before the removal


It would be possible to do these
in smaller changes.
I attached a sample patch.






> That would be a undertaking to deal with the native packaging system for
> different distributions.
>
> >--
> >Best Regards
> >Masahiro Yamada
>
> Thanks,
> Bhaskar



-- 
Best Regards
Masahiro Yamada

[-- Attachment #2: prune-kernel.diff --]
[-- Type: text/x-patch, Size: 1148 bytes --]

diff --git a/scripts/prune-kernel b/scripts/prune-kernel
index e8aa940bc0a9..9091ee1125f5 100755
--- a/scripts/prune-kernel
+++ b/scripts/prune-kernel
@@ -5,6 +5,11 @@
 # again, /boot and /lib/modules/ eventually fill up.
 # Dumb script to purge that stuff:
 
+if [ "$1" = -i ]; then
+	interactive=y
+	shift
+fi
+
 for f in "$@"
 do
         if rpm -qf "/lib/modules/$f" >/dev/null; then
@@ -12,10 +17,20 @@ do
         elif [ $(uname -r) = "$f" ]; then
                 echo "keeping $f (running kernel) "
         else
-                echo "removing $f"
-                rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
-                rm -f "/boot/vmlinuz-$f"   "/boot/config-$f"
-                rm -rf "/lib/modules/$f"
-                new-kernel-pkg --remove $f
+		for g in $(ls -d /boot/initramfs-$f.img /boot/System.map-$f \
+			   /boot/vmlinuz-$f /boot/config-$f /lib/modules/$f \
+			   2>/dev/null)
+		do
+			if [ "$interactive" = y ]; then
+				printf "remove '$g'? "
+				read ans
+				if [ $ans != Y -a $ans != y ]; then
+					continue
+				fi
+			else
+				echo "removing '$g'"
+			fi
+			rm -rf $g
+		done
         fi
 done

  reply	other threads:[~2019-11-18  7:31 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-02  6:30 [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system Bhaskar Chowdhury
2019-11-05  2:03 ` Randy Dunlap
2019-11-05  2:32   ` J. Bruce Fields
2019-11-05  4:39     ` Bhaskar Chowdhury
2019-11-05  4:52       ` Bhaskar Chowdhury
2019-11-06  2:53     ` Masahiro Yamada
2019-11-06  3:10       ` Bhaskar Chowdhury
2019-11-06  4:03         ` Masahiro Yamada
2019-11-06  4:29           ` Bhaskar Chowdhury
2019-11-06  4:31       ` J. Bruce Fields
2019-11-06  4:32         ` Randy Dunlap
2019-11-06  4:42         ` Bhaskar Chowdhury
2019-11-06 19:30           ` J. Bruce Fields
2019-11-06 22:39             ` Bhaskar Chowdhury
2019-11-09  7:25               ` Masahiro Yamada
2019-11-09 11:13                 ` Bhaskar Chowdhury
2019-11-15  1:58                   ` Masahiro Yamada
2019-11-15 15:21                     ` Bhaskar Chowdhury
2019-11-18  7:30                       ` Masahiro Yamada [this message]
2019-11-05  4:33   ` Bhaskar Chowdhury
  -- strict thread matches above, loose matches on Subject: below --
2019-10-30  9:54 [PATCH] scripts: prune-kernel:remove " Bhaskar Chowdhury
2019-10-31  2:33 ` Randy Dunlap
2019-10-31  3:37   ` Bhaskar Chowdhury
2019-10-31  4:32     ` Randy Dunlap
2019-10-31  4:52       ` Bhaskar Chowdhury
2019-10-31  5:27         ` Randy Dunlap
2019-10-31  7:18           ` Bhaskar Chowdhury
2019-10-31 15:06             ` Randy Dunlap
2019-11-01  4:23               ` Bhaskar Chowdhury
2019-11-01  5:11                 ` Bhaskar Chowdhury
2019-11-01  5:45                   ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK7LNARhV9Zy20WRQmZRkcVLtWYT_LKjrpT_Pyx75auCp_veLg@mail.gmail.com \
    --to=yamada.masahiro@socionext.com \
    --cc=bfields@fieldses.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=rdunlap@infradead.org \
    --cc=unixbhaskar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).