Recently I wanted to remove all the muck I had installed on my osmc system using apt-get (multiple desktops such as mate and xfce, various applications such as tightvncserver and transmission, etc) which were wasting disk space and slowing down my osmc system.
I searched everywhere to no avail for an easy method of removing user installed packages but leaving the required osmc system packages alone, in essence to “refresh” the osmc install or restore it to defaults.
When it became clear that there was no “simple” solution other than a complete fresh install, I decided to remedy that situation and created the osmc-freshstart script.
Usage is quite simple, just install the script and supporting files (step by step directions below the disclaimer) and then execute the script from the command line:
The script will build a list of installed user packages to remove and ask you to confirm that you indeed do want to remove them, then ask if you want to also remove the package archives.
That’s all it takes from the user, the actual removal process is 100% automated.
When complete your osmc system should be restored to a near virgin state.
If you have installed packages you wish to keep, simply add them to the keep-packages file (in the same directory as the script) and enter each package you wish to keep on a single line. Packages listed in ‘keep-packages’ will not be removed by the script.
A simple example of a keep-packages file would be:
I have tested this script for the past week using three different osmc installs on various RPIs by installing dozens of packages and then running the script to clean the systems. I have found the script to be quite stable and bug free but as always, use it at your own risk (disclaimer below).
If you are about to do a fresh install to clean your system, it may be well worth your time to give this script a shot.
** DISCLAIMER: Though I have tested this script extensively (removed 3 different xdesktops, dozens of smaller apps, etc) and repeatedly on three separate OSMC setups but I cannot guarantee it will work for you. I accept no liability or responsibility if this script destroys your OSMC install or even if it sets your RPI on FIRE (okay, seriously IMHO very little chance of that with this script). This is run at your own risk, though I have taken reasonable care to ensure it will not cause you issues… you are warned.
Install and Use:
SSH into osmc (user & pass ‘osmc’)
using apt install wget and unzip
sudo apt-get update
sudo apt-get install wget unzip
if you don’t have one already, create the scripts directory
cd into the scripts directory
use wget to download script from github:
extract the script archive
rename the directory
mv ./osmc-freshstart-master ./osmc-freshstart
cd into the freshstart directory
make the script executable
chmod +x osmc-freshstart.sh
execute the script
The script will automatically determine which packages are user installed and not required by OSMC or part of the base system and then present a list of packages which will be removed.
** Take a few moments and check the packages to be removed, make sure there are not any packages you want to keep, then when you are satisfied simply press Y and enter to begin the cleaning process.
If your unsure of what other packages any given package you want to keep require to function, a quick way to determine this is to simply run:
sudo apt-get remove [package name]
Then when apt asks if you want to remove the package, simply note (copy and paste) the additional packages that are to be removed with the primary and then press N to exit apt. Then you add those package names to keep-packages file and run the osmc-freshstart.sh script again.
A simple example is vi.
To retain vi on your system, you would need to add three packages to your keep-packages list:
Feel free to post any questions you have regarding this script here, I will answer as quickly as I am able. You will also find my email address in the comments at the top of the script, feel free to email me too.
I hope this helps many of you and perhaps gives you a bit more confidence to test various software on your OSMC RPI