{"id":567,"date":"2023-08-13T13:29:16","date_gmt":"2023-08-13T11:29:16","guid":{"rendered":"https:\/\/anjo.pt\/keyword-oracle\/?p=567"},"modified":"2023-08-26T17:53:19","modified_gmt":"2023-08-26T15:53:19","slug":"new-opatch-util-deleteinactivepatches-tool-for-reducing-the-oracle_home-size","status":"publish","type":"post","link":"https:\/\/anjo.pt\/keyword-oracle\/2023\/08\/13\/new-opatch-util-deleteinactivepatches-tool-for-reducing-the-oracle_home-size\/","title":{"rendered":"New &#8220;OPatch util DeleteInactivePatches&#8221; tool for reducing the $ORACLE_HOME size"},"content":{"rendered":"\n<p>When you are a sensible person, you patch regularly your Oracle database. After a few years, maybe you noticed that the $ORACLE_HOME increased size from new ~7 GB to &#8230;. 26 GB!<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ du -hs \/u00\/app\/oracle\/product\/19.18.0\n26G     \/u00\/app\/oracle\/product\/19.18.0\n<\/pre><\/div>\n\n\n<p>Looking better, you find the culprit is the hidden directory <code>$ORACLE_HOME\/.patch_storage<\/code> :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ du -hs \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\n17G     \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\n<\/pre><\/div>\n\n\n<p>Today I show how a new option from OPatch allowed me to regain 11 GB of disk space in a couple of minutes. In a supported way. <\/p>\n\n\n\n<p>Last year I had already presented <a href=\"https:\/\/anjo.pt\/keyword-oracle\/2022\/02\/15\/the-opatch-patch_storage-and-its-space-issues-the-solutions\/\" data-type=\"post\" data-id=\"533\">other options to recover space from Oracle Patching<\/a>. Below I remind them, but todays post is about the latest and improved way that OPatch tool has to keep only the usual needed patch backups.<\/p>\n\n\n\n<!--more Read More-->\n\n\n\n<p>The .patch_storage directory inside an Oracle Home has the backup of every changed files when we patch the database software. And this just increases. Check this example of .patch_storage in a a regularly patched DB at my customer, ordered by folder size:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ du -hs \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/* | sort -h\n\n4.0K    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/LatestOPatchSession.properties\n68K     \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/newdirs.txt\n76K     \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47\n88K     \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/record_inventory.txt\n164K    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/NApply\n188K    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/interim_inventory.txt\n248K    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29517242_Apr_17_2019_23_27_10\n216M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/33529556_Jan_9_2022_21_15_36\n217M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/32916816_Jul_19_2021_01_56_39\n217M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/34768559_Jan_14_2023_07_39_49\n218M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29850993_Jul_5_2019_05_08_35\n220M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/34160635_Jul_10_2022_21_27_08\n223M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/32222571_Jan_15_2021_01_49_46\n227M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/30489227_Jan_7_2020_03_37_45\n228M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/31305087_Jun_25_2020_11_36_08\n425M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/30484981_Dec_5_2019_05_10_10\n426M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/31219897_Jul_8_2020_01_57_16\n427M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/32067171_Dec_2_2020_09_24_57\n432M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/32876380_Jul_5_2021_04_53_50\n432M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/33561310_Jan_5_2022_08_13_10\n432M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/34086870_May_31_2022_05_49_37\n432M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/34786990_Dec_6_2022_13_24_50\n725M    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29834717_Jul_10_2019_02_09_26\n1.2G    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/30557433_Jan_6_2020_19_07_34\n1.4G    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/31281355_Jul_6_2020_11_18_02\n1.7G    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/32218454_Jan_14_2021_16_24_38\n1.7G    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/33515361_Jan_13_2022_06_14_07\n1.9G    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/32904851_Jul_20_2021_09_21_24\n1.9G    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/34765931_Jan_27_2023_11_25_14\n2.0G    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/34133642_Jul_14_2022_16_09_56\n<\/pre><\/div>\n\n\n<p>These backups allow to rollback the $ORACLE_HOME to all previous point in time. However we are very unlikely to do it. While it is possible just delete the contents of the $ORACLE_HOME\/.patch_storage and usually there is no issue, this is not supported.<\/p>\n\n\n\n<p>But did you already hit the problem that you don&#8217;t have enough space for patching? <a href=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/19\/ladbi\/storage-checklist-for-oracle-database-installation.html#GUID-C6184DFA-45A2-4420-99D6-237EA5BAB058:~:text=Oracle%20recommends%20that%20you%20allocate%20approximately%20100%20GB%20to%20allow%20additional%20space%20for%20applying%20any%20future%20patches%20on%20top%20of%20the%20existing%20Oracle%20home\" target=\"_blank\" rel=\"noreferrer noopener\">Oracle recommends a 100 GB partition for the $ORACLE_HOME<\/a>, but is it really needed?<\/p>\n\n\n\n<p>This post is not about patching, but how to clean-up the .patch_storage directory in a supported way. And mostly about my experience about the recent new feature of OPatch to delete inactive patches from the ORACLE_HOME.<\/p>\n\n\n\n<p>Several years ago, the following option was added to Opatch:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ORACLE_HOME\/OPatch\/opatch until cleanup\n<\/pre><\/div>\n\n\n<p>which &#8220;cleans up &#8216;restore.sh,make.txt&#8217; files and &#8216;scratch,backup&#8217; directories of the.patch_storage directory of Oracle Home.&#8221;<\/p>\n\n\n\n<p>Later, there was the possibility to &#8220;archive&#8221; the .patch_storage elsewhere:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ORACLE_HOME\/OPatch\/opatch archive\n<\/pre><\/div>\n\n\n<p>which &#8220;helps to archive the patches stored under ORACLE_HOME\/.patch_storage to custom storage location&#8221;. And adds to the help:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nRECOMMENDATION :\n  To archive patches, opatch recommends the following\n    1. Archiving inactive patches :\n        Run the following command to get inactive patches :  &quot;OPatch\/opatch lsinv -inactive&quot;\n\nExample\n        opatch util archive -patches 123456,1122334 -archive_dir \/dir1\/dir2\/\n<\/pre><\/div>\n\n\n<p>In 2023, since OPatch version 12.2.0.1.37 (current is 12.2.0.1.39), there is a merge of the two tools, which finally allows to use OPatch to delete old inactive patches, keeping only the last one that is not active:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ORACLE_HOME\/OPatch\/opatch util DeleteInactivePatches\n<\/pre><\/div>\n\n\n<p>which &#8220;helps to clean up inactive patches stored under ORACLE_HOME\/inventory &amp; ORACLE_HOME\/.patch_storage&#8221;<\/p>\n\n\n\n<p>More over it says:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nBy default OPatch util deleteinactivepatches retains only 1 latest inactive patch(RU\\CPU\\BP)\nNote: If user needs to retain more than 1 inactive patch, then update the value of RETAIN_INACTIVE_PATCHES in\nORACLE_HOME\/OPatch\/config\/opatch.properties\n<\/pre><\/div>\n\n\n<p>There is also a list only function:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ORACLE_HOME\/OPatch\/opatch util ListOrderedInactivePatches\n<\/pre><\/div>\n\n\n<p>which is the same as calling the delete function with -report switch:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ORACLE_HOME\/OPatch\/opatch util DeleteInactivePatches -report\n<\/pre><\/div>\n\n\n<p>In my case, here the huge list of patches that comes from its run:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ORACLE_HOME\/OPatch\/opatch util DeleteInactivePatches -report\n\nOracle Interim Patch Installer version 12.2.0.1.39\nCopyright (c) 2023, Oracle Corporation.  All rights reserved.\n\nOracle Home       : \/u00\/app\/oracle\/product\/19.18.0\nCentral Inventory : \/u00\/app\/OraInventory\n   from           : \/u00\/app\/oracle\/product\/19.18.0\/oraInst.loc\nOPatch version    : 12.2.0.1.39\nOUI version       : 12.2.0.7.0\nLog file location : \/u00\/app\/oracle\/product\/19.18.0\/cfgtoollogs\/opatch\/opatch2023-08-08_17-09-04PM_1.log\n\nInvoking utility &quot;deleteinactivepatches&quot;\nInactive Patches Cleanup option provided\nDelete Inactive Patches .......\n\n***** There are 8 inactive RU patches in chain 1\n\n***** 7 inactive patches will be deleted\n-To be deleted inactive RU\/BP 29585399:OCW RELEASE UPDATE 19.3.0.0.0 (29585399), installed on: Thu Apr 18 09:21:33 CEST 2019, with no overlays\n-To be deleted inactive RU\/BP 29850993:OCW RELEASE UPDATE 19.4.0.0.0 (29850993), installed on: Mon Jul 29 15:14:19 CEST 2019, with no overlays\n-To be deleted inactive RU\/BP 30489227:OCW RELEASE UPDATE 19.6.0.0.0 (30489227), installed on: Mon Feb 03 09:37:21 CET 2020, with no overlays\n-To be deleted inactive RU\/BP 31305087:OCW RELEASE UPDATE 19.8.0.0.0 (31305087), installed on: Tue Oct 13 13:27:46 CEST 2020, with no overlays\n-To be deleted inactive RU\/BP 32222571:OCW Interim patch for 32222571, installed on: Tue Mar 09 12:50:27 CET 2021, with no overlays\n-To be deleted inactive RU\/BP 32916816:OCW RELEASE UPDATE 19.12.0.0.0 (32916816), installed on: Fri Sep 24 11:26:21 CEST 2021, with no overlays\n-To be deleted inactive RU\/BP 33529556:OCW RELEASE UPDATE 19.14.0.0.0 (33529556), installed on: Thu Feb 10 14:09:40 CET 2022, with no overlays\n-To be retained inactive RU\/BP 34160635:OCW RELEASE UPDATE 19.16.0.0.0 (34160635), installed on: Thu Dec 15 15:13:06 CET 2022, with no overlays\n-Active RU\/BP 34768559:OCW RELEASE UPDATE 19.18.0.0.0 (34768559), installed on: Tue Mar 14 10:18:46 CET 2023, with no overlays\n\n***** There are 8 inactive RU patches in chain 2\n\n***** 7 inactive patches will be deleted\n-To be deleted inactive RU\/BP 29517242:Database Release Update : 19.3.0.0.190416 (29517242), installed on: Thu Apr 18 09:21:17 CEST 2019, with no overlays\n-To be deleted inactive RU\/BP 29834717:Database Release Update : 19.4.0.0.190716 (29834717), installed on: Mon Jul 29 15:12:44 CEST 2019, with no overlays\n-To be deleted inactive RU\/BP 30557433:Database Release Update : 19.6.0.0.200114 (30557433), installed on: Mon Feb 03 09:39:40 CET 2020, with no overlays\n-To be deleted inactive RU\/BP 31281355:Database Release Update : 19.8.0.0.200714 (31281355), installed on: Tue Oct 13 13:23:33 CEST 2020, with no overlays\n-To be deleted inactive RU\/BP 32218454:Database Release Update : 19.10.0.0.210119 (32218454), installed on: Tue Mar 09 12:42:54 CET 2021, with no overlays\n-To be deleted inactive RU\/BP 32904851:Database Release Update : 19.12.0.0.210720 (32904851), installed on: Fri Sep 24 11:17:00 CEST 2021, with no overlays\n-To be deleted inactive RU\/BP 33515361:Database Release Update : 19.14.0.0.220118 (33515361), installed on: Thu Feb 10 14:02:39 CET 2022, with no overlays\n-To be retained inactive RU\/BP 34133642:Database Release Update : 19.16.0.0.220719 (34133642), installed on: Thu Dec 15 15:07:21 CET 2022, with no overlays\n-Active RU\/BP 34765931:DATABASE RELEASE UPDATE : 19.18.0.0.230117 (REL-JAN230131) (34765931), installed on: Tue Mar 14 10:12:42 CET 2023, with no overlays\n\n***** There are 6 inactive RU patches in chain 3\n\n***** 5 inactive patches will be deleted\n-To be deleted inactive RU\/BP 30484981:OJVM RELEASE UPDATE: 19.6.0.0.200114 (30484981), installed on: Mon Feb 03 09:26:39 CET 2020, with no overlays\n-To be deleted inactive RU\/BP 31219897:OJVM RELEASE UPDATE: 19.8.0.0.200714 (31219897), installed on: Tue Oct 13 13:20:35 CEST 2020, with no overlays\n-To be deleted inactive RU\/BP 32067171:OJVM RELEASE UPDATE: 19.10.0.0.210119 (32067171), installed on: Tue Mar 09 12:38:35 CET 2021, with no overlays\n-To be deleted inactive RU\/BP 32876380:OJVM RELEASE UPDATE: 19.12.0.0.210720 (32876380), installed on: Fri Sep 24 11:10:35 CEST 2021, with no overlays\n-To be deleted inactive RU\/BP 33561310:OJVM RELEASE UPDATE: 19.14.0.0.220118 (33561310), installed on: Thu Feb 10 14:12:21 CET 2022, with no overlays\n-To be retained inactive RU\/BP 34086870:OJVM RELEASE UPDATE: 19.16.0.0.220719 (34086870), installed on: Thu Dec 15 15:05:34 CET 2022, with no overlays\n-Active RU\/BP 34786990:OJVM RELEASE UPDATE: 19.18.0.0.230117 (34786990), installed on: Tue Mar 14 10:19:19 CET 2023, with no overlays\n\nOPatch is in report mode. No actual deletion happened. Reporting is done.\n\nOPatch succeeded.\n<\/pre><\/div>\n\n\n<p>Just to write this report, it took about 2 minutes. I could not find why it took so long.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ time $ORACLE_HOME\/OPatch\/opatch util ListOrderedInactivePatches\n...\nreal    2m46.644s\nuser    2m48.534s\nsys     0m2.317s\n<\/pre><\/div>\n\n\n<p>These are the contents of my .patch_storage folder:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ ls -altr $ORACLE_HOME\/.patch_storage\n\ntotal 360\ndrwxr-xr-x.  3 oracle dba     74 Apr 18  2019 29517242_Apr_17_2019_23_27_10\ndrwxr-xr-x.  3 oracle dba     74 Apr 18  2019 29585399_Apr_9_2019_19_12_47\ndrwxr-xr-x.  4 oracle dba     87 Jul 29  2019 29834717_Jul_10_2019_02_09_26\ndrwxr-xr-x.  4 oracle dba     87 Jul 29  2019 29850993_Jul_5_2019_05_08_35\ndrwxr-xr-x.  4 oracle dba     87 Feb  3  2020 30484981_Dec_5_2019_05_10_10\ndrwxr-xr-x.  4 oracle dba     87 Feb  3  2020 30489227_Jan_7_2020_03_37_45\ndrwxr-xr-x.  4 oracle dba     87 Feb  3  2020 30557433_Jan_6_2020_19_07_34\ndrwxr-xr-x.  4 oracle dba     87 Oct 13  2020 31219897_Jul_8_2020_01_57_16\ndrwxr-xr-x.  4 oracle dba     87 Oct 13  2020 31281355_Jul_6_2020_11_18_02\ndrwxr-xr-x.  4 oracle dba     87 Oct 13  2020 31305087_Jun_25_2020_11_36_08\ndrwxr-xr-x.  4 oracle dba     87 Mar  9  2021 32067171_Dec_2_2020_09_24_57\ndrwxr-xr-x.  4 oracle dba     87 Mar  9  2021 32218454_Jan_14_2021_16_24_38\ndrwxr-xr-x.  4 oracle dba     87 Mar  9  2021 32222571_Jan_15_2021_01_49_46\ndrwxr-xr-x.  4 oracle dba     87 Sep 24  2021 32876380_Jul_5_2021_04_53_50\ndrwxr-xr-x.  4 oracle dba     87 Sep 24  2021 32904851_Jul_20_2021_09_21_24\ndrwxr-xr-x.  4 oracle dba     87 Sep 24  2021 32916816_Jul_19_2021_01_56_39\ndrwxr-xr-x.  4 oracle dba     87 Feb 10  2022 33515361_Jan_13_2022_06_14_07\ndrwxr-xr-x.  4 oracle dba     87 Feb 10  2022 33529556_Jan_9_2022_21_15_36\ndrwxr-xr-x.  4 oracle dba     87 Feb 10  2022 33561310_Jan_5_2022_08_13_10\ndrwxr-xr-x.  4 oracle dba     87 Dec 15  2022 34086870_May_31_2022_05_49_37\ndrwxr-xr-x.  4 oracle dba     87 Dec 15  2022 34133642_Jul_14_2022_16_09_56\ndrwxr-xr-x.  4 oracle dba     87 Dec 15  2022 34160635_Jul_10_2022_21_27_08\ndrwxr-xr-x. 42 oracle dba   4096 Mar 14 10:10 NApply\n-rw-r--r--.  1 oracle dba  87836 Mar 14 10:10 record_inventory.txt\n-rw-r--r--.  1 oracle dba 190461 Mar 14 10:10 interim_inventory.txt\n-rw-r--r--.  1 oracle dba  67011 Mar 14 10:18 newdirs.txt\n-rw-r--r--.  1 oracle dba     92 Mar 14 10:19 LatestOPatchSession.properties\ndrwxr-xr-x.  4 oracle dba     87 Mar 14 10:20 34765931_Jan_27_2023_11_25_14\ndrwxr-xr-x.  4 oracle dba     87 Mar 14 10:20 34768559_Jan_14_2023_07_39_49\ndrwxr-xr-x.  4 oracle dba     87 Mar 14 10:20 34786990_Dec_6_2022_13_24_50\ndrwxr-xr-x. 74 oracle dba   4096 Jul 25 23:58 ..\ndrwx------. 28 oracle dba   4096 Aug 11 11:26 .\n<\/pre><\/div>\n\n\n<p>We see there are patches from before Covid, 4-years old. Will I ever rollback to that point? I don&#8217;t think so, everything is running well.<\/p>\n\n\n\n<p>So I decide to give a try to the new <code>opatch util DeleteInactivePatches<\/code> option:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ $ORACLE_HOME\/OPatch\/opatch util DeleteInactivePatches -silent\nOracle Interim Patch Installer version 12.2.0.1.39\nCopyright (c) 2023, Oracle Corporation.  All rights reserved.\n\n\nOracle Home       : \/u00\/app\/oracle\/product\/19.18.0\nCentral Inventory : \/u00\/app\/OraInventory\n   from           : \/u00\/app\/oracle\/product\/19.18.0\/oraInst.loc\nOPatch version    : 12.2.0.1.39\nOUI version       : 12.2.0.7.0\nLog file location : \/u00\/app\/oracle\/product\/19.18.0\/cfgtoollogs\/opatch\/opatch2023-08-13_12-31-39PM_1.log\n\nInvoking utility &quot;deleteinactivepatches&quot;\nInactive Patches Cleanup option provided\nDelete Inactive Patches .......\n\n***** There are 8 inactive RU patches in chain 1\n\n***** 7 inactive patches will be deleted\n-To be deleted inactive RU\/BP 29585399:OCW RELEASE UPDATE 19.3.0.0.0 (29585399), installed on: Thu Apr 18 09:21:33 CEST 2019, with no overlays\n-To be deleted inactive RU\/BP 29850993:OCW RELEASE UPDATE 19.4.0.0.0 (29850993), installed on: Mon Jul 29 15:14:19 CEST 2019, with no overlays\n-To be deleted inactive RU\/BP 30489227:OCW RELEASE UPDATE 19.6.0.0.0 (30489227), installed on: Mon Feb 03 09:37:21 CET 2020, with no overlays\n-To be deleted inactive RU\/BP 31305087:OCW RELEASE UPDATE 19.8.0.0.0 (31305087), installed on: Tue Oct 13 13:27:46 CEST 2020, with no overlays\n-To be deleted inactive RU\/BP 32222571:OCW Interim patch for 32222571, installed on: Tue Mar 09 12:50:27 CET 2021, with no overlays\n-To be deleted inactive RU\/BP 32916816:OCW RELEASE UPDATE 19.12.0.0.0 (32916816), installed on: Fri Sep 24 11:26:21 CEST 2021, with no overlays\n-To be deleted inactive RU\/BP 33529556:OCW RELEASE UPDATE 19.14.0.0.0 (33529556), installed on: Thu Feb 10 14:09:40 CET 2022, with no overlays\n-To be retained inactive RU\/BP 34160635:OCW RELEASE UPDATE 19.16.0.0.0 (34160635), installed on: Thu Dec 15 15:13:06 CET 2022, with no overlays\n-Active RU\/BP 34768559:OCW RELEASE UPDATE 19.18.0.0.0 (34768559), installed on: Tue Mar 14 10:18:46 CET 2023, with no overlays\n\n***** There are 8 inactive RU patches in chain 2\n\n***** 7 inactive patches will be deleted\n-To be deleted inactive RU\/BP 29517242:Database Release Update : 19.3.0.0.190416 (29517242), installed on: Thu Apr 18 09:21:17 CEST 2019, with no overlays\n-To be deleted inactive RU\/BP 29834717:Database Release Update : 19.4.0.0.190716 (29834717), installed on: Mon Jul 29 15:12:44 CEST 2019, with no overlays\n-To be deleted inactive RU\/BP 30557433:Database Release Update : 19.6.0.0.200114 (30557433), installed on: Mon Feb 03 09:39:40 CET 2020, with no overlays\n-To be deleted inactive RU\/BP 31281355:Database Release Update : 19.8.0.0.200714 (31281355), installed on: Tue Oct 13 13:23:33 CEST 2020, with no overlays\n-To be deleted inactive RU\/BP 32218454:Database Release Update : 19.10.0.0.210119 (32218454), installed on: Tue Mar 09 12:42:54 CET 2021, with no overlays\n-To be deleted inactive RU\/BP 32904851:Database Release Update : 19.12.0.0.210720 (32904851), installed on: Fri Sep 24 11:17:00 CEST 2021, with no overlays\n-To be deleted inactive RU\/BP 33515361:Database Release Update : 19.14.0.0.220118 (33515361), installed on: Thu Feb 10 14:02:39 CET 2022, with no overlays\n-To be retained inactive RU\/BP 34133642:Database Release Update : 19.16.0.0.220719 (34133642), installed on: Thu Dec 15 15:07:21 CET 2022, with no overlays\n-Active RU\/BP 34765931:DATABASE RELEASE UPDATE : 19.18.0.0.230117 (REL-JAN230131) (34765931), installed on: Tue Mar 14 10:12:42 CET 2023, with no overlays\n\n***** There are 6 inactive RU patches in chain 3\n\n***** 5 inactive patches will be deleted\n-To be deleted inactive RU\/BP 30484981:OJVM RELEASE UPDATE: 19.6.0.0.200114 (30484981), installed on: Mon Feb 03 09:26:39 CET 2020, with no overlays\n-To be deleted inactive RU\/BP 31219897:OJVM RELEASE UPDATE: 19.8.0.0.200714 (31219897), installed on: Tue Oct 13 13:20:35 CEST 2020, with no overlays\n-To be deleted inactive RU\/BP 32067171:OJVM RELEASE UPDATE: 19.10.0.0.210119 (32067171), installed on: Tue Mar 09 12:38:35 CET 2021, with no overlays\n-To be deleted inactive RU\/BP 32876380:OJVM RELEASE UPDATE: 19.12.0.0.210720 (32876380), installed on: Fri Sep 24 11:10:35 CEST 2021, with no overlays\n-To be deleted inactive RU\/BP 33561310:OJVM RELEASE UPDATE: 19.14.0.0.220118 (33561310), installed on: Thu Feb 10 14:12:21 CET 2022, with no overlays\n-To be retained inactive RU\/BP 34086870:OJVM RELEASE UPDATE: 19.16.0.0.220719 (34086870), installed on: Thu Dec 15 15:05:34 CET 2022, with no overlays\n-Active RU\/BP 34786990:OJVM RELEASE UPDATE: 19.18.0.0.230117 (34786990), installed on: Tue Mar 14 10:19:19 CET 2023, with no overlays\n\nDo you want to proceed? &#x5B;y|n]\nY (auto-answered by -silent)\nUser Responded with: Y\nDeleted RU\/BP patch: 29585399\nDeleted RU\/BP patch: 29850993\nDeleted RU\/BP patch: 30489227\nDeleted RU\/BP patch: 31305087\nDeleted RU\/BP patch: 32222571\nDeleted RU\/BP patch: 32916816\nDeleted RU\/BP patch: 33529556\nDeleted RU\/BP patch: 29517242\nDeleted RU\/BP patch: 29834717\nDeleted RU\/BP patch: 30557433\nDeleted RU\/BP patch: 31281355\nDeleted RU\/BP patch: 32218454\nDeleted RU\/BP patch: 32904851\nDeleted RU\/BP patch: 33515361\nDeleted RU\/BP patch: 30484981\nDeleted RU\/BP patch: 31219897\nDeleted RU\/BP patch: 32067171\nDeleted RU\/BP patch: 32876380\nDeleted RU\/BP patch: 33561310\n\nOPatch succeeded.\n<\/pre><\/div>\n\n\n<p>It took around 8 minutes to run. The main points from the log file are the follows:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#x5B;Aug 13, 2023 12:31:40 PM] &#x5B;INFO]   OPatch invoked as follows: &#039;util DeleteInactivePatches -silent -invPtrLoc \/u00\/app\/oracle\/product\/19.18.0\/oraInst.loc &#039;\n...\n&#x5B;Aug 13, 2023 12:34:30 PM] &#x5B;INFO]   Built sorted map of inactive patches in oracle home\n...\n&#x5B;Aug 13, 2023 12:34:30 PM] &#x5B;INFO]   File \/u00\/app\/oracle\/product\/19.18.0\/inventory\/ContentsXML\/comps.xml has been backed up.\n&#x5B;Aug 13, 2023 12:34:30 PM] &#x5B;INFO]   File \/u00\/app\/oracle\/product\/19.18.0\/inventory\/ContentsXML\/oui-patch.xml has been backed up.\n&#x5B;Aug 13, 2023 12:34:30 PM] &#x5B;INFO]   Directory \/u00\/app\/oracle\/product\/19.18.0\/inventory\/oneoffs has been backed up.\n...\n&#x5B;Aug 13, 2023 12:34:30 PM] &#x5B;INFO]   Deleting patch 29585399 from inventory.\n&#x5B;Aug 13, 2023 12:34:34 PM] &#x5B;INFO]   Is batchMode enable? false\n&#x5B;Aug 13, 2023 12:34:34 PM] &#x5B;INFO]   Saving inventory after applying each patch\n&#x5B;Aug 13, 2023 12:34:39 PM] &#x5B;INFO]   &#x5B;OPSR-TIME] Loading raw inventory\n&#x5B;Aug 13, 2023 12:34:39 PM] &#x5B;INFO]   &#x5B;OPSR-MEMORY] Loaded all components from inventory. Heap memory in use: 937 (MB)\n&#x5B;Aug 13, 2023 12:34:39 PM] &#x5B;INFO]   &#x5B;OPSR-MEMORY] Loaded all one offs from inventory. Heap memory in use: 937 (MB)\n&#x5B;Aug 13, 2023 12:34:39 PM] &#x5B;INFO]   &#x5B;OPSR-TIME] Raw inventory loaded successfully\n&#x5B;Aug 13, 2023 12:34:39 PM] &#x5B;INFO]   &#x5B;OPSR-TIME] Loading cooked inventory\n&#x5B;Aug 13, 2023 12:34:39 PM] &#x5B;INFO]   &#x5B;OPSR-MEMORY] : Loading cooked one offs. Heap memory used 937 (MB)\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   &#x5B;OPSR-MEMORY] : Loaded cooked oneoffs. Heap memory used : 564 (MB)\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   &#x5B;OPSR-TIME] Cooked inventory loaded successfully\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleting patch 29585399 from inventory is done.\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleting patch \/u00\/app\/oracle\/product\/19.18.0\/inventory\/oneoffs\/29585399 in inventory\/oneoffs.\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Cannot delete as either pathToBeDeleted is empty or it does not contain .patch_storage :\/u00\/app\/oracle\/product\/19.18.0\/inventory\/oneoffs\/29585399\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleting patch \/u00\/app\/oracle\/product\/19.18.0\/inventory\/oneoffs\/29585399 in inventory\/oneoffs is done.\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleting patch \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47 in patch storage.\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleted the file &quot;\/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47\/original_patch\/custom\/scripts\/postpatch.sh&quot;\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleted the file &quot;\/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47\/original_patch\/custom\/scripts\/prepatch.sh&quot;\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleted the file &quot;\/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47\/original_patch\/etc\/config\/actions.xml&quot;\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleted the file &quot;\/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47\/original_patch\/etc\/config\/inventory.xml&quot;\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleted the file &quot;\/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47\/original_patch\/README.txt&quot;\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleted the file &quot;\/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47\/rollback.sh&quot;\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleted the file &quot;\/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47\/unchanged_files.txt&quot;\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleting patch \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\/29585399_Apr_9_2019_19_12_47 in patch storage done.\n&#x5B;Aug 13, 2023 12:34:50 PM] &#x5B;INFO]   Deleted RU\/BP patch: 29585399\n....\n&#x5B;Aug 13, 2023 12:39:47 PM] &#x5B;INFO]   Start verifying if inactive patches got deleted successfully..\n...\n&#x5B;Aug 13, 2023 12:39:53 PM] &#x5B;INFO]   list of inactive patches after delete:34160635,34133642,34086870,\n&#x5B;Aug 13, 2023 12:39:53 PM] &#x5B;INFO]   Verifying of delete inactive patches in DB CUP env was completed.\n&#x5B;Aug 13, 2023 12:39:53 PM] &#x5B;INFO]   Finished verifying. The inactive patches got deleted successfully..\n&#x5B;Aug 13, 2023 12:39:53 PM] &#x5B;INFO]   Finishing UtilSession at Sun Aug 13 12:39:53 CEST 2023\n<\/pre><\/div>\n\n\n<p>It starts by redoing the list of patches then backups up inventory files. For each patch it does the following: loads the info, deletes the patch from inventory, gives a warning about a oneoff directory not existing and deletes the patch backup files. At the end checks that all was correctly deleted and show the list of preserved inactive patches.<\/p>\n\n\n\n<p>As result, in my example I gained 11 GB of space in this $ORACLE_HOME:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ du -hs \/u00\/app\/oracle\/product\/19.18.0\n15G     \/u00\/app\/oracle\/product\/19.18.0\n\n$ du -hs \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\n5.2G    \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\n<\/pre><\/div>\n\n\n<p>Running a new report takes now only 12 seconds, which finds there are no patches to be deleted:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ time $ORACLE_HOME\/OPatch\/opatch util DeleteInactivePatches -report\nOracle Interim Patch Installer version 12.2.0.1.39\nCopyright (c) 2023, Oracle Corporation.  All rights reserved.\n\n\nOracle Home       : \/u00\/app\/oracle\/product\/19.18.0\nCentral Inventory : \/u00\/app\/OraInventory\n   from           : \/u00\/app\/oracle\/product\/19.18.0\/oraInst.loc\nOPatch version    : 12.2.0.1.39\nOUI version       : 12.2.0.7.0\nLog file location : \/u00\/app\/oracle\/product\/19.18.0\/cfgtoollogs\/opatch\/opatch2023-08-13_12-47-39PM_1.log\n\nInvoking utility &quot;deleteinactivepatches&quot;\nInactive Patches Cleanup option provided\nDelete Inactive Patches .......\nWarning: No inactive RU is eligible for delete. See log file for more details\n\nOPatch succeeded.\n\nreal    0m11.304s\nuser    0m12.135s\nsys     0m1.484s\n<\/pre><\/div>\n\n\n<p>And the contents of .patch_storage show now only the backups of the current active version (19.18 &#8211; RU Jan 2023 installed on 14.Mar) and backups of last inactive version (19.16 &#8211; RU Jul 2022 installed on 15.Dec):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n$ ls -ltr \/u00\/app\/oracle\/product\/19.18.0\/.patch_storage\n\ndrwxr-xr-x.  4 oracle dba     87 Dec 15  2022 34086870_May_31_2022_05_49_37\ndrwxr-xr-x.  4 oracle dba     87 Dec 15  2022 34133642_Jul_14_2022_16_09_56\ndrwxr-xr-x.  4 oracle dba     87 Dec 15  2022 34160635_Jul_10_2022_21_27_08\ndrwxr-xr-x. 42 oracle dba   4096 Mar 14 10:10 NApply\n-rw-r--r--.  1 oracle dba  87836 Mar 14 10:10 record_inventory.txt\n-rw-r--r--.  1 oracle dba 190461 Mar 14 10:10 interim_inventory.txt\n-rw-r--r--.  1 oracle dba  67011 Mar 14 10:18 newdirs.txt\n-rw-r--r--.  1 oracle dba     92 Mar 14 10:19 LatestOPatchSession.properties\ndrwxr-xr-x.  4 oracle dba     87 Mar 14 10:20 34765931_Jan_27_2023_11_25_14\ndrwxr-xr-x.  4 oracle dba     87 Mar 14 10:20 34768559_Jan_14_2023_07_39_49\ndrwxr-xr-x.  4 oracle dba     87 Mar 14 10:20 34786990_Dec_6_2022_13_24_50\ndrwxr-xr-x.  3 oracle dba     33 Aug 13 12:34 backup_delete_inactive\n<\/pre><\/div>\n\n\n<p>My recommendation is to use this new feature <code>opatch util DeleteInactivePatches<\/code> every time after patching an Oracle Home. This means that if today I install Oracle 19.20 (Jul 2023), I will afterwards delete the backups of 19.16 files. Don&#8217;t forget to do the same on the GRID_HOME. It would even be great that it would be an option of <code>opatch apply<\/code> and <code>opatchauto<\/code> .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you are a sensible person, you patch regularly your Oracle database. After a few years, maybe you noticed that the $ORACLE_HOME increased size from new ~7 GB to &#8230;. 26 GB! Looking better, you find the culprit is the hidden directory $ORACLE_HOME\/.patch_storage : Today I show how a new option from OPatch allowed me [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,6,39],"tags":[],"class_list":{"0":"post-567","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-opatch","7":"category-oracle","8":"category-oracle-19c","9":"czr-hentry"},"_links":{"self":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/comments?post=567"}],"version-history":[{"count":7,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/567\/revisions"}],"predecessor-version":[{"id":577,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/567\/revisions\/577"}],"wp:attachment":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/media?parent=567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/categories?post=567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/tags?post=567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}