ephestione
Posts: 32
Joined: Wed Aug 15, 2018 10:46 am

Uninstall older versions of packages that still exist after newer versions have been installed?

Sat Sep 14, 2019 1:25 pm

Just upgraded from stretch to buster before swapping the 3b+ to a 4, and the upgrade process, other than excruciatingly slow, left a lot less space on the root partition. I use a 32GB pendrive, where I limited root to 4GB since that's always been way more than enough, and I was surprised that a simple distro bump would fill so much space.
So finally I looked around on the intertubes, and found this:

Code: Select all

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
the returned (just last few lines) this:

Code: Select all

21359   mariadb-client-10.3
21779   gcc-8
22249   mariadb-client-core-10.3
23710   raspberrypi-bootloader
26535   libicu52
29111   libicu57
29717   git
30057   mysql-server-5.5
30630   libicu63
31965   mariadb-server-core-10.3
33029   libraspberrypi-doc
40447   mariadb-client-10.1
45340   libpython2.7-dev
52681   libllvm6.0
60144   mariadb-server-10.3
69077   libpython3.7-dev
71248   mariadb-server-10.1
185848  raspberrypi-kernel
297463  libgl1-mesa-dri
I think that I need to keep the libgl1-mesa-dri package even if I run headless. Still, I can see there is an older version of mariadb-server that's still installed (10.1) after newer version was installed (10.3).
I suppose I could just uninstall everything "mariadb" without the purge flag, and then reinstall mariadb to do a cleaning... but is there a way to find "duplicates" (which are not exactly duplicates, but rather leftovers) and remove them?

User avatar
scruss
Posts: 2471
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Uninstall older versions of packages that still exist after newer versions have been installed?

Sat Sep 14, 2019 1:36 pm

You've probably got a lot of downloaded deb files in your cache. You can remove them with:

Code: Select all

sudo apt clean
To remove packages that the system doesn't need any more:

Code: Select all

sudo apt --purge autoremove
Manually removing packages you don't think you need? Probably not a good idea. The packages that remain after clean and autoremove are the ones that Raspbian has dependencies for. Sometimes you'll see older packages than you think you need sticking around. apt clean will likely clean up a few gigabytes for you.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

ephestione
Posts: 32
Joined: Wed Aug 15, 2018 10:46 am

Re: Uninstall older versions of packages that still exist after newer versions have been installed?

Sat Sep 14, 2019 1:47 pm

Thank you scruss, using autoclean and autoremove with apt was the first thing I did, what remains is what apt deems "still necessary".
I will definitely remove the 10.1 versions of mariadb, I've decided against apt judgement :D I wondered if there's something that does it automagically.
After all, it makes no sense having two different versions of a MySQL server installed :)

User avatar
rpdom
Posts: 15172
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Uninstall older versions of packages that still exist after newer versions have been installed?

Sat Sep 14, 2019 1:59 pm

ephestione wrote:
Sat Sep 14, 2019 1:47 pm
it makes no sense having two different versions of a MySQL server installed
You may find that the mysql-server package is a dummy transitional package that depends on the mariadb-server now. I'm not at home, so I can't check. If so, it will take up very little space.

I seem to recall writing a script that went through looking for packages that were no longer current. I'll look around later to see if I finished it.

User avatar
scruss
Posts: 2471
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Uninstall older versions of packages that still exist after newer versions have been installed?

Sat Sep 14, 2019 3:59 pm

ephestione wrote:
Sat Sep 14, 2019 1:47 pm
I will definitely remove the 10.1 versions of mariadb, I've decided against apt judgement :D
Well, good luck! Upgrading from one Raspbian release to another can leave some files around. If you wanted it absolutely clean, install from a new image (which is what the Foundation recommends anyway, especially for Buster).

For me, unless I'm running out of space for something I need to do, the effort of tracking down old packages plus the risk of breaking something means that this doesn't happen.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
rpdom
Posts: 15172
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Uninstall older versions of packages that still exist after newer versions have been installed?

Sat Sep 14, 2019 4:36 pm

The deborphan command (will need installing) can help tidy up to some extent.

ephestione
Posts: 32
Joined: Wed Aug 15, 2018 10:46 am

Re: Uninstall older versions of packages that still exist after newer versions have been installed?

Sat Sep 14, 2019 7:10 pm

Thank you for the feedback :)

This is an update:

Code: Select all

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
does output the existence of a mariadb-server-10.1 package together with mariadb-server-10.3 package, the older being even larger, at about 70MB, than the newer.
But when I issue

Code: Select all

sudo apt search mariadb
the results for 10.1 version only show "residual config", and also doing

Code: Select all

sudo apt remove mariadb-server-10.1
reports that the package is not installed so won't be removed... now I'm wondering why I see that the 10.1 version is filling 70MB of space with the

Code: Select all

dpkg query
command.
I installed and tested the deborphan tool, interesting to a point but I'm not sure I can make much out of it, as in I'm not sure the output is of all the unneeded packages that I can safely uninstall, so I'll leave it alone for now!

Return to “Beginners”