* [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system @ 2019-11-02 6:30 Bhaskar Chowdhury 2019-11-05 2:03 ` Randy Dunlap 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-02 6:30 UTC (permalink / raw) To: rdunlap Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel, Bhaskar Chowdhury This patch allow you to remove old kernels and associated modules directory from the system.You can do it at once with the -r flag and interactively with the -i flag. Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> --- scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 17 deletions(-) diff --git a/scripts/prune-kernel b/scripts/prune-kernel index e8aa940bc0a9..01d0778db71f 100755 --- a/scripts/prune-kernel +++ b/scripts/prune-kernel @@ -1,21 +1,69 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +#This script will remove old kernels and modules directory related to it. +#"-r" or "--remove" show how to silently remove old kernel and modules dir. +# "-h" or "--help" show how to use this script or show without parameter. +#"-i" or "--interactive" show how to remove interactively. + +flag=$1 +kernel_version=$2 +modules_version=$3 +boot_dir=/boot +modules_dir=/lib/modules + +remove_old_kernel() { + cd $boot_dir + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version + return 0 +} + +remove_old_modules_dir() { + cd $modules_dir + rm -rf $modules_version + return 0 +} + +usage() { + printf "Usage: $(basename $0) [-ri]\n" + printf "\n -r or --remove kernel_version modules_version\n" + printf "\n -i or --interactive do as interactive way\n" + return 0 +} + +case "$flag" in + -i | --interactive) + printf "\nEnter kernel version to remove or blank/empty to exit:" + read kernel_version + if [[ $kernel_version != "" ]]; then + remove_old_kernel + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" + printf "Please give the full modules directory name to remove:" + read modules_version + if [[ $modules_version != "" ]]; then + remove_old_modules_dir + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" + else + exit 1 + fi + fi + ;; + -h | --help) + usage + exit 0 + ;; + -r | --remove) + if [[ $# -ne 3 ]]; then + printf "You need to provide kernel version and modules directory name.\n" + exit 1 + else + remove_old_kernel + remove_old_modules_dir + fi + ;; + *) + usage + exit 1 + ;; +esac -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and -# again, /boot and /lib/modules/ eventually fill up. -# Dumb script to purge that stuff: -for f in "$@" -do - if rpm -qf "/lib/modules/$f" >/dev/null; then - echo "keeping $f (installed from rpm)" - 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 - fi -done -- 2.23.0 ^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 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:33 ` Bhaskar Chowdhury 0 siblings, 2 replies; 31+ messages in thread From: Randy Dunlap @ 2019-11-05 2:03 UTC (permalink / raw) To: Bhaskar Chowdhury Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: > This patch allow you to remove old kernels and associated modules > directory from the system.You can do it at once with the -r flag > and interactively with the -i flag. > > Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> > --- > scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- > 1 file changed, 65 insertions(+), 17 deletions(-) Hi, I believe that this script now does what the patch author intends it to do. It does have a few whitespace issues, but no big deals. (see below) Tested-by: Randy Dunlap <rdunlap@infradead.org> > diff --git a/scripts/prune-kernel b/scripts/prune-kernel > index e8aa940bc0a9..01d0778db71f 100755 > --- a/scripts/prune-kernel > +++ b/scripts/prune-kernel > @@ -1,21 +1,69 @@ > #!/bin/bash > # SPDX-License-Identifier: GPL-2.0 > +#This script will remove old kernels and modules directory related to it. > +#"-r" or "--remove" show how to silently remove old kernel and modules dir. > +# "-h" or "--help" show how to use this script or show without parameter. > +#"-i" or "--interactive" show how to remove interactively. > + > +flag=$1 > +kernel_version=$2 > +modules_version=$3 > +boot_dir=/boot > +modules_dir=/lib/modules > + > +remove_old_kernel() { > + cd $boot_dir > + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version > + return 0 > +} > + > +remove_old_modules_dir() { > + cd $modules_dir > + rm -rf $modules_version > + return 0 > +} > + > +usage() { > + printf "Usage: $(basename $0) [-ri]\n" > + printf "\n -r or --remove kernel_version modules_version\n" > + printf "\n -i or --interactive do as interactive way\n" > + return 0 > +} > + > +case "$flag" in > + -i | --interactive) > + printf "\nEnter kernel version to remove or blank/empty to exit:" > + read kernel_version > + if [[ $kernel_version != "" ]]; then > + remove_old_kernel > + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" space after ':' drop one \n above. > + printf "Please give the full modules directory name to remove:" > + read modules_version > + if [[ $modules_version != "" ]]; then > + remove_old_modules_dir > + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" space after ':' drop one \n above. > + else > + exit 1 > + fi > + fi > + ;; > + -h | --help) > + usage > + exit 0 > + ;; > + -r | --remove) > + if [[ $# -ne 3 ]]; then > + printf "You need to provide kernel version and modules directory name.\n" > + exit 1 > + else > + remove_old_kernel > + remove_old_modules_dir > + fi > + ;; > + *) > + usage > + exit 1 > + ;; > +esac > > -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and > -# again, /boot and /lib/modules/ eventually fill up. > -# Dumb script to purge that stuff: > OK, the former script's loop is removed.. good. But the 2 preceding blank lines are not removed, so the script now ends with 2 unnecessary blank lines. > -for f in "$@" > -do > - if rpm -qf "/lib/modules/$f" >/dev/null; then > - echo "keeping $f (installed from rpm)" > - 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 > - fi > -done > -- -- ~Randy ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-05 2:03 ` Randy Dunlap @ 2019-11-05 2:32 ` J. Bruce Fields 2019-11-05 4:39 ` Bhaskar Chowdhury 2019-11-06 2:53 ` Masahiro Yamada 2019-11-05 4:33 ` Bhaskar Chowdhury 1 sibling, 2 replies; 31+ messages in thread From: J. Bruce Fields @ 2019-11-05 2:32 UTC (permalink / raw) To: Randy Dunlap Cc: Bhaskar Chowdhury, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel On Mon, Nov 04, 2019 at 06:03:13PM -0800, Randy Dunlap wrote: > On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: > > This patch allow you to remove old kernels and associated modules > > directory from the system.You can do it at once with the -r flag > > and interactively with the -i flag. > > > > Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> > > --- > > scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- > > 1 file changed, 65 insertions(+), 17 deletions(-) > > Hi, > I believe that this script now does what the patch author intends it to do. > It does have a few whitespace issues, but no big deals. (see below) My original comment stands: looks like it prompts for full module path and kernel versions which means it's no more convenient than just doing an "ls" and then removing the ones you want to. (In fact, with "rm" you'd also get the benefit of tab completion....) It's quite different from the original script and I don't really see the advantage. --b. > > Tested-by: Randy Dunlap <rdunlap@infradead.org> > > > > diff --git a/scripts/prune-kernel b/scripts/prune-kernel > > index e8aa940bc0a9..01d0778db71f 100755 > > --- a/scripts/prune-kernel > > +++ b/scripts/prune-kernel > > @@ -1,21 +1,69 @@ > > #!/bin/bash > > # SPDX-License-Identifier: GPL-2.0 > > +#This script will remove old kernels and modules directory related to it. > > +#"-r" or "--remove" show how to silently remove old kernel and modules dir. > > +# "-h" or "--help" show how to use this script or show without parameter. > > +#"-i" or "--interactive" show how to remove interactively. > > + > > +flag=$1 > > +kernel_version=$2 > > +modules_version=$3 > > +boot_dir=/boot > > +modules_dir=/lib/modules > > + > > +remove_old_kernel() { > > + cd $boot_dir > > + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version > > + return 0 > > +} > > + > > +remove_old_modules_dir() { > > + cd $modules_dir > > + rm -rf $modules_version > > + return 0 > > +} > > + > > +usage() { > > + printf "Usage: $(basename $0) [-ri]\n" > > + printf "\n -r or --remove kernel_version modules_version\n" > > + printf "\n -i or --interactive do as interactive way\n" > > + return 0 > > +} > > + > > +case "$flag" in > > + -i | --interactive) > > + printf "\nEnter kernel version to remove or blank/empty to exit:" > > + read kernel_version > > + if [[ $kernel_version != "" ]]; then > > + remove_old_kernel > > + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" > > space after ':' > > drop one \n above. > > > + printf "Please give the full modules directory name to remove:" > > + read modules_version > > + if [[ $modules_version != "" ]]; then > > + remove_old_modules_dir > > + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" > > space after ':' > > drop one \n above. > > > + else > > + exit 1 > > + fi > > + fi > > + ;; > > + -h | --help) > > + usage > > + exit 0 > > + ;; > > + -r | --remove) > > + if [[ $# -ne 3 ]]; then > > + printf "You need to provide kernel version and modules directory name.\n" > > + exit 1 > > + else > > + remove_old_kernel > > + remove_old_modules_dir > > + fi > > + ;; > > + *) > > + usage > > + exit 1 > > + ;; > > +esac > > > > -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and > > -# again, /boot and /lib/modules/ eventually fill up. > > -# Dumb script to purge that stuff: > > > > OK, the former script's loop is removed.. good. > But the 2 preceding blank lines are not removed, so the script > now ends with 2 unnecessary blank lines. > > > -for f in "$@" > > -do > > - if rpm -qf "/lib/modules/$f" >/dev/null; then > > - echo "keeping $f (installed from rpm)" > > - 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 > > - fi > > -done > > -- > > > -- > ~Randy ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 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 1 sibling, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-05 4:39 UTC (permalink / raw) To: J. Bruce Fields Cc: Randy Dunlap, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel [-- Attachment #1: Type: text/plain, Size: 4948 bytes --] On 21:32 Mon 04 Nov 2019, J. Bruce Fields wrote: >On Mon, Nov 04, 2019 at 06:03:13PM -0800, Randy Dunlap wrote: >> On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: >> > This patch allow you to remove old kernels and associated modules >> > directory from the system.You can do it at once with the -r flag >> > and interactively with the -i flag. >> > >> > Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> >> > --- >> > scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- >> > 1 file changed, 65 insertions(+), 17 deletions(-) >> >> Hi, >> I believe that this script now does what the patch author intends it to do. >> It does have a few whitespace issues, but no big deals. (see below) > >My original comment stands: looks like it prompts for full module path >and kernel versions which means it's no more convenient than just doing >an "ls" and then removing the ones you want to. (In fact, with "rm" >you'd also get the benefit of tab completion....) Hi Bruce, I am forcing user to put full modules directory name,kinda engagement to the process.It is not a trivial operation, so the users should be aware. OHT Could you please state what else you would like to be inducted in the so it can be useful?? So sorry for my weak memory if you already explicitly stated something like that before. Thanks, Bhaskar > >It's quite different from the original script and I don't really see the >advantage. > >--b. > >> >> Tested-by: Randy Dunlap <rdunlap@infradead.org> >> >> >> > diff --git a/scripts/prune-kernel b/scripts/prune-kernel >> > index e8aa940bc0a9..01d0778db71f 100755 >> > --- a/scripts/prune-kernel >> > +++ b/scripts/prune-kernel >> > @@ -1,21 +1,69 @@ >> > #!/bin/bash >> > # SPDX-License-Identifier: GPL-2.0 >> > +#This script will remove old kernels and modules directory related to it. >> > +#"-r" or "--remove" show how to silently remove old kernel and modules dir. >> > +# "-h" or "--help" show how to use this script or show without parameter. >> > +#"-i" or "--interactive" show how to remove interactively. >> > + >> > +flag=$1 >> > +kernel_version=$2 >> > +modules_version=$3 >> > +boot_dir=/boot >> > +modules_dir=/lib/modules >> > + >> > +remove_old_kernel() { >> > + cd $boot_dir >> > + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version >> > + return 0 >> > +} >> > + >> > +remove_old_modules_dir() { >> > + cd $modules_dir >> > + rm -rf $modules_version >> > + return 0 >> > +} >> > + >> > +usage() { >> > + printf "Usage: $(basename $0) [-ri]\n" >> > + printf "\n -r or --remove kernel_version modules_version\n" >> > + printf "\n -i or --interactive do as interactive way\n" >> > + return 0 >> > +} >> > + >> > +case "$flag" in >> > + -i | --interactive) >> > + printf "\nEnter kernel version to remove or blank/empty to exit:" >> > + read kernel_version >> > + if [[ $kernel_version != "" ]]; then >> > + remove_old_kernel >> > + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" >> >> space after ':' >> >> drop one \n above. >> >> > + printf "Please give the full modules directory name to remove:" >> > + read modules_version >> > + if [[ $modules_version != "" ]]; then >> > + remove_old_modules_dir >> > + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" >> >> space after ':' >> >> drop one \n above. >> >> > + else >> > + exit 1 >> > + fi >> > + fi >> > + ;; >> > + -h | --help) >> > + usage >> > + exit 0 >> > + ;; >> > + -r | --remove) >> > + if [[ $# -ne 3 ]]; then >> > + printf "You need to provide kernel version and modules directory name.\n" >> > + exit 1 >> > + else >> > + remove_old_kernel >> > + remove_old_modules_dir >> > + fi >> > + ;; >> > + *) >> > + usage >> > + exit 1 >> > + ;; >> > +esac >> > >> > -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and >> > -# again, /boot and /lib/modules/ eventually fill up. >> > -# Dumb script to purge that stuff: >> > >> >> OK, the former script's loop is removed.. good. >> But the 2 preceding blank lines are not removed, so the script >> now ends with 2 unnecessary blank lines. >> >> > -for f in "$@" >> > -do >> > - if rpm -qf "/lib/modules/$f" >/dev/null; then >> > - echo "keeping $f (installed from rpm)" >> > - 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 >> > - fi >> > -done >> > -- >> >> >> -- >> ~Randy [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-05 4:39 ` Bhaskar Chowdhury @ 2019-11-05 4:52 ` Bhaskar Chowdhury 0 siblings, 0 replies; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-05 4:52 UTC (permalink / raw) To: J. Bruce Fields Cc: Randy Dunlap, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel [-- Attachment #1: Type: text/plain, Size: 6218 bytes --] On 10:09 Tue 05 Nov 2019, Bhaskar Chowdhury wrote: >On 21:32 Mon 04 Nov 2019, J. Bruce Fields wrote: >>On Mon, Nov 04, 2019 at 06:03:13PM -0800, Randy Dunlap wrote: >>> On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: >>> > This patch allow you to remove old kernels and associated modules >>> > directory from the system.You can do it at once with the -r flag >>> > and interactively with the -i flag. >>> > >>> > Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> >>> > --- >>> > scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- >>> > 1 file changed, 65 insertions(+), 17 deletions(-) >>> >>> Hi, >>> I believe that this script now does what the patch author intends it to do. >>> It does have a few whitespace issues, but no big deals. (see below) >> >>My original comment stands: looks like it prompts for full module path >>and kernel versions which means it's no more convenient than just doing >>an "ls" and then removing the ones you want to. (In fact, with "rm" >>you'd also get the benefit of tab completion....) Bruce, There is -r or --remove option , with that you can pass the kernel version and modules directory name , and the script will remove those without prompting you for those. For instance you need to pass the options like this : ./scripts/prune-kernel -r kernel_version modules_directory_name OR ./scripts/prune-kernel --remove kernel_version modules_directory_name Which I certainly believe is not just "ls and rm" stuff...could you please give it a shot ,and let me know the shortcoming please?? So , I can fix the damn thing. > >Hi Bruce, >I am forcing user to put full modules directory name,kinda engagement >to the process.It is not a trivial operation, so the users should be >aware. >OHT Could you please state what else you would like to be inducted in >the so it can be useful?? So sorry for my weak memory if you already >explicitly stated something like that before. > >Thanks, >Bhaskar >> >>It's quite different from the original script and I don't really see the >>advantage. >> >>--b. >> >>> >>> Tested-by: Randy Dunlap <rdunlap@infradead.org> >>> >>> >>> > diff --git a/scripts/prune-kernel b/scripts/prune-kernel >>> > index e8aa940bc0a9..01d0778db71f 100755 >>> > --- a/scripts/prune-kernel >>> > +++ b/scripts/prune-kernel >>> > @@ -1,21 +1,69 @@ >>> > #!/bin/bash >>> > # SPDX-License-Identifier: GPL-2.0 >>> > +#This script will remove old kernels and modules directory related to it. >>> > +#"-r" or "--remove" show how to silently remove old kernel and modules dir. >>> > +# "-h" or "--help" show how to use this script or show without parameter. >>> > +#"-i" or "--interactive" show how to remove interactively. >>> > + >>> > +flag=$1 >>> > +kernel_version=$2 >>> > +modules_version=$3 >>> > +boot_dir=/boot >>> > +modules_dir=/lib/modules >>> > + >>> > +remove_old_kernel() { >>> > + cd $boot_dir >>> > + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version >>> > + return 0 >>> > +} >>> > + >>> > +remove_old_modules_dir() { >>> > + cd $modules_dir >>> > + rm -rf $modules_version >>> > + return 0 >>> > +} >>> > + >>> > +usage() { >>> > + printf "Usage: $(basename $0) [-ri]\n" >>> > + printf "\n -r or --remove kernel_version modules_version\n" >>> > + printf "\n -i or --interactive do as interactive way\n" >>> > + return 0 >>> > +} >>> > + >>> > +case "$flag" in >>> > + -i | --interactive) >>> > + printf "\nEnter kernel version to remove or blank/empty to exit:" >>> > + read kernel_version >>> > + if [[ $kernel_version != "" ]]; then >>> > + remove_old_kernel >>> > + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" >>> >>> space after ':' >>> >>> drop one \n above. >>> >>> > + printf "Please give the full modules directory name to remove:" >>> > + read modules_version >>> > + if [[ $modules_version != "" ]]; then >>> > + remove_old_modules_dir >>> > + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" >>> >>> space after ':' >>> >>> drop one \n above. >>> >>> > + else >>> > + exit 1 >>> > + fi >>> > + fi >>> > + ;; >>> > + -h | --help) >>> > + usage >>> > + exit 0 >>> > + ;; >>> > + -r | --remove) >>> > + if [[ $# -ne 3 ]]; then >>> > + printf "You need to provide kernel version and modules directory name.\n" >>> > + exit 1 >>> > + else >>> > + remove_old_kernel >>> > + remove_old_modules_dir >>> > + fi >>> > + ;; >>> > + *) >>> > + usage >>> > + exit 1 >>> > + ;; >>> > +esac >>> > >>> > -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and >>> > -# again, /boot and /lib/modules/ eventually fill up. >>> > -# Dumb script to purge that stuff: >>> > >>> >>> OK, the former script's loop is removed.. good. >>> But the 2 preceding blank lines are not removed, so the script >>> now ends with 2 unnecessary blank lines. >>> >>> > -for f in "$@" >>> > -do >>> > - if rpm -qf "/lib/modules/$f" >/dev/null; then >>> > - echo "keeping $f (installed from rpm)" >>> > - 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 >>> > - fi >>> > -done >>> > -- >>> >>> >>> -- >>> ~Randy >-----BEGIN PGP SIGNATURE----- > >iQEzBAABCAAdFiEEnwF+nWawchZUPOuwsjqdtxFLKRUFAl3A/PMACgkQsjqdtxFL >KRUyqQgAya3BYL2iEMk0N3b1/Ji3TVzjrhaMrYM1bc6MDs7UA83ikBBG7C/dSmZ9 >3l9ANXfEnjaF64FpuLTNE2pT/tVxEj+xQz5iWw3JXV9TR7P2rq6814LH4b3hXX54 >A9r0sIRz0xwCMq7ihtNtgXziyviLp8UkUjIK+1C4vQ0h9/CvP0YETq8fgRWASMrS >2+VErRPd06DryAAnapz9CnZz2Fju6S4mA2aaTJ3hiDLNmbj++6IoNQw+r5MZrWde >yUqPQcfAzxs6/GIuUPK3uStudgofQjCKbHbPho9jjmwXrNSFH6/0/pjz5R91oMu9 >AWpkl0vkvAvzLsjRIeMG/MmClx0c3w== >=VReA >-----END PGP SIGNATURE----- [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-05 2:32 ` J. Bruce Fields 2019-11-05 4:39 ` Bhaskar Chowdhury @ 2019-11-06 2:53 ` Masahiro Yamada 2019-11-06 3:10 ` Bhaskar Chowdhury 2019-11-06 4:31 ` J. Bruce Fields 1 sibling, 2 replies; 31+ messages in thread From: Masahiro Yamada @ 2019-11-06 2:53 UTC (permalink / raw) To: J. Bruce Fields Cc: Randy Dunlap, Bhaskar Chowdhury, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List On Tue, Nov 5, 2019 at 11:32 AM J. Bruce Fields <bfields@fieldses.org> wrote: > > On Mon, Nov 04, 2019 at 06:03:13PM -0800, Randy Dunlap wrote: > > On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: > > > This patch allow you to remove old kernels and associated modules > > > directory from the system.You can do it at once with the -r flag > > > and interactively with the -i flag. > > > > > > Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> > > > --- > > > scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- > > > 1 file changed, 65 insertions(+), 17 deletions(-) > > > > Hi, > > I believe that this script now does what the patch author intends it to do. > > It does have a few whitespace issues, but no big deals. (see below) > > My original comment stands: looks like it prompts for full module path > and kernel versions which means it's no more convenient than just doing > an "ls" and then removing the ones you want to. (In fact, with "rm" > you'd also get the benefit of tab completion....) > > It's quite different from the original script and I don't really see the > advantage. > > --b. I am with Bruce. This patch is trying to replace everything with worse code. BTW. Bruce, Does the current script expect RHEL or something? I do not see 'new-kernel-pkg' on my Ubuntu machine. 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 Masahiro Yamada > > > > Tested-by: Randy Dunlap <rdunlap@infradead.org> > > > > > > > diff --git a/scripts/prune-kernel b/scripts/prune-kernel > > > index e8aa940bc0a9..01d0778db71f 100755 > > > --- a/scripts/prune-kernel > > > +++ b/scripts/prune-kernel > > > @@ -1,21 +1,69 @@ > > > #!/bin/bash > > > # SPDX-License-Identifier: GPL-2.0 > > > +#This script will remove old kernels and modules directory related to it. > > > +#"-r" or "--remove" show how to silently remove old kernel and modules dir. > > > +# "-h" or "--help" show how to use this script or show without parameter. > > > +#"-i" or "--interactive" show how to remove interactively. > > > + > > > +flag=$1 > > > +kernel_version=$2 > > > +modules_version=$3 > > > +boot_dir=/boot > > > +modules_dir=/lib/modules > > > + > > > +remove_old_kernel() { > > > + cd $boot_dir > > > + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version > > > + return 0 > > > +} > > > + > > > +remove_old_modules_dir() { > > > + cd $modules_dir > > > + rm -rf $modules_version > > > + return 0 > > > +} > > > + > > > +usage() { > > > + printf "Usage: $(basename $0) [-ri]\n" > > > + printf "\n -r or --remove kernel_version modules_version\n" > > > + printf "\n -i or --interactive do as interactive way\n" > > > + return 0 > > > +} > > > + > > > +case "$flag" in > > > + -i | --interactive) > > > + printf "\nEnter kernel version to remove or blank/empty to exit:" > > > + read kernel_version > > > + if [[ $kernel_version != "" ]]; then > > > + remove_old_kernel > > > + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" > > > > space after ':' > > > > drop one \n above. > > > > > + printf "Please give the full modules directory name to remove:" > > > + read modules_version > > > + if [[ $modules_version != "" ]]; then > > > + remove_old_modules_dir > > > + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" > > > > space after ':' > > > > drop one \n above. > > > > > + else > > > + exit 1 > > > + fi > > > + fi > > > + ;; > > > + -h | --help) > > > + usage > > > + exit 0 > > > + ;; > > > + -r | --remove) > > > + if [[ $# -ne 3 ]]; then > > > + printf "You need to provide kernel version and modules directory name.\n" > > > + exit 1 > > > + else > > > + remove_old_kernel > > > + remove_old_modules_dir > > > + fi > > > + ;; > > > + *) > > > + usage > > > + exit 1 > > > + ;; > > > +esac > > > > > > -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and > > > -# again, /boot and /lib/modules/ eventually fill up. > > > -# Dumb script to purge that stuff: > > > > > > > OK, the former script's loop is removed.. good. > > But the 2 preceding blank lines are not removed, so the script > > now ends with 2 unnecessary blank lines. > > > > > -for f in "$@" > > > -do > > > - if rpm -qf "/lib/modules/$f" >/dev/null; then > > > - echo "keeping $f (installed from rpm)" > > > - 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 > > > - fi > > > -done > > > -- > > > > > > -- > > ~Randy -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 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:31 ` J. Bruce Fields 1 sibling, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-06 3:10 UTC (permalink / raw) To: Masahiro Yamada Cc: J. Bruce Fields, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List [-- Attachment #1: Type: text/plain, Size: 5769 bytes --] On 11:53 Wed 06 Nov 2019, Masahiro Yamada wrote: >On Tue, Nov 5, 2019 at 11:32 AM J. Bruce Fields <bfields@fieldses.org> wrote: >> >> On Mon, Nov 04, 2019 at 06:03:13PM -0800, Randy Dunlap wrote: >> > On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: >> > > This patch allow you to remove old kernels and associated modules >> > > directory from the system.You can do it at once with the -r flag >> > > and interactively with the -i flag. >> > > >> > > Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> >> > > --- >> > > scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- >> > > 1 file changed, 65 insertions(+), 17 deletions(-) >> > >> > Hi, >> > I believe that this script now does what the patch author intends it to do. >> > It does have a few whitespace issues, but no big deals. (see below) >> >> My original comment stands: looks like it prompts for full module path >> and kernel versions which means it's no more convenient than just doing >> an "ls" and then removing the ones you want to. (In fact, with "rm" >> you'd also get the benefit of tab completion....) >> >> It's quite different from the original script and I don't really see the >> advantage. >> >> --b. > >I am with Bruce. > >This patch is trying to replace everything >with worse code. Well,Masahiro, I won't mind dropping the idea, which you already concluded.But, would you care to let me know how worse the code seems to be???? > > >BTW. >Bruce, >Does the current script expect RHEL or something? >I do not see 'new-kernel-pkg' on my Ubuntu machine. > >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 > > > >Masahiro Yamada > > > >> > >> > Tested-by: Randy Dunlap <rdunlap@infradead.org> >> > >> > >> > > diff --git a/scripts/prune-kernel b/scripts/prune-kernel >> > > index e8aa940bc0a9..01d0778db71f 100755 >> > > --- a/scripts/prune-kernel >> > > +++ b/scripts/prune-kernel >> > > @@ -1,21 +1,69 @@ >> > > #!/bin/bash >> > > # SPDX-License-Identifier: GPL-2.0 >> > > +#This script will remove old kernels and modules directory related to it. >> > > +#"-r" or "--remove" show how to silently remove old kernel and modules dir. >> > > +# "-h" or "--help" show how to use this script or show without parameter. >> > > +#"-i" or "--interactive" show how to remove interactively. >> > > + >> > > +flag=$1 >> > > +kernel_version=$2 >> > > +modules_version=$3 >> > > +boot_dir=/boot >> > > +modules_dir=/lib/modules >> > > + >> > > +remove_old_kernel() { >> > > + cd $boot_dir >> > > + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version >> > > + return 0 >> > > +} >> > > + >> > > +remove_old_modules_dir() { >> > > + cd $modules_dir >> > > + rm -rf $modules_version >> > > + return 0 >> > > +} >> > > + >> > > +usage() { >> > > + printf "Usage: $(basename $0) [-ri]\n" >> > > + printf "\n -r or --remove kernel_version modules_version\n" >> > > + printf "\n -i or --interactive do as interactive way\n" >> > > + return 0 >> > > +} >> > > + >> > > +case "$flag" in >> > > + -i | --interactive) >> > > + printf "\nEnter kernel version to remove or blank/empty to exit:" >> > > + read kernel_version >> > > + if [[ $kernel_version != "" ]]; then >> > > + remove_old_kernel >> > > + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" >> > >> > space after ':' >> > >> > drop one \n above. >> > >> > > + printf "Please give the full modules directory name to remove:" >> > > + read modules_version >> > > + if [[ $modules_version != "" ]]; then >> > > + remove_old_modules_dir >> > > + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" >> > >> > space after ':' >> > >> > drop one \n above. >> > >> > > + else >> > > + exit 1 >> > > + fi >> > > + fi >> > > + ;; >> > > + -h | --help) >> > > + usage >> > > + exit 0 >> > > + ;; >> > > + -r | --remove) >> > > + if [[ $# -ne 3 ]]; then >> > > + printf "You need to provide kernel version and modules directory name.\n" >> > > + exit 1 >> > > + else >> > > + remove_old_kernel >> > > + remove_old_modules_dir >> > > + fi >> > > + ;; >> > > + *) >> > > + usage >> > > + exit 1 >> > > + ;; >> > > +esac >> > > >> > > -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and >> > > -# again, /boot and /lib/modules/ eventually fill up. >> > > -# Dumb script to purge that stuff: >> > > >> > >> > OK, the former script's loop is removed.. good. >> > But the 2 preceding blank lines are not removed, so the script >> > now ends with 2 unnecessary blank lines. >> > >> > > -for f in "$@" >> > > -do >> > > - if rpm -qf "/lib/modules/$f" >/dev/null; then >> > > - echo "keeping $f (installed from rpm)" >> > > - 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 >> > > - fi >> > > -done >> > > -- >> > >> > >> > -- >> > ~Randy > > > >-- >Best Regards > >Masahiro Yamada [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-06 3:10 ` Bhaskar Chowdhury @ 2019-11-06 4:03 ` Masahiro Yamada 2019-11-06 4:29 ` Bhaskar Chowdhury 0 siblings, 1 reply; 31+ messages in thread From: Masahiro Yamada @ 2019-11-06 4:03 UTC (permalink / raw) To: Bhaskar Chowdhury Cc: J. Bruce Fields, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List On Wed, Nov 6, 2019 at 12:10 PM Bhaskar Chowdhury <unixbhaskar@gmail.com> wrote: > > On 11:53 Wed 06 Nov 2019, Masahiro Yamada wrote: > >On Tue, Nov 5, 2019 at 11:32 AM J. Bruce Fields <bfields@fieldses.org> wrote: > >> > >> On Mon, Nov 04, 2019 at 06:03:13PM -0800, Randy Dunlap wrote: > >> > On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: > >> > > This patch allow you to remove old kernels and associated modules > >> > > directory from the system.You can do it at once with the -r flag > >> > > and interactively with the -i flag. > >> > > > >> > > Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> > >> > > --- > >> > > scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- > >> > > 1 file changed, 65 insertions(+), 17 deletions(-) > >> > > >> > Hi, > >> > I believe that this script now does what the patch author intends it to do. > >> > It does have a few whitespace issues, but no big deals. (see below) > >> > >> My original comment stands: looks like it prompts for full module path > >> and kernel versions which means it's no more convenient than just doing > >> an "ls" and then removing the ones you want to. (In fact, with "rm" > >> you'd also get the benefit of tab completion....) > >> > >> It's quite different from the original script and I don't really see the > >> advantage. > >> > >> --b. > > > >I am with Bruce. > > > >This patch is trying to replace everything > >with worse code. > Well,Masahiro, > I won't mind dropping the idea, which you already concluded.But, would > you care to let me know how worse the code seems to be???? As far as I understood this script, it is useful to delete stale versions with a single command. scripts/prune-kernel 5.2-rc1 5.2-rc2 5.2-rc3 This patch is dropping the 'for f in "$@"' loop, so you would end up with running this script multiple times. scripts/prune-kernel -r 5.2-rc1 5.2-rc1 scripts/prune-kernel -r 5.2-rc2 5.2-rc2 scripts/prune-kernel -r 5.2-rc3 5.2-rc3 What is funny is, it takes the kernel_version and modules_version separately. And now it requires -r option for the default behavior. I see nothing cool overall. J. Bruce Fields suggested: "But if somebody does actually use it as-is, it'd be nicer to keep the current behavior and add an option ("-i" or something) for the interactive behavior." I want to see a patch if and only if you can add -i without intrusively changing the current code. Masahiro > > > >BTW. > >Bruce, > >Does the current script expect RHEL or something? > >I do not see 'new-kernel-pkg' on my Ubuntu machine. > > > >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 > > > > > > > >Masahiro Yamada > > > > > > > >> > > >> > Tested-by: Randy Dunlap <rdunlap@infradead.org> > >> > > >> > > >> > > diff --git a/scripts/prune-kernel b/scripts/prune-kernel > >> > > index e8aa940bc0a9..01d0778db71f 100755 > >> > > --- a/scripts/prune-kernel > >> > > +++ b/scripts/prune-kernel > >> > > @@ -1,21 +1,69 @@ > >> > > #!/bin/bash > >> > > # SPDX-License-Identifier: GPL-2.0 > >> > > +#This script will remove old kernels and modules directory related to it. > >> > > +#"-r" or "--remove" show how to silently remove old kernel and modules dir. > >> > > +# "-h" or "--help" show how to use this script or show without parameter. > >> > > +#"-i" or "--interactive" show how to remove interactively. > >> > > + > >> > > +flag=$1 > >> > > +kernel_version=$2 > >> > > +modules_version=$3 > >> > > +boot_dir=/boot > >> > > +modules_dir=/lib/modules > >> > > + > >> > > +remove_old_kernel() { > >> > > + cd $boot_dir > >> > > + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version > >> > > + return 0 > >> > > +} > >> > > + > >> > > +remove_old_modules_dir() { > >> > > + cd $modules_dir > >> > > + rm -rf $modules_version > >> > > + return 0 > >> > > +} > >> > > + > >> > > +usage() { > >> > > + printf "Usage: $(basename $0) [-ri]\n" > >> > > + printf "\n -r or --remove kernel_version modules_version\n" > >> > > + printf "\n -i or --interactive do as interactive way\n" > >> > > + return 0 > >> > > +} > >> > > + > >> > > +case "$flag" in > >> > > + -i | --interactive) > >> > > + printf "\nEnter kernel version to remove or blank/empty to exit:" > >> > > + read kernel_version > >> > > + if [[ $kernel_version != "" ]]; then > >> > > + remove_old_kernel > >> > > + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" > >> > > >> > space after ':' > >> > > >> > drop one \n above. > >> > > >> > > + printf "Please give the full modules directory name to remove:" > >> > > + read modules_version > >> > > + if [[ $modules_version != "" ]]; then > >> > > + remove_old_modules_dir > >> > > + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" > >> > > >> > space after ':' > >> > > >> > drop one \n above. > >> > > >> > > + else > >> > > + exit 1 > >> > > + fi > >> > > + fi > >> > > + ;; > >> > > + -h | --help) > >> > > + usage > >> > > + exit 0 > >> > > + ;; > >> > > + -r | --remove) > >> > > + if [[ $# -ne 3 ]]; then > >> > > + printf "You need to provide kernel version and modules directory name.\n" > >> > > + exit 1 > >> > > + else > >> > > + remove_old_kernel > >> > > + remove_old_modules_dir > >> > > + fi > >> > > + ;; > >> > > + *) > >> > > + usage > >> > > + exit 1 > >> > > + ;; > >> > > +esac > >> > > > >> > > -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and > >> > > -# again, /boot and /lib/modules/ eventually fill up. > >> > > -# Dumb script to purge that stuff: > >> > > > >> > > >> > OK, the former script's loop is removed.. good. > >> > But the 2 preceding blank lines are not removed, so the script > >> > now ends with 2 unnecessary blank lines. > >> > > >> > > -for f in "$@" > >> > > -do > >> > > - if rpm -qf "/lib/modules/$f" >/dev/null; then > >> > > - echo "keeping $f (installed from rpm)" > >> > > - 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 > >> > > - fi > >> > > -done > >> > > -- > >> > > >> > > >> > -- > >> > ~Randy > > > > > > > >-- > >Best Regards > > > >Masahiro Yamada -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-06 4:03 ` Masahiro Yamada @ 2019-11-06 4:29 ` Bhaskar Chowdhury 0 siblings, 0 replies; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-06 4:29 UTC (permalink / raw) To: Masahiro Yamada Cc: J. Bruce Fields, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List [-- Attachment #1: Type: text/plain, Size: 8234 bytes --] On 13:03 Wed 06 Nov 2019, Masahiro Yamada wrote: >On Wed, Nov 6, 2019 at 12:10 PM Bhaskar Chowdhury <unixbhaskar@gmail.com> wrote: >> >> On 11:53 Wed 06 Nov 2019, Masahiro Yamada wrote: >> >On Tue, Nov 5, 2019 at 11:32 AM J. Bruce Fields <bfields@fieldses.org> wrote: >> >> >> >> On Mon, Nov 04, 2019 at 06:03:13PM -0800, Randy Dunlap wrote: >> >> > On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: >> >> > > This patch allow you to remove old kernels and associated modules >> >> > > directory from the system.You can do it at once with the -r flag >> >> > > and interactively with the -i flag. >> >> > > >> >> > > Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> >> >> > > --- >> >> > > scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- >> >> > > 1 file changed, 65 insertions(+), 17 deletions(-) >> >> > >> >> > Hi, >> >> > I believe that this script now does what the patch author intends it to do. >> >> > It does have a few whitespace issues, but no big deals. (see below) >> >> >> >> My original comment stands: looks like it prompts for full module path >> >> and kernel versions which means it's no more convenient than just doing >> >> an "ls" and then removing the ones you want to. (In fact, with "rm" >> >> you'd also get the benefit of tab completion....) >> >> >> >> It's quite different from the original script and I don't really see the >> >> advantage. >> >> >> >> --b. >> > >> >I am with Bruce. >> > >> >This patch is trying to replace everything >> >with worse code. >> Well,Masahiro, >> I won't mind dropping the idea, which you already concluded.But, would >> you care to let me know how worse the code seems to be???? > > >As far as I understood this script, >it is useful to delete stale versions with a single command. > >scripts/prune-kernel 5.2-rc1 5.2-rc2 5.2-rc3 > > >This patch is dropping the 'for f in "$@"' loop, >so you would end up with running this script multiple times. > >scripts/prune-kernel -r 5.2-rc1 5.2-rc1 >scripts/prune-kernel -r 5.2-rc2 5.2-rc2 >scripts/prune-kernel -r 5.2-rc3 5.2-rc3 > Yes, true. You don't want all the stale kernels to be discarded at once, do you??? > >What is funny is, it takes the kernel_version and modules_version >separately. Lack of farsight of mine ...will take your suggestion. Should have realized it before, but was writing for different purpose. >And now it requires -r option for the default behavior. Because other flags are involved and they do different things. >I see nothing cool overall. > Meh... I am interpreting you "cool" literal way...which you certainly didn't mean it...do you?? > > >J. Bruce Fields suggested: >"But if somebody does actually use it as-is, it'd be nicer to keep the >current behavior and add an option ("-i" or something) for the >interactive behavior." > Yes, that's true ...and now I understood. On the contrary ,if I recollect properly, Bruce ,once told that he won't if do something which will be useful to the wider users..not sure that stands anymore. > >I want to see a patch if and only if >you can add -i without intrusively changing the current code. > Hopefully , you wish get fulfilled sooner than later. > >Masahiro > > > Bhaskar > >> > >> >BTW. >> >Bruce, >> >Does the current script expect RHEL or something? >> >I do not see 'new-kernel-pkg' on my Ubuntu machine. >> > >> >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 >> > >> > >> > >> >Masahiro Yamada >> > >> > >> > >> >> > >> >> > Tested-by: Randy Dunlap <rdunlap@infradead.org> >> >> > >> >> > >> >> > > diff --git a/scripts/prune-kernel b/scripts/prune-kernel >> >> > > index e8aa940bc0a9..01d0778db71f 100755 >> >> > > --- a/scripts/prune-kernel >> >> > > +++ b/scripts/prune-kernel >> >> > > @@ -1,21 +1,69 @@ >> >> > > #!/bin/bash >> >> > > # SPDX-License-Identifier: GPL-2.0 >> >> > > +#This script will remove old kernels and modules directory related to it. >> >> > > +#"-r" or "--remove" show how to silently remove old kernel and modules dir. >> >> > > +# "-h" or "--help" show how to use this script or show without parameter. >> >> > > +#"-i" or "--interactive" show how to remove interactively. >> >> > > + >> >> > > +flag=$1 >> >> > > +kernel_version=$2 >> >> > > +modules_version=$3 >> >> > > +boot_dir=/boot >> >> > > +modules_dir=/lib/modules >> >> > > + >> >> > > +remove_old_kernel() { >> >> > > + cd $boot_dir >> >> > > + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version >> >> > > + return 0 >> >> > > +} >> >> > > + >> >> > > +remove_old_modules_dir() { >> >> > > + cd $modules_dir >> >> > > + rm -rf $modules_version >> >> > > + return 0 >> >> > > +} >> >> > > + >> >> > > +usage() { >> >> > > + printf "Usage: $(basename $0) [-ri]\n" >> >> > > + printf "\n -r or --remove kernel_version modules_version\n" >> >> > > + printf "\n -i or --interactive do as interactive way\n" >> >> > > + return 0 >> >> > > +} >> >> > > + >> >> > > +case "$flag" in >> >> > > + -i | --interactive) >> >> > > + printf "\nEnter kernel version to remove or blank/empty to exit:" >> >> > > + read kernel_version >> >> > > + if [[ $kernel_version != "" ]]; then >> >> > > + remove_old_kernel >> >> > > + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" >> >> > >> >> > space after ':' >> >> > >> >> > drop one \n above. >> >> > >> >> > > + printf "Please give the full modules directory name to remove:" >> >> > > + read modules_version >> >> > > + if [[ $modules_version != "" ]]; then >> >> > > + remove_old_modules_dir >> >> > > + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" >> >> > >> >> > space after ':' >> >> > >> >> > drop one \n above. >> >> > >> >> > > + else >> >> > > + exit 1 >> >> > > + fi >> >> > > + fi >> >> > > + ;; >> >> > > + -h | --help) >> >> > > + usage >> >> > > + exit 0 >> >> > > + ;; >> >> > > + -r | --remove) >> >> > > + if [[ $# -ne 3 ]]; then >> >> > > + printf "You need to provide kernel version and modules directory name.\n" >> >> > > + exit 1 >> >> > > + else >> >> > > + remove_old_kernel >> >> > > + remove_old_modules_dir >> >> > > + fi >> >> > > + ;; >> >> > > + *) >> >> > > + usage >> >> > > + exit 1 >> >> > > + ;; >> >> > > +esac >> >> > > >> >> > > -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and >> >> > > -# again, /boot and /lib/modules/ eventually fill up. >> >> > > -# Dumb script to purge that stuff: >> >> > > >> >> > >> >> > OK, the former script's loop is removed.. good. >> >> > But the 2 preceding blank lines are not removed, so the script >> >> > now ends with 2 unnecessary blank lines. >> >> > >> >> > > -for f in "$@" >> >> > > -do >> >> > > - if rpm -qf "/lib/modules/$f" >/dev/null; then >> >> > > - echo "keeping $f (installed from rpm)" >> >> > > - 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 >> >> > > - fi >> >> > > -done >> >> > > -- >> >> > >> >> > >> >> > -- >> >> > ~Randy >> > >> > >> > >> >-- >> >Best Regards >> > >> >Masahiro Yamada > > > >-- >Best Regards >Masahiro Yamada [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-06 2:53 ` Masahiro Yamada 2019-11-06 3:10 ` Bhaskar Chowdhury @ 2019-11-06 4:31 ` J. Bruce Fields 2019-11-06 4:32 ` Randy Dunlap 2019-11-06 4:42 ` Bhaskar Chowdhury 1 sibling, 2 replies; 31+ messages in thread From: J. Bruce Fields @ 2019-11-06 4:31 UTC (permalink / raw) To: Masahiro Yamada Cc: Randy Dunlap, Bhaskar Chowdhury, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List 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. ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-06 4:31 ` J. Bruce Fields @ 2019-11-06 4:32 ` Randy Dunlap 2019-11-06 4:42 ` Bhaskar Chowdhury 1 sibling, 0 replies; 31+ messages in thread From: Randy Dunlap @ 2019-11-06 4:32 UTC (permalink / raw) To: J. Bruce Fields, Masahiro Yamada Cc: Bhaskar Chowdhury, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List On 11/5/19 8:31 PM, 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. on openSUSE, I don't have new-kernel-pkg or grubby. -- ~Randy ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 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 1 sibling, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-06 4:42 UTC (permalink / raw) To: J. Bruce Fields Cc: Masahiro Yamada, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List [-- Attachment #1: Type: text/plain, Size: 1048 bytes --] 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???? ~ Bhaskar [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-06 4:42 ` Bhaskar Chowdhury @ 2019-11-06 19:30 ` J. Bruce Fields 2019-11-06 22:39 ` Bhaskar Chowdhury 0 siblings, 1 reply; 31+ messages in thread From: J. Bruce Fields @ 2019-11-06 19:30 UTC (permalink / raw) To: Bhaskar Chowdhury Cc: Masahiro Yamada, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List 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. ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-06 19:30 ` J. Bruce Fields @ 2019-11-06 22:39 ` Bhaskar Chowdhury 2019-11-09 7:25 ` Masahiro Yamada 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-06 22:39 UTC (permalink / raw) To: J. Bruce Fields Cc: Masahiro Yamada, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List [-- Attachment #1: Type: text/plain, Size: 3778 bytes --] 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. ~Bhaskar [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-06 22:39 ` Bhaskar Chowdhury @ 2019-11-09 7:25 ` Masahiro Yamada 2019-11-09 11:13 ` Bhaskar Chowdhury 0 siblings, 1 reply; 31+ messages in thread From: Masahiro Yamada @ 2019-11-09 7:25 UTC (permalink / raw) To: Bhaskar Chowdhury Cc: J. Bruce Fields, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List 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 am not sure how many people are using this. 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. -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-09 7:25 ` Masahiro Yamada @ 2019-11-09 11:13 ` Bhaskar Chowdhury 2019-11-15 1:58 ` Masahiro Yamada 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-09 11:13 UTC (permalink / raw) To: Masahiro Yamada Cc: J. Bruce Fields, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List [-- Attachment #1: Type: text/plain, Size: 5048 bytes --] 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. > >-- >Best Regards >Masahiro Yamada Thanks, Bhaskar [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-09 11:13 ` Bhaskar Chowdhury @ 2019-11-15 1:58 ` Masahiro Yamada 2019-11-15 15:21 ` Bhaskar Chowdhury 0 siblings, 1 reply; 31+ messages in thread From: Masahiro Yamada @ 2019-11-15 1:58 UTC (permalink / raw) To: Bhaskar Chowdhury Cc: J. Bruce Fields, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List 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 [2] do nice things for non-rpm systems They should be done by separate patches. I think [1] is easy to do in a few liners. For [2], I am not sure how well it goes until I see an actual patch. -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-15 1:58 ` Masahiro Yamada @ 2019-11-15 15:21 ` Bhaskar Chowdhury 2019-11-18 7:30 ` Masahiro Yamada 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-15 15:21 UTC (permalink / raw) To: Masahiro Yamada Cc: J. Bruce Fields, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List [-- Attachment #1: Type: text/plain, Size: 6669 bytes --] 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. > That would be a undertaking to deal with the native packaging system for different distributions. >-- >Best Regards >Masahiro Yamada Thanks, Bhaskar [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-15 15:21 ` Bhaskar Chowdhury @ 2019-11-18 7:30 ` Masahiro Yamada 0 siblings, 0 replies; 31+ messages in thread From: Masahiro Yamada @ 2019-11-18 7:30 UTC (permalink / raw) To: Bhaskar Chowdhury, Masahiro Yamada, J. Bruce Fields, Randy Dunlap, Michal Marek, Linux Kbuild mailing list, Linux Kernel Mailing List [-- 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 ^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts:prune-kernel:remove old kernels and modules dir from system 2019-11-05 2:03 ` Randy Dunlap 2019-11-05 2:32 ` J. Bruce Fields @ 2019-11-05 4:33 ` Bhaskar Chowdhury 1 sibling, 0 replies; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-05 4:33 UTC (permalink / raw) To: Randy Dunlap Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel [-- Attachment #1: Type: text/plain, Size: 3936 bytes --] On 18:03 Mon 04 Nov 2019, Randy Dunlap wrote: >On 11/1/19 11:30 PM, Bhaskar Chowdhury wrote: >> This patch allow you to remove old kernels and associated modules >> directory from the system.You can do it at once with the -r flag >> and interactively with the -i flag. >> >> Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> >> --- >> scripts/prune-kernel | 82 +++++++++++++++++++++++++++++++++++--------- >> 1 file changed, 65 insertions(+), 17 deletions(-) > >Hi, >I believe that this script now does what the patch author intends it to do. >It does have a few whitespace issues, but no big deals. (see below) > >Tested-by: Randy Dunlap <rdunlap@infradead.org> > > Thank you Randy.. >> diff --git a/scripts/prune-kernel b/scripts/prune-kernel >> index e8aa940bc0a9..01d0778db71f 100755 >> --- a/scripts/prune-kernel >> +++ b/scripts/prune-kernel >> @@ -1,21 +1,69 @@ >> #!/bin/bash >> # SPDX-License-Identifier: GPL-2.0 >> +#This script will remove old kernels and modules directory related to it. >> +#"-r" or "--remove" show how to silently remove old kernel and modules dir. >> +# "-h" or "--help" show how to use this script or show without parameter. >> +#"-i" or "--interactive" show how to remove interactively. >> + >> +flag=$1 >> +kernel_version=$2 >> +modules_version=$3 >> +boot_dir=/boot >> +modules_dir=/lib/modules >> + >> +remove_old_kernel() { >> + cd $boot_dir >> + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version >> + return 0 >> +} >> + >> +remove_old_modules_dir() { >> + cd $modules_dir >> + rm -rf $modules_version >> + return 0 >> +} >> + >> +usage() { >> + printf "Usage: $(basename $0) [-ri]\n" >> + printf "\n -r or --remove kernel_version modules_version\n" >> + printf "\n -i or --interactive do as interactive way\n" >> + return 0 >> +} >> + >> +case "$flag" in >> + -i | --interactive) >> + printf "\nEnter kernel version to remove or blank/empty to exit:" >> + read kernel_version >> + if [[ $kernel_version != "" ]]; then >> + remove_old_kernel >> + printf "\nRemoved kernel version:$kernel_version from the system.\n\n" > >space after ':' > >drop one \n above. > Will do. >> + printf "Please give the full modules directory name to remove:" >> + read modules_version >> + if [[ $modules_version != "" ]]; then >> + remove_old_modules_dir >> + printf "\n\nRemoved modules directory:$modules_version from the system.\n\n" > >space after ':' > >drop one \n above. > Will do. >> + else >> + exit 1 >> + fi >> + fi >> + ;; >> + -h | --help) >> + usage >> + exit 0 >> + ;; >> + -r | --remove) >> + if [[ $# -ne 3 ]]; then >> + printf "You need to provide kernel version and modules directory name.\n" >> + exit 1 >> + else >> + remove_old_kernel >> + remove_old_modules_dir >> + fi >> + ;; >> + *) >> + usage >> + exit 1 >> + ;; >> +esac >> >> -# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and >> -# again, /boot and /lib/modules/ eventually fill up. >> -# Dumb script to purge that stuff: >> > >OK, the former script's loop is removed.. good. >But the 2 preceding blank lines are not removed, so the script >now ends with 2 unnecessary blank lines. > Will do. >> -for f in "$@" >> -do >> - if rpm -qf "/lib/modules/$f" >/dev/null; then >> - echo "keeping $f (installed from rpm)" >> - 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 >> - fi >> -done >> -- > > >-- >~Randy > Bhaskar [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system @ 2019-10-30 9:54 Bhaskar Chowdhury 2019-10-31 2:33 ` Randy Dunlap 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-10-30 9:54 UTC (permalink / raw) To: rdunlap, bfields Cc: yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel, Bhaskar Chowdhury This patch will remove old kernels and modules directorey related to that kernel from the system by interactively and silently.Here are few interactions with the scripts 1) ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] 14:52 $ ./scripts/prune-kernel -h Usage: prune-kernel [ri] -r | --remove kernel_ver modules_dir_name -i | --interactive use as interactive way ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] 14:52 $ ./scripts/prune-kernel --help Usage: prune-kernel [ri] -r | --remove kernel_ver modules_dir_name -i | --interactive use as interactive way 2) ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] 14:52 $ ./scripts/prune-kernel -r 5.3.3 You need to provide kernel version and modules dir name ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] 14:53 $ ./scripts/prune-kernel -r You need to provide kernel version and modules dir name ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] 14:54 $ ./scripts/prune-kernel -r 5.3.3 5.3.3-foo 3) $ ./scripts/prune-kernel --remove You need to provide kernel version and modules dir name ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] 14:55 $ ./scripts/prune-kernel --remove 5.3.3 You need to provide kernel version and modules dir name ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] 14:55 $ ./scripts/prune-kernel --remove 5.3.3 5.3.3-foo 4)14:55 $ ./scripts/prune-kernel -i Enter kernel version to remove or blank/empty to exit: 5)14:57 $ ./scripts/prune-kernel --interactive Enter kernel version to remove or blank/empty to exit: ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] 6)14:59 $ ./scripts/prune-kernel --interactive Enter kernel version to remove or blank/empty to exit:5.3.3 Please give the full modules directory name to remove:5.3.3-foo Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. 7)15:00 $ ./scripts/prune-kernel -i Enter kernel version to remove or blank/empty to exit:5.3.3 Please give the full modules directory name to remove:5.3.3-foo Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> --- scripts/prune-kernel | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/scripts/prune-kernel b/scripts/prune-kernel index a25aa2160d47..a91010d0e2af 100755 --- a/scripts/prune-kernel +++ b/scripts/prune-kernel @@ -1,3 +1,66 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +#This script will delete old kernels and modules directory related to it +#-h with the script will show you the help +#-r with the script take two parameter: kernel_ver and modules_dir_name +#-i with the script allow you do the removing interactive way +flag=$1 +kernel_ver=$2 +modules_dir_name=$3 +boot_dir=/boot +modules_dir=/lib/modules + +remove_old_kernel() { + cd $boot_dir + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version + return 0 +} + +remove_old_modules_dir() { + cd $modules_dir + rm -rf $modules_version + return 0 +} + +usage() { + printf "Usage: $(basename $0) [ri] \n" + printf "\n -r | --remove kernel_ver modules_dir_name \n" + printf "\n -i | --interactive use as interactive way \n" +} + +for arg in "$@" +do + case "$flag" in + -i | --interactive) + printf "\nEnter kernel version to remove or blank/empty to exit:%s" + read kernel_version + if [[ $kernel_version != "" ]]; then + remove_old_kernel + printf "Please give the full modules directory name to remove:%s" + read modules_version + if [[ $modules_version != "" ]]; then + remove_old_modules_dir + printf "\n\n\n Removed kernel version:$kernel_version and associated modules:$modules_version ...Done. \n" + else + exit 1 + fi + fi + ;; + -h | --help) + usage + exit 1 + ;; + -r | --remove) + if [[ $# -ne 3 ]]; then + printf "You need to provide kernel version and modules dir name\n" + exit 1 + else + cd $boot_dir + rm -f $kernel_ver + cd $modules_dir + rm -rf $modules_dir_name + fi + ;; + esac +done -- 2.23.0 ^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 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 0 siblings, 1 reply; 31+ messages in thread From: Randy Dunlap @ 2019-10-31 2:33 UTC (permalink / raw) To: Bhaskar Chowdhury, bfields Cc: yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel Hi, On 10/30/19 2:54 AM, Bhaskar Chowdhury wrote: > This patch will remove old kernels and modules directorey related > to that kernel from the system by interactively and silently.Here > are few interactions with the scripts > > 1) > > ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] > 14:52 $ ./scripts/prune-kernel -h > Usage: prune-kernel [ri] > > -r | --remove kernel_ver modules_dir_name > > -i | --interactive use as interactive way > ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] > > 14:52 $ ./scripts/prune-kernel --help > Usage: prune-kernel [ri] That "[ri]" is confusing to me. > > -r | --remove kernel_ver modules_dir_na] > > -i | --interactive use as interactive way > > 2) > > ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] > 14:52 $ ./scripts/prune-kernel -r 5.3.3 > You need to provide kernel version and modules dir name > > ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] > 14:53 $ ./scripts/prune-kernel -r > You need to provide kernel version and modules dir name > > ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] > 14:54 $ ./scripts/prune-kernel -r 5.3.3 5.3.3-foo This one above didn't remove any kernel files. Needs more testing. > 3) > > $ ./scripts/prune-kernel --remove > You need to provide kernel version and modules dir name > > ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] > 14:55 $ ./scripts/prune-kernel --remove 5.3.3 > You need to provide kernel version and modules dir name > > ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] > 14:55 $ ./scripts/prune-kernel --remove 5.3.3 5.3.3-foo > > > 4)14:55 $ ./scripts/prune-kernel -i > > Enter kernel version to remove or blank/empty to exit: > > > 5)14:57 $ ./scripts/prune-kernel --interactive > > Enter kernel version to remove or blank/empty to exit: > ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] > > > 6)14:59 $ ./scripts/prune-kernel --interactive > > Enter kernel version to remove or blank/empty to exit:5.3.3 > Please give the full modules directory name to remove:5.3.3-foo > > > > Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. > > > 7)15:00 $ ./scripts/prune-kernel -i > > Enter kernel version to remove or blank/empty to exit:5.3.3 > Please give the full modules directory name to remove:5.3.3-foo > > > > Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. > > > Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> > --- > scripts/prune-kernel | 63 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 63 insertions(+) > > diff --git a/scripts/prune-kernel b/scripts/prune-kernel > index a25aa2160d47..a91010d0e2af 100755 > --- a/scripts/prune-kernel > +++ b/scripts/prune-kernel > @@ -1,3 +1,66 @@ > #!/bin/bash > # SPDX-License-Identifier: GPL-2.0 > +#This script will delete old kernels and modules directory related to it > +#-h with the script will show you the help > +#-r with the script take two parameter: kernel_ver and modules_dir_name > +#-i with the script allow you do the removing interactive way > > +flag=$1 > +kernel_ver=$2 > +modules_dir_name=$3 > +boot_dir=/boot > +modules_dir=/lib/modules > + > +remove_old_kernel() { > + cd $boot_dir > + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version > + return 0 > +} > + > +remove_old_modules_dir() { > + cd $modules_dir > + rm -rf $modules_version > + return 0 > +} > + > +usage() { > + printf "Usage: $(basename $0) [ri] \n" > + printf "\n -r | --remove kernel_ver modules_dir_name \n" > + printf "\n -i | --interactive use as interactive way \n" > +} > + > +for arg in "$@" what is the purpose (use) of "arg" here? what is the purpose of the for loop? Is any 'shift' needed to consume (or discard) the first 3 positional command line arguments? > +do > + case "$flag" in > + -i | --interactive) > + printf "\nEnter kernel version to remove or blank/empty to exit:%s" > + read kernel_version > + if [[ $kernel_version != "" ]]; then > + remove_old_kernel > + printf "Please give the full modules directory name to remove:%s" > + read modules_version > + if [[ $modules_version != "" ]]; then > + remove_old_modules_dir > + printf "\n\n\n Removed kernel version:$kernel_version and associated modules:$modules_version ...Done. \n" This message is only printed if $modules_version is non-empty. If it is empty, remove_old_kernel() has silently removed some kernel files (if they existed). > + else > + exit 1 > + fi > + fi > + ;; > + -h | --help) > + usage > + exit 1 > + ;; > + -r | --remove) > + if [[ $# -ne 3 ]]; then > + printf "You need to provide kernel version and modules dir name\n" > + exit 1 > + else > + cd $boot_dir > + rm -f $kernel_ver That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. > + cd $modules_dir > + rm -rf $modules_dir_name > + fi > + ;; > + esac > +done > -- The script, after this patch is applied, still contains the old script's for-loop at the end of the "new" prune-kernel script. Nack. -- ~Randy ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 2019-10-31 2:33 ` Randy Dunlap @ 2019-10-31 3:37 ` Bhaskar Chowdhury 2019-10-31 4:32 ` Randy Dunlap 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-10-31 3:37 UTC (permalink / raw) To: Randy Dunlap Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel [-- Attachment #1: Type: text/plain, Size: 6888 bytes --] Thank you Randy, my response are inline. Please look at it.I am wondering , what else I could do get this damn! thing going?? Any clue?? On 19:33 Wed 30 Oct 2019, Randy Dunlap wrote: >Hi, > >On 10/30/19 2:54 AM, Bhaskar Chowdhury wrote: >> This patch will remove old kernels and modules directorey related >> to that kernel from the system by interactively and silently.Here >> are few interactions with the scripts >> >> 1) >> >> ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >> 14:52 $ ./scripts/prune-kernel -h >> Usage: prune-kernel [ri] >> >> -r | --remove kernel_ver modules_dir_name >> >> -i | --interactive use as interactive way >> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >> >> 14:52 $ ./scripts/prune-kernel --help >> Usage: prune-kernel [ri] > >That "[ri]" is confusing to me. This are the options one has to pass with the script.Like below: >> >> -r | --remove kernel_ver modules_dir_na] >> >> -i | --interactive use as interactive way >> >> 2) >> >> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >> 14:52 $ ./scripts/prune-kernel -r 5.3.3 >> You need to provide kernel version and modules dir name >> >> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >> 14:53 $ ./scripts/prune-kernel -r >> You need to provide kernel version and modules dir name >> >> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >> 14:54 $ ./scripts/prune-kernel -r 5.3.3 5.3.3-foo > >This one above didn't remove any kernel files. >Needs more testing. It does remove but silently, as you and Bruce asked for this feature. > >> 3) >> >> $ ./scripts/prune-kernel --remove >> You need to provide kernel version and modules dir name >> >> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >> 14:55 $ ./scripts/prune-kernel --remove 5.3.3 >> You need to provide kernel version and modules dir name >> >> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >> 14:55 $ ./scripts/prune-kernel --remove 5.3.3 5.3.3-foo >> >> >> 4)14:55 $ ./scripts/prune-kernel -i >> >> Enter kernel version to remove or blank/empty to exit: >> >> >> 5)14:57 $ ./scripts/prune-kernel --interactive >> >> Enter kernel version to remove or blank/empty to exit: >> ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >> >> >> 6)14:59 $ ./scripts/prune-kernel --interactive >> >> Enter kernel version to remove or blank/empty to exit:5.3.3 >> Please give the full modules directory name to remove:5.3.3-foo >> >> >> >> Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. >> >> >> 7)15:00 $ ./scripts/prune-kernel -i >> >> Enter kernel version to remove or blank/empty to exit:5.3.3 >> Please give the full modules directory name to remove:5.3.3-foo >> >> >> >> Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. >> >> >> Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> >> --- >> scripts/prune-kernel | 63 ++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 63 insertions(+) >> >> diff --git a/scripts/prune-kernel b/scripts/prune-kernel >> index a25aa2160d47..a91010d0e2af 100755 >> --- a/scripts/prune-kernel >> +++ b/scripts/prune-kernel >> @@ -1,3 +1,66 @@ >> #!/bin/bash >> # SPDX-License-Identifier: GPL-2.0 >> +#This script will delete old kernels and modules directory related to it >> +#-h with the script will show you the help >> +#-r with the script take two parameter: kernel_ver and modules_dir_name >> +#-i with the script allow you do the removing interactive way >> >> +flag=$1 >> +kernel_ver=$2 >> +modules_dir_name=$3 >> +boot_dir=/boot >> +modules_dir=/lib/modules >> + >> +remove_old_kernel() { >> + cd $boot_dir >> + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version >> + return 0 >> +} >> + >> +remove_old_modules_dir() { >> + cd $modules_dir >> + rm -rf $modules_version >> + return 0 >> +} >> + >> +usage() { >> + printf "Usage: $(basename $0) [ri] \n" >> + printf "\n -r | --remove kernel_ver modules_dir_name \n" >> + printf "\n -i | --interactive use as interactive way \n" >> +} >> + >> +for arg in "$@" > >what is the purpose (use) of "arg" here? This variable is used in case statement below. >what is the purpose of the for loop? > It scan through all the parameters pass . >Is any 'shift' needed to consume (or discard) the first 3 positional >command line arguments? Nope, that is not required. And I haven't use any. > >> +do >> + case "$flag" in >> + -i | --interactive) >> + printf "\nEnter kernel version to remove or blank/empty to exit:%s" >> + read kernel_version >> + if [[ $kernel_version != "" ]]; then >> + remove_old_kernel >> + printf "Please give the full modules directory name to remove:%s" >> + read modules_version >> + if [[ $modules_version != "" ]]; then >> + remove_old_modules_dir >> + printf "\n\n\n Removed kernel version:$kernel_version and associated modules:$modules_version ...Done. \n" > >This message is only printed if $modules_version is non-empty. If it is empty, >remove_old_kernel() has silently removed some kernel files (if they existed). it will fail to remove anything if the kernel_version or modules_version are empty and importantly exit. > >> + else >> + exit 1 >> + fi >> + fi >> + ;; >> + -h | --help) >> + usage >> + exit 1 >> + ;; >> + -r | --remove) >> + if [[ $# -ne 3 ]]; then >> + printf "You need to provide kernel version and modules dir name\n" >> + exit 1 >> + else >> + cd $boot_dir >> + rm -f $kernel_ver > >That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. No,it is not using that function rather take the parameter from the commandline and get into boot dir match with it and remove it. > >> + cd $modules_dir >> + rm -rf $modules_dir_name >> + fi >> + ;; >> + esac >> +done >> -- > >The script, after this patch is applied, still contains the old script's for-loop >at the end of the "new" prune-kernel script. Amazing! now it needs some explanation how I did...you probably want that ..here are the steps.... 1)fetch that prune-kernel file from repos , which contains Bruce's code in it. 2) get inot it by editior, remove all except first two lines i.e bash interpreter and PSDX . 3)Save and commit it locally. 4) Write my own code 5) save it and commit it locally. 6) go one level up use checkpatch to see anything bad creeps in 7) Fixed the damn things if it reports. 8) create the patch 9) test it 10) Send it. Now, how the heck , that for loop is getting staying there is a mystry to me!! Look like that is ruin all the work. irk... > >Nack. > >-- >~Randy [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 2019-10-31 3:37 ` Bhaskar Chowdhury @ 2019-10-31 4:32 ` Randy Dunlap 2019-10-31 4:52 ` Bhaskar Chowdhury 0 siblings, 1 reply; 31+ messages in thread From: Randy Dunlap @ 2019-10-31 4:32 UTC (permalink / raw) To: Bhaskar Chowdhury Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel On 10/30/19 8:37 PM, Bhaskar Chowdhury wrote: > Thank you Randy, my response are inline. Please look at it.I am > wondering , what else I could do get this damn! thing going?? > Any clue?? > > On 19:33 Wed 30 Oct 2019, Randy Dunlap wrote: >> Hi, >> >> On 10/30/19 2:54 AM, Bhaskar Chowdhury wrote: >>> This patch will remove old kernels and modules directorey related >>> to that kernel from the system by interactively and silently.Here >>> are few interactions with the scripts >>> >>> 1) >>> >>> ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>> 14:52 $ ./scripts/prune-kernel -h >>> Usage: prune-kernel [ri] >>> >>> -r | --remove kernel_ver modules_dir_name >>> >>> -i | --interactive use as interactive way >>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>> 14:52 $ ./scripts/prune-kernel --help >>> Usage: prune-kernel [ri] >> >> That "[ri]" is confusing to me. > This are the options one has to pass with the script.Like below: I know that. But it's missing '-', so it looks like $ prune-kernel r 5.2.5-foobar would work. >>> >>> -r | --remove kernel_ver modules_dir_na] >>> >>> -i | --interactive use as interactive way >>> 2) >>> >>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>> 14:52 $ ./scripts/prune-kernel -r 5.3.3 >>> You need to provide kernel version and modules dir name >>> >>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>> 14:53 $ ./scripts/prune-kernel -r >>> You need to provide kernel version and modules dir name >>> >>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>> 14:54 $ ./scripts/prune-kernel -r 5.3.3 5.3.3-foo >> >> This one above didn't remove any kernel files. >> Needs more testing. > It does remove but silently, as you and Bruce asked for this feature. No, see the code below for -r... >>> 3) >>> >>> $ ./scripts/prune-kernel --remove >>> You need to provide kernel version and modules dir name >>> >>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>> 14:55 $ ./scripts/prune-kernel --remove 5.3.3 >>> You need to provide kernel version and modules dir name >>> >>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>> 14:55 $ ./scripts/prune-kernel --remove 5.3.3 5.3.3-foo >>> >>> >>> 4)14:55 $ ./scripts/prune-kernel -i >>> >>> Enter kernel version to remove or blank/empty to exit: >>> >>> >>> 5)14:57 $ ./scripts/prune-kernel --interactive >>> >>> Enter kernel version to remove or blank/empty to exit: >>> ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>> >>> >>> 6)14:59 $ ./scripts/prune-kernel --interactive >>> >>> Enter kernel version to remove or blank/empty to exit:5.3.3 >>> Please give the full modules directory name to remove:5.3.3-foo >>> >>> >>> >>> Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. >>> >>> >>> 7)15:00 $ ./scripts/prune-kernel -i >>> >>> Enter kernel version to remove or blank/empty to exit:5.3.3 >>> Please give the full modules directory name to remove:5.3.3-foo >>> >>> >>> >>> Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. >>> >>> >>> Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> >>> --- >>> scripts/prune-kernel | 63 ++++++++++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 63 insertions(+) >>> >>> diff --git a/scripts/prune-kernel b/scripts/prune-kernel >>> index a25aa2160d47..a91010d0e2af 100755 >>> --- a/scripts/prune-kernel >>> +++ b/scripts/prune-kernel >>> @@ -1,3 +1,66 @@ >>> #!/bin/bash >>> # SPDX-License-Identifier: GPL-2.0 >>> +#This script will delete old kernels and modules directory related to it >>> +#-h with the script will show you the help >>> +#-r with the script take two parameter: kernel_ver and modules_dir_name >>> +#-i with the script allow you do the removing interactive way >>> >>> +flag=$1 >>> +kernel_ver=$2 >>> +modules_dir_name=$3 >>> +boot_dir=/boot >>> +modules_dir=/lib/modules >>> + >>> +remove_old_kernel() { >>> + cd $boot_dir >>> + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version >>> + return 0 >>> +} >>> + >>> +remove_old_modules_dir() { >>> + cd $modules_dir >>> + rm -rf $modules_version >>> + return 0 >>> +} >>> + >>> +usage() { >>> + printf "Usage: $(basename $0) [ri] \n" >>> + printf "\n -r | --remove kernel_ver modules_dir_name \n" >>> + printf "\n -i | --interactive use as interactive way \n" >>> +} >>> + >>> +for arg in "$@" >> >> what is the purpose (use) of "arg" here? > > This variable is used in case statement below. I can't find any use of 'arg' anywhere else in the script. Please show me where it is. >> what is the purpose of the for loop? >> > It scan through all the parameters pass . What is this script supposed (expected) to do with multiple arg parameters? >> Is any 'shift' needed to consume (or discard) the first 3 positional >> command line arguments? > Nope, that is not required. And I haven't use any. >> >>> +do >>> + case "$flag" in >>> + -i | --interactive) >>> + printf "\nEnter kernel version to remove or blank/empty to exit:%s" >>> + read kernel_version >>> + if [[ $kernel_version != "" ]]; then >>> + remove_old_kernel >>> + printf "Please give the full modules directory name to remove:%s" >>> + read modules_version >>> + if [[ $modules_version != "" ]]; then >>> + remove_old_modules_dir >>> + printf "\n\n\n Removed kernel version:$kernel_version and associated modules:$modules_version ...Done. \n" >> >> This message is only printed if $modules_version is non-empty. If it is empty, >> remove_old_kernel() has silently removed some kernel files (if they existed). > it will fail to remove anything if the kernel_version or modules_version > are empty and importantly exit. >> >>> + else >>> + exit 1 >>> + fi >>> + fi >>> + ;; >>> + -h | --help) >>> + usage >>> + exit 1 >>> + ;; >>> + -r | --remove) >>> + if [[ $# -ne 3 ]]; then >>> + printf "You need to provide kernel version and modules dir name\n" >>> + exit 1 >>> + else >>> + cd $boot_dir >>> + rm -f $kernel_ver >> >> That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. > No,it is not using that function rather take the parameter from the > commandline and get into boot dir match with it and remove it. But it doesn't do that. I tested it. It should be more like what rmeove_old_kernel() does: rm -If vmlinuz-$kernel_ver System.map-$kernel_ver config-$kernel_ver and if not, please explain why not. >>> + cd $modules_dir >>> + rm -rf $modules_dir_name >>> + fi >>> + ;; >>> + esac >>> +done >>> -- >> >> The script, after this patch is applied, still contains the old script's for-loop >> at the end of the "new" prune-kernel script. > > Amazing! now it needs some explanation how I did...you probably want > that ..here are the steps.... > 1)fetch that prune-kernel file from repos , which contains Bruce's code > in it. > 2) get inot it by editior, remove all except first two lines i.e bash > interpreter and PSDX . > 3)Save and commit it locally. > 4) Write my own code > 5) save it and commit it locally. > 6) go one level up use checkpatch to see anything bad creeps in > 7) Fixed the damn things if it reports. > 8) create the patch > 9) test it > 10) Send it. > > Now, how the heck , that for loop is getting staying there is a mystry > to me!! Look like that is ruin all the work. > irk... I don't know. I just know that it's not working AFAICT. -- ~Randy ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 2019-10-31 4:32 ` Randy Dunlap @ 2019-10-31 4:52 ` Bhaskar Chowdhury 2019-10-31 5:27 ` Randy Dunlap 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-10-31 4:52 UTC (permalink / raw) To: Randy Dunlap Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel [-- Attachment #1: Type: text/plain, Size: 9462 bytes --] Thank you so much Randy. I am awfully sorry about the ugly code , hopefully come up with a better one. If I understood your expectation. I know we all are blessed with limited resources like patience.Thanks for holding this long...little more and we will be over it. :) On 21:32 Wed 30 Oct 2019, Randy Dunlap wrote: >On 10/30/19 8:37 PM, Bhaskar Chowdhury wrote: >> Thank you Randy, my response are inline. Please look at it.I am >> wondering , what else I could do get this damn! thing going?? >> Any clue?? >> >> On 19:33 Wed 30 Oct 2019, Randy Dunlap wrote: >>> Hi, >>> >>> On 10/30/19 2:54 AM, Bhaskar Chowdhury wrote: >>>> This patch will remove old kernels and modules directorey related >>>> to that kernel from the system by interactively and silently.Here >>>> are few interactions with the scripts >>>> >>>> 1) >>>> >>>> ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>>> 14:52 $ ./scripts/prune-kernel -h >>>> Usage: prune-kernel [ri] >>>> >>>> -r | --remove kernel_ver modules_dir_name >>>> >>>> -i | --interactive use as interactive way >>>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>>> 14:52 $ ./scripts/prune-kernel --help >>>> Usage: prune-kernel [ri] >>> >>> That "[ri]" is confusing to me. >> This are the options one has to pass with the script.Like below: > >I know that. But it's missing '-', so it looks like >$ prune-kernel r 5.2.5-foobar > >would work. > Will correct that. >>>> >>>> -r | --remove kernel_ver modules_dir_na] >>>> >>>> -i | --interactive use as interactive way >>>> 2) >>>> >>>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>>> 14:52 $ ./scripts/prune-kernel -r 5.3.3 >>>> You need to provide kernel version and modules dir name >>>> >>>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>>> 14:53 $ ./scripts/prune-kernel -r >>>> You need to provide kernel version and modules dir name >>>> >>>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>>> 14:54 $ ./scripts/prune-kernel -r 5.3.3 5.3.3-foo >>> >>> This one above didn't remove any kernel files. >>> Needs more testing. >> It does remove but silently, as you and Bruce asked for this feature. > >No, see the code below for -r... > Okay ...look like some some uniformity missing >>>> 3) >>>> >>>> $ ./scripts/prune-kernel --remove >>>> You need to provide kernel version and modules dir name >>>> >>>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>>> 14:55 $ ./scripts/prune-kernel --remove 5.3.3 >>>> You need to provide kernel version and modules dir name >>>> >>>> ✘-1 ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>>> 14:55 $ ./scripts/prune-kernel --remove 5.3.3 5.3.3-foo >>>> >>>> >>>> 4)14:55 $ ./scripts/prune-kernel -i >>>> >>>> Enter kernel version to remove or blank/empty to exit: >>>> >>>> >>>> 5)14:57 $ ./scripts/prune-kernel --interactive >>>> >>>> Enter kernel version to remove or blank/empty to exit: >>>> ✔ ~/git-linux/linux-kbuild [master|AM 1/1 ↑·59|✔] >>>> >>>> >>>> 6)14:59 $ ./scripts/prune-kernel --interactive >>>> >>>> Enter kernel version to remove or blank/empty to exit:5.3.3 >>>> Please give the full modules directory name to remove:5.3.3-foo >>>> >>>> >>>> >>>> Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. >>>> >>>> >>>> 7)15:00 $ ./scripts/prune-kernel -i >>>> >>>> Enter kernel version to remove or blank/empty to exit:5.3.3 >>>> Please give the full modules directory name to remove:5.3.3-foo >>>> >>>> >>>> >>>> Removed kernel version:5.3.3 and associated modules:5.3.3-foo ...Done. >>>> >>>> >>>> Signed-off-by: Bhaskar Chowdhury <unixbhaskar@gmail.com> >>>> --- >>>> scripts/prune-kernel | 63 ++++++++++++++++++++++++++++++++++++++++++++ >>>> 1 file changed, 63 insertions(+) >>>> >>>> diff --git a/scripts/prune-kernel b/scripts/prune-kernel >>>> index a25aa2160d47..a91010d0e2af 100755 >>>> --- a/scripts/prune-kernel >>>> +++ b/scripts/prune-kernel >>>> @@ -1,3 +1,66 @@ >>>> #!/bin/bash >>>> # SPDX-License-Identifier: GPL-2.0 >>>> +#This script will delete old kernels and modules directory related to it >>>> +#-h with the script will show you the help >>>> +#-r with the script take two parameter: kernel_ver and modules_dir_name >>>> +#-i with the script allow you do the removing interactive way >>>> >>>> +flag=$1 >>>> +kernel_ver=$2 >>>> +modules_dir_name=$3 >>>> +boot_dir=/boot >>>> +modules_dir=/lib/modules >>>> + >>>> +remove_old_kernel() { >>>> + cd $boot_dir >>>> + rm -If vmlinuz-$kernel_version System.map-$kernel_version config-$kernel_version >>>> + return 0 >>>> +} >>>> + >>>> +remove_old_modules_dir() { >>>> + cd $modules_dir >>>> + rm -rf $modules_version >>>> + return 0 >>>> +} >>>> + >>>> +usage() { >>>> + printf "Usage: $(basename $0) [ri] \n" >>>> + printf "\n -r | --remove kernel_ver modules_dir_name \n" >>>> + printf "\n -i | --interactive use as interactive way \n" >>>> +} >>>> + >>>> +for arg in "$@" >>> >>> what is the purpose (use) of "arg" here? >> >> This variable is used in case statement below. > >I can't find any use of 'arg' anywhere else in the script. >Please show me where it is. My bad and apologies for overlooking. > >>> what is the purpose of the for loop? >>> >> It scan through all the parameters pass . > >What is this script supposed (expected) to do with multiple arg parameters? > It uses multiple parameter >>> Is any 'shift' needed to consume (or discard) the first 3 positional >>> command line arguments? >> Nope, that is not required. And I haven't use any. >>> >>>> +do >>>> + case "$flag" in >>>> + -i | --interactive) >>>> + printf "\nEnter kernel version to remove or blank/empty to exit:%s" >>>> + read kernel_version >>>> + if [[ $kernel_version != "" ]]; then >>>> + remove_old_kernel >>>> + printf "Please give the full modules directory name to remove:%s" >>>> + read modules_version >>>> + if [[ $modules_version != "" ]]; then >>>> + remove_old_modules_dir >>>> + printf "\n\n\n Removed kernel version:$kernel_version and associated modules:$modules_version ...Done. \n" >>> >>> This message is only printed if $modules_version is non-empty. If it is empty, >>> remove_old_kernel() has silently removed some kernel files (if they existed). >> it will fail to remove anything if the kernel_version or modules_version >> are empty and importantly exit. >>> >>>> + else >>>> + exit 1 >>>> + fi >>>> + fi >>>> + ;; >>>> + -h | --help) >>>> + usage >>>> + exit 1 >>>> + ;; >>>> + -r | --remove) >>>> + if [[ $# -ne 3 ]]; then >>>> + printf "You need to provide kernel version and modules dir name\n" >>>> + exit 1 >>>> + else >>>> + cd $boot_dir >>>> + rm -f $kernel_ver >>> >>> That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. >> No,it is not using that function rather take the parameter from the >> commandline and get into boot dir match with it and remove it. > >But it doesn't do that. I tested it. It should be more like what >rmeove_old_kernel() does: > > rm -If vmlinuz-$kernel_ver System.map-$kernel_ver config-$kernel_ver > >and if not, please explain why not. Okay, again some uniformity missing in the code, I would like to your suggested method,i.e call remove_old_kernel to do the job instead of depending on individual kernel. > > >>>> + cd $modules_dir >>>> + rm -rf $modules_dir_name >>>> + fi >>>> + ;; >>>> + esac >>>> +done >>>> -- >>> >>> The script, after this patch is applied, still contains the old script's for-loop >>> at the end of the "new" prune-kernel script. >> >> Amazing! now it needs some explanation how I did...you probably want >> that ..here are the steps.... >> 1)fetch that prune-kernel file from repos , which contains Bruce's code >> in it. >> 2) get inot it by editior, remove all except first two lines i.e bash >> interpreter and PSDX . >> 3)Save and commit it locally. >> 4) Write my own code >> 5) save it and commit it locally. >> 6) go one level up use checkpatch to see anything bad creeps in >> 7) Fixed the damn things if it reports. >> 8) create the patch >> 9) test it >> 10) Send it. >> >> Now, how the heck , that for loop is getting staying there is a mystry >> to me!! Look like that is ruin all the work. >> irk... > >I don't know. I just know that it's not working AFAICT. Thank you, will be more vigilant in next iteration. > >-- >~Randy > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 2019-10-31 4:52 ` Bhaskar Chowdhury @ 2019-10-31 5:27 ` Randy Dunlap 2019-10-31 7:18 ` Bhaskar Chowdhury 0 siblings, 1 reply; 31+ messages in thread From: Randy Dunlap @ 2019-10-31 5:27 UTC (permalink / raw) To: Bhaskar Chowdhury Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel On 10/30/19 9:52 PM, Bhaskar Chowdhury wrote: >>>> That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. >>> No,it is not using that function rather take the parameter from the >>> commandline and get into boot dir match with it and remove it. >> >> But it doesn't do that. I tested it. It should be more like what >> rmeove_old_kernel() does: >> >> rm -If vmlinuz-$kernel_ver System.map-$kernel_ver config-$kernel_ver >> >> and if not, please explain why not. > Okay, again some uniformity missing in the code, I would like to your > suggested method,i.e call remove_old_kernel to do the job instead of depending on individual kernel. The simplest thing to do is set kernel_version=$kernel_ver and then call remove_old_kernel(). And set modules_version=$modules_dir_name and call remove_old_modules_dir(). But it would be cleaner to pass a parameter (kernel_version) to the remove_old_kernel() function and to pass a parameter (modules_dir) to the remove_old_modules_dir() function. -- ~Randy ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 2019-10-31 5:27 ` Randy Dunlap @ 2019-10-31 7:18 ` Bhaskar Chowdhury 2019-10-31 15:06 ` Randy Dunlap 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-10-31 7:18 UTC (permalink / raw) To: Randy Dunlap Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel [-- Attachment #1: Type: text/plain, Size: 2019 bytes --] On 22:27 Wed 30 Oct 2019, Randy Dunlap wrote: >On 10/30/19 9:52 PM, Bhaskar Chowdhury wrote: >>>>> That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. >>>> No,it is not using that function rather take the parameter from the >>>> commandline and get into boot dir match with it and remove it. >>> >>> But it doesn't do that. I tested it. It should be more like what >>> rmeove_old_kernel() does: >>> >>> rm -If vmlinuz-$kernel_ver System.map-$kernel_ver config-$kernel_ver >>> >>> and if not, please explain why not. >> Okay, again some uniformity missing in the code, I would like to your >> suggested method,i.e call remove_old_kernel to do the job instead of depending on individual kernel. > >The simplest thing to do is set kernel_version=$kernel_ver >and then call remove_old_kernel(). >And set modules_version=$modules_dir_name and call remove_old_modules_dir(). > >But it would be cleaner to pass a parameter (kernel_version) to the >remove_old_kernel() function and to pass a parameter (modules_dir) to the >remove_old_modules_dir() function. > Thank you...I have just modified the code and call both the function under remove option. BTW I didn't set the extra variable $kernel_ver name it $kernel_version and instead of $modules_dir_name name it $mo dules_version. Capturing command line parameter in $kernel_version and $modules_version Is that fine? Here is a code snippet: -r | --remove) if [[ $# -ne 3 ]]; then printf "You need to provide kernel version and modules directory name \n" exit 1 else remove_old_kernel remove_old_modules_dir fi I have just test it and it works. And about solitary r option without hypen is ignoring and doing nothing. Means, if I pass ./scripts/prune-kernel r 5.3.3 it simply ignore and does nothing.Only with the hypen it can work. >-- >~Randy > Bhaskar [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 2019-10-31 7:18 ` Bhaskar Chowdhury @ 2019-10-31 15:06 ` Randy Dunlap 2019-11-01 4:23 ` Bhaskar Chowdhury 0 siblings, 1 reply; 31+ messages in thread From: Randy Dunlap @ 2019-10-31 15:06 UTC (permalink / raw) To: Bhaskar Chowdhury Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel On 10/31/19 12:18 AM, Bhaskar Chowdhury wrote: > On 22:27 Wed 30 Oct 2019, Randy Dunlap wrote: >> On 10/30/19 9:52 PM, Bhaskar Chowdhury wrote: >>>>>> That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. >>>>> No,it is not using that function rather take the parameter from the >>>>> commandline and get into boot dir match with it and remove it. >>>> >>>> But it doesn't do that. I tested it. It should be more like what >>>> rmeove_old_kernel() does: >>>> >>>> rm -If vmlinuz-$kernel_ver System.map-$kernel_ver config-$kernel_ver >>>> >>>> and if not, please explain why not. >>> Okay, again some uniformity missing in the code, I would like to your >>> suggested method,i.e call remove_old_kernel to do the job instead of depending on individual kernel. >> >> The simplest thing to do is set kernel_version=$kernel_ver >> and then call remove_old_kernel(). >> And set modules_version=$modules_dir_name and call remove_old_modules_dir(). >> >> But it would be cleaner to pass a parameter (kernel_version) to the >> remove_old_kernel() function and to pass a parameter (modules_dir) to the >> remove_old_modules_dir() function. > >> > > Thank you...I have just modified the code and call both the function > under remove option. BTW I didn't set the extra variable $kernel_ver name it $kernel_version and instead of $modules_dir_name name it $mo > dules_version. > > Capturing command line parameter in $kernel_version and $modules_version > > Is that fine? Here is a code snippet: Yes, that should be OK. > -r | --remove) > if [[ $# -ne 3 ]]; then > printf "You need to provide kernel version and modules directory > name \n" > exit 1 > else > remove_old_kernel > remove_old_modules_dir > fi > > > I have just test it and it works. > > > And about solitary r option without hypen is ignoring and doing nothing. > > Means, if I pass ./scripts/prune-kernel r 5.3.3 > it simply ignore and does nothing.Only with the hypen it can work. Is that how it should be? or what would you expect that to do? -- ~Randy ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 2019-10-31 15:06 ` Randy Dunlap @ 2019-11-01 4:23 ` Bhaskar Chowdhury 2019-11-01 5:11 ` Bhaskar Chowdhury 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-01 4:23 UTC (permalink / raw) To: Randy Dunlap Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel [-- Attachment #1: Type: text/plain, Size: 2567 bytes --] On 08:06 Thu 31 Oct 2019, Randy Dunlap wrote: >On 10/31/19 12:18 AM, Bhaskar Chowdhury wrote: >> On 22:27 Wed 30 Oct 2019, Randy Dunlap wrote: >>> On 10/30/19 9:52 PM, Bhaskar Chowdhury wrote: >>>>>>> That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. >>>>>> No,it is not using that function rather take the parameter from the >>>>>> commandline and get into boot dir match with it and remove it. >>>>> >>>>> But it doesn't do that. I tested it. It should be more like what >>>>> rmeove_old_kernel() does: >>>>> >>>>> rm -If vmlinuz-$kernel_ver System.map-$kernel_ver config-$kernel_ver >>>>> >>>>> and if not, please explain why not. >>>> Okay, again some uniformity missing in the code, I would like to your >>>> suggested method,i.e call remove_old_kernel to do the job instead of depending on individual kernel. >>> >>> The simplest thing to do is set kernel_version=$kernel_ver >>> and then call remove_old_kernel(). >>> And set modules_version=$modules_dir_name and call remove_old_modules_dir(). >>> >>> But it would be cleaner to pass a parameter (kernel_version) to the >>> remove_old_kernel() function and to pass a parameter (modules_dir) to the >>> remove_old_modules_dir() function. >> >>> >> >> Thank you...I have just modified the code and call both the function >> under remove option. BTW I didn't set the extra variable $kernel_ver name it $kernel_version and instead of $modules_dir_name name it $mo >> dules_version. >> >> Capturing command line parameter in $kernel_version and $modules_version >> >> Is that fine? Here is a code snippet: > >Yes, that should be OK. > >> -r | --remove) >> if [[ $# -ne 3 ]]; then >> printf "You need to provide kernel version and modules directory >> name \n" >> exit 1 >> else >> remove_old_kernel >> remove_old_modules_dir >> fi >> >> >> I have just test it and it works. >> >> >> And about solitary r option without hypen is ignoring and doing nothing. >> >> Means, if I pass ./scripts/prune-kernel r 5.3.3 >> it simply ignore and does nothing.Only with the hypen it can work. > >Is that how it should be? >or what would you expect that to do? Yes it should be. Any malformed parameter should be discarded,except what explicitly given in code form,as help reminder. OR Do you want me to reminds user that they are missing thing to operate correctly?? > >-- >~Randy Bhaskar > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 2019-11-01 4:23 ` Bhaskar Chowdhury @ 2019-11-01 5:11 ` Bhaskar Chowdhury 2019-11-01 5:45 ` Randy Dunlap 0 siblings, 1 reply; 31+ messages in thread From: Bhaskar Chowdhury @ 2019-11-01 5:11 UTC (permalink / raw) To: Randy Dunlap Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel [-- Attachment #1: Type: text/plain, Size: 3516 bytes --] On 09:53 Fri 01 Nov 2019, Bhaskar Chowdhury wrote: >On 08:06 Thu 31 Oct 2019, Randy Dunlap wrote: >>On 10/31/19 12:18 AM, Bhaskar Chowdhury wrote: >>> On 22:27 Wed 30 Oct 2019, Randy Dunlap wrote: >>>> On 10/30/19 9:52 PM, Bhaskar Chowdhury wrote: >>>>>>>> That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. >>>>>>> No,it is not using that function rather take the parameter from the >>>>>>> commandline and get into boot dir match with it and remove it. >>>>>> >>>>>> But it doesn't do that. I tested it. It should be more like what >>>>>> rmeove_old_kernel() does: >>>>>> >>>>>> rm -If vmlinuz-$kernel_ver System.map-$kernel_ver config-$kernel_ver >>>>>> >>>>>> and if not, please explain why not. >>>>> Okay, again some uniformity missing in the code, I would like to your >>>>> suggested method,i.e call remove_old_kernel to do the job instead of depending on individual kernel. >>>> >>>> The simplest thing to do is set kernel_version=$kernel_ver >>>> and then call remove_old_kernel(). >>>> And set modules_version=$modules_dir_name and call remove_old_modules_dir(). >>>> >>>> But it would be cleaner to pass a parameter (kernel_version) to the >>>> remove_old_kernel() function and to pass a parameter (modules_dir) to the >>>> remove_old_modules_dir() function. >>> >>>> >>> >>> Thank you...I have just modified the code and call both the function >>> under remove option. BTW I didn't set the extra variable $kernel_ver name it $kernel_version and instead of $modules_dir_name name it $mo >>> dules_version. >>> >>> Capturing command line parameter in $kernel_version and $modules_version >>> >>> Is that fine? Here is a code snippet: >> >>Yes, that should be OK. >> >>> -r | --remove) >>> if [[ $# -ne 3 ]]; then >>> printf "You need to provide kernel version and modules directory >>> name \n" >>> exit 1 >>> else >>> remove_old_kernel >>> remove_old_modules_dir >>> fi >>> >>> >>> I have just test it and it works. >>> >>> >>> And about solitary r option without hypen is ignoring and doing nothing. >>> >>> Means, if I pass ./scripts/prune-kernel r 5.3.3 >>> it simply ignore and does nothing.Only with the hypen it can work. >> >>Is that how it should be? >>or what would you expect that to do? >Yes it should be. Any malformed parameter should be discarded,except >what explicitly given in code form,as help reminder. >OR >Do you want me to reminds user that they are missing thing to operate >correctly?? > >> >>-- >>~Randy >Bhaskar >> Randy, I think we should show the help message , whenever user put a malformed parameter, say they put something like this : ./scripts/prune-kernel f 5.3.3 It should show the help message to indicate what exactly need to pass with the script to get the desired result. What do you think?? ~Bhaskar >-----BEGIN PGP SIGNATURE----- > >iQEzBAABCAAdFiEEnwF+nWawchZUPOuwsjqdtxFLKRUFAl27s0EACgkQsjqdtxFL >KRV81wf/cMmIASLvGNbAxdbZY/7xnsdsaOWLsfH5c4twHsVwm74Zbasdq8s1l5Kn >z8CZeWxKOKsItEY52g2vXbyDMFkk2La77kHZo4O5hQOmenRMaD9M7wcWqSCOJg59 >EbhMUt7RLpJLDKYTtegoGIyNgVZXfV8PpH6iKIvNscyJPMNBvppgRKkn80MWoG7k >i0rMI6kvchwilxhVz/LPbJgKrIayhriKIBfTbDracSdX+WtJMQbAjdWRgGk0rmGe >wS0p8nwJmmqXSc/qrrgZPR9VxsknVNMm/PzKS9CTE+GvELjXS8MeG3iwauQ4hx2K >B255AW+zobp0IQGwTqH7VwO0u2GzLQ== >=3y5/ >-----END PGP SIGNATURE----- [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH] scripts: prune-kernel:remove old kernels and modules dir from system 2019-11-01 5:11 ` Bhaskar Chowdhury @ 2019-11-01 5:45 ` Randy Dunlap 0 siblings, 0 replies; 31+ messages in thread From: Randy Dunlap @ 2019-11-01 5:45 UTC (permalink / raw) To: Bhaskar Chowdhury Cc: bfields, yamada.masahiro, michal.lkml, linux-kbuild, linux-kernel On 10/31/19 10:11 PM, Bhaskar Chowdhury wrote: > On 09:53 Fri 01 Nov 2019, Bhaskar Chowdhury wrote: >> On 08:06 Thu 31 Oct 2019, Randy Dunlap wrote: >>> On 10/31/19 12:18 AM, Bhaskar Chowdhury wrote: >>>> On 22:27 Wed 30 Oct 2019, Randy Dunlap wrote: >>>>> On 10/30/19 9:52 PM, Bhaskar Chowdhury wrote: >>>>>>>>> That 'rm' doesn't remove any files. Compare what remove_old_kernel() does. >>>>>>>> No,it is not using that function rather take the parameter from the >>>>>>>> commandline and get into boot dir match with it and remove it. >>>>>>> >>>>>>> But it doesn't do that. I tested it. It should be more like what >>>>>>> rmeove_old_kernel() does: >>>>>>> >>>>>>> rm -If vmlinuz-$kernel_ver System.map-$kernel_ver config-$kernel_ver >>>>>>> >>>>>>> and if not, please explain why not. >>>>>> Okay, again some uniformity missing in the code, I would like to your >>>>>> suggested method,i.e call remove_old_kernel to do the job instead of depending on individual kernel. >>>>> >>>>> The simplest thing to do is set kernel_version=$kernel_ver >>>>> and then call remove_old_kernel(). >>>>> And set modules_version=$modules_dir_name and call remove_old_modules_dir(). >>>>> >>>>> But it would be cleaner to pass a parameter (kernel_version) to the >>>>> remove_old_kernel() function and to pass a parameter (modules_dir) to the >>>>> remove_old_modules_dir() function. >>>> >>>>> >>>> >>>> Thank you...I have just modified the code and call both the function >>>> under remove option. BTW I didn't set the extra variable $kernel_ver name it $kernel_version and instead of $modules_dir_name name it $mo >>>> dules_version. >>>> >>>> Capturing command line parameter in $kernel_version and $modules_version >>>> >>>> Is that fine? Here is a code snippet: >>> >>> Yes, that should be OK. >>> >>>> -r | --remove) >>>> if [[ $# -ne 3 ]]; then >>>> printf "You need to provide kernel version and modules directory >>>> name \n" >>>> exit 1 >>>> else >>>> remove_old_kernel >>>> remove_old_modules_dir >>>> fi >>>> >>>> >>>> I have just test it and it works. >>>> >>>> >>>> And about solitary r option without hypen is ignoring and doing nothing. >>>> >>>> Means, if I pass ./scripts/prune-kernel r 5.3.3 >>>> it simply ignore and does nothing.Only with the hypen it can work. >>> >>> Is that how it should be? >>> or what would you expect that to do? >> Yes it should be. Any malformed parameter should be discarded,except >> what explicitly given in code form,as help reminder. >> OR >> Do you want me to reminds user that they are missing thing to operate >> correctly?? >>> >>> -- >>> ~Randy >> Bhaskar >>> > Randy, > > I think we should show the help message , whenever user put a malformed > parameter, say they put something like this : > > ./scripts/prune-kernel f 5.3.3 > > It should show the help message to indicate what exactly need to pass > with the script to get the desired result. > > What do you think?? I agree. Entering garbage junk should spit out help. -- ~Randy ^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2019-11-18 7:31 UTC | newest] Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 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
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.