I'm trying to convert an existing Ubuntu installation to a minimal config so it can run off of a 2 GB SD card (or even smaller). Right now, the current hardware (a Pi like board) needs a custom 16.04 build to support network and other on-board devices and takes up 4+ GB of space.
So the question is how to remove most packages (e.g. terminal, network, Wi-Fi and other board-specific drivers) to make it really small and lightweight? Are there any guides or recommendations on how to make it safe?
I know I can do something like this to identify and remove optional packages:
dpkg-query -Wf '${Package;-40}${Priority}\n' | awk '$2 ~ /optional|extra/ {print $2,"\t", $1}'
But what else can be safely removed?
sudo apt-get remove x11-common midori lxde python3 python3-minimal
thensudo find / -type f -size +10000k -exec ls -lh {} \; | awk '{ print $NF ": " $5 }'
and remove unused cache, etc. then remove all dev libs from the system by typing insudo apt-get remove `sudo dpkg --get-selections | grep "\-dev" | sed s/install//
. There's more steps involved if you wanna get rid of display manager and/or whole x11 system.... right now my 16.04 image is about 160mb – Alex D Oct 05 '18 at 23:06