6

It turns out that when I prepared a certain Raspberry Pi several months ago, I used the full Raspbian image. Since then, that Pi is on headless duty just running some server software. When I run updates on it, a whole lot of stuff I'll never use gets updated. Migrating from jessie to stretch took unnecessary hours.

What can I do to move to the lite version from within the existing installation?

I would presume that I can remove some package and install another, like the ubuntu-desktop on Ubuntu, but what would that be on Raspbian?

Colin Dean
  • 225
  • 3
  • 6
  • 2
    install a lite version from scratch – jsotola Apr 23 '18 at 03:56
  • read man apt, man apt-get, man dpkg. remove all installed packages, then manually clean in /etc and elsewhere. – user2497 Apr 23 '18 at 04:07
  • 3
    @user2497 "Remove all installed packages" seems like an absurd suggestion... – goldilocks Apr 23 '18 at 14:14
  • @goldilocks Not if OP has heavily modified his installation with custom scripts etc - and who doesn’t? He has already expressed a desire to keep his current install, and why do you think that is? Purging takes 15 minutes. Rebuilding will take longer. OP: try apt-get purge \*, but do back up /etc and other relevant folders first. – user2497 Apr 23 '18 at 14:22
  • ... and subsequently add your server programs, and then restore their configurations from the backup (restore permissions as well with tar’s ‘-p’ flag; e.g. tar -xpf archive.tar -C /tmp. Review the files before committing them to /etc. – user2497 Apr 23 '18 at 14:33
  • 2
    @user2497 your advice is dangerous at best! Removing all packages and manually cleaning /etc (whatever that means) - you may as well just delete the partition. – John Hawthorne Apr 23 '18 at 16:54
  • @JohnHawthorne I think ‘dangerous at worst’ is more apt. To clean /etc is simply to remove unused daemon configurations. I have done this many, many times - and so have you. I like your answer, however. It is so convenient to remove the x11 meta-package. +1 – user2497 Apr 23 '18 at 17:08
  • What do you hope to achieve? Uninstalling won't make any difference if you don't use apps. – Milliways Apr 23 '18 at 23:52
  • Uninstalling stuff that I do not use will make upgrades go significantly faster. This wolfram-engine package alone has been unpacking for approximately 20 minutes. – Colin Dean Apr 24 '18 at 01:07

2 Answers2

8

I don't like answers that simply say install a clean image as if the OP wasn't aware of that possibility and it also disregards the work that the OP has already done on their installation.

So to answer your question directly, here's how to remove the GUI:

sudo apt-get remove --purge x11-common
sudo apt-get autoremove

The first line invalidates a lot of packages that are then removed by the second line leaving a much reduced codebase although it will not be identical to a Lite installation.

You can also use the tasksel command to remove top-level tasks which will consist of a number of packages.

John Hawthorne
  • 889
  • 5
  • 11
  • 1
    This basically did it for me, but I needed do a few other things to completely remove old packages and their on-disk files: apt-get clean; apt-get autoremove -y; apt-get update && apt-get upgrade; apt-get autoremove -y; apt-get purge -y $(dpkg --list |grep '^rc' |awk '{print $2}') – Colin Dean Apr 24 '18 at 03:55
1

What can I do to shift to the lite version?

There is no reliable and user-friendly way to "shift" from an already installed "Raspbian Stretch with desktop" to "Raspbian Stretch Lite".

In theory you need to find all different packages and replace respectively remove them. But in practice this is very time-consuming.

To get the lite version the most sensible way is to install the correct image.

Addition:

Removing the GUI will not transform an installation of "Raspbian Stretch with desktop" into "Raspbian Stretch Lite". There are a lot more differences between both versions. For further details about the differences please see:

Fabian
  • 1,260
  • 1
  • 10
  • 19
  • Is Debian package system not reliable? This notion people have of ditching a whole installation for a few tiny changes makes me cringe. OP has stated clearly he’d like a headless raspbian, and doesn’t need a GUI. -1 – user2497 Apr 23 '18 at 14:53
  • 1
    @user2497 Looking forward to your answer explaining these "few tiny changes". – Fabian Apr 23 '18 at 15:43
  • Explanation of a few tiny changes: removal of all packages, installation of required packages, copying saved configurations to the correct locations. – user2497 Apr 23 '18 at 15:50