Page 1 of 2
What to remove to minimize Raspbian (no xserver)
Posted: Mon Sep 30, 2013 9:10 pm
by McGregor80
Hi,
I'm writing a script which would strip down raspbian installation. On my raspberry i'm going to use:
- shell with all the commands and few more from apt-get
openssl
ssh
mc
i2c
gpio
apt-get !
all standard C runtime libraries stdio etc.
which means all Xserver stuff, python, graphics, sounds, games,midori... is just taking the place on the SD card.
And i know that there are interesting links on our forum to ready minimum images like
http://www.raspberrypi.org/phpBB3/viewt ... 2&p=374867 but as they don't support apt-get it's not the thing.
Inspired by
http://www.cnx-software.com/2012/07/31/ ... pberry-pi/
my script uses so far:
- sudo rm -rf python_games
sudo apt-get autoremove x11-common
sudo apt-get autoremove midori
sudo apt-get autoremove python*
sudo apt-get autoremove lxde-icon-theme
sudo apt-get autoremove omxplayer
sudo rm -rv /usr/share/icons/*
sudo rm -rv /opt/vc/src/*
i managed to go down to 979 MB (df) but satisfactionary would be if the image(dd) would get space on 512MB card.
If you have any ideas what more i can remove please write.
P.S. I tried to do apt-get autoremove X11 but this was bad idea as the system never got up after this
thanks
Re: What to remove to minimize Raspbian (no xserver)
Posted: Mon Sep 30, 2013 11:48 pm
by AndrewS
OffTopic: I see lots and lots of threads about people trying to make a "minimal Raspbian", but with SD cards costing so little nowadays, I never see a good reason for people's effort...

Also,
http://www.raspberrypi.org/archives/4959#comment-255606
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 01, 2013 1:19 am
by DavidS
There are many good reasons to minimize the install. Why do you want 2 to 3 GB of stuff that you will never use on your Raspbian SD when you could be using that space for something that you use, even if you have a 32GB or 64GB Card it is still better to have the extra space to play with.
My current Raspbian Card is 4GB, and I will be getting a 16GB card soon, even so I am attempting to strip it down as far as I can, so far I am down to 1.2GB on card, and still looking at what is there that I do not use. I do realize that since I do use X, I am going to have to replace the WM, Desktop FileManager, and dump the panel to be able to remove some of the unwanted libraries.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 01, 2013 1:27 am
by DavidS
[quote]managed to go down to 979 MB (df) but satisfactionary would be if the image(dd) would get space on 512MB card.
If you have any ideas what more i can remove please write.[/qutoe]
You could also remove all of the WiFi firmware, all of the unused dynalibs, there are many things that are not needed.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 01, 2013 1:45 am
by AndrewS
DavidS wrote:There are many good reasons to minimize the install. Why do you want 2 to 3 GB of stuff that you will never use on your Raspbian SD when you could be using that space for something that you use, even if you have a 32GB or 64GB Card it is still better to have the extra space to play with.
If you really need that much space, wouldn't it be cheaper to just plug in a USB flash drive or a powered USB hard drive? *shrug*
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 01, 2013 2:22 am
by AndrewS
Here's another similar thread, which also links to other similar threads
http://www.raspberrypi.org/phpBB3/viewt ... 66&t=56283
Re: What to remove to minimize Raspbian (no xserver)
Posted: Wed Oct 02, 2013 3:06 am
by DeanC
Issue these commands as well, and then remove the results:
sudo find / -name *.wav
sudo find / -name *.mp3
Seems to be a few of these things.
I too am interested in a minimized raspian.
First off, this is an educational forum for educating people. Why the hell do people have the need to tell someone not to bother doing something, or telling them it is useless. Some of my best learning experiences have been from re-inventing the wheel. Either help people, or STFU.
The reason I want a small raspian is for my backup images. It is much faster to make/burn an image if it fits on a 2GB card rather than a 32GB card, if you are learning, and constantly reinstalling.
And if there are other reductions you have done, please post them or send them to me in a PM.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Wed Oct 02, 2013 4:39 am
by SirLagz
I have a script to get Raspbian down to around 600 megabytes.
Though you might be better off using the raspbian installer that HiFi made up if you want a truly minimal Raspbian install.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Wed Oct 02, 2013 11:11 am
by AndrewS
DeanC wrote:First off, this is an educational forum for educating people. Why the hell do people have the need to tell someone not to bother doing something, or telling them it is useless. Some of my best learning experiences have been from re-inventing the wheel. Either help people, or STFU.
Sorry if I gave the wrong impression
If you're doing it as a learning exercise (e.g. to see how far you can go before breaking things), or you have a valid reason for wanting a smaller image (without using one of the several already-made minimal images, or starting from something like Arch) then by all means go ahead
It's just that I often get the impression that people think if they "remove stuff" then it'll automatically "make things faster" even though that isn't the case and people would just be wasting their time for no noticeable improvement (EDIT: e.g.
http://www.raspberrypi.org/phpBB3/viewt ... 29&t=57003 ). It's usually much better to start-small and work your way up, than to start with a "full Raspbian" and try stripping bits out.
There should be an "official" smaller image coming soon
http://www.raspberrypi.org/archives/4959#comment-255606
Re: What to remove to minimize Raspbian (no xserver)
Posted: Wed Oct 02, 2013 11:19 am
by McGregor80
Thaks for the input all of you.
SirLagz:
Though you might be better off using the raspbian installer that HiFi made up if you want a truly minimal Raspbian install.
is the HIFI version always the latest version comparing to ordinary raspbian distribution?
Here is what i remove so far:
Code: Select all
rm -rv python_games
rm -rv /opt/*
rm -rv /usr/share/icons/*
rm -rv /usr/games/
rm -rv /usr/share/squeak/
rm -rv /usr/share/sounds/
rm -rv /usr/share/wallpapers
rm -rv /usr/share/themes
rm -rv /usr/share/kde4
apt-get autoremove -y x11-common
apt-get autoremove -y midori
apt-get autoremove -y omxplayer
apt-get autoremove -y scratch
apt-get autoremove -y dillo
apt-get autoremove -y xpdf
apt-get autoremove -y galculator
apt-get autoremove -y netsurf-common
apt-get autoremove -y netsurf-gtk
apt-get autoremove -y psmisc
apt-get autoremove -y idle-python3.2
apt-get autoremove -y python
apt-get autoremove -y python3
apt-get autoremove -y python2.7
apt-get autoremove -y python2.7-minimal
apt-get autoremove -y lxde-common
apt-get autoremove -y lxde-icon-theme
apt-get autoremove -y lxdeterminal
apt-get autoremove -y hicolor-icon-theme
apt-get autoremove
apt-get clean
I get ca 800MB but somehow the killall command doesn't work anylonger.

Re: What to remove to minimize Raspbian (no xserver)
Posted: Wed Oct 02, 2013 11:26 am
by AndrewS
McGregor80 wrote:I get ca 800MB but somehow the killall command doesn't work anylonger.

That's because killall is in the psmisc package, which you've just removed

Re: What to remove to minimize Raspbian (no xserver)
Posted: Wed Oct 02, 2013 1:58 pm
by DeanC
McGregor80 wrote:
Here is what i remove so far:
This is one your missing:
rm -rv /usr/share/images/*
And this command would help shorten your script:
apt-get -y autoremove python*
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 08, 2013 6:47 am
by McGregor80
Thanks all of you for the input
The script looks like this now:
Code: Select all
df -h
rm -rv python_games
rm -rv /opt/*
rm -rv /usr/share/icons/*
rm -rv /usr/games/
rm -rv /usr/share/squeak/
rm -rv /usr/share/sounds/
rm -rv /usr/share/wallpapers
rm -rv /usr/share/themes
rm -rv /usr/share/kde4
rm -rv /usr/share/images/*
apt-get autoremove -y x11-common
apt-get autoremove -y midori
apt-get autoremove -y omxplayer
apt-get autoremove -y scratch
apt-get autoremove -y dillo
apt-get autoremove -y xpdf
apt-get autoremove -y galculator
apt-get autoremove -y netsurf-common
apt-get autoremove -y netsurf-gtk
apt-get autoremove -y idle-python3.2
apt-get autoremove -y python*
apt-get autoremove -y lxde-common
apt-get autoremove -y lxde-icon-theme
apt-get autoremove -y lxdeterminal
apt-get autoremove -y hicolor-icon-theme
apt-get autoremove -y
apt-get clean
it gives 764 MB
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 08, 2013 9:22 pm
by DeanC
McGregor80 wrote:...it gives 764 MB
Which version of Wheezy are you starting with?
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 08, 2013 11:10 pm
by ramstrong
Usually, yes. Not in Raspberry Pi case. Most people would start with Raspbian standard install. I know I did. On my second build, I want to start from the bottom. As you noted, though, there is no official minimal image. I tried using Arch linux. Different packages and usage. Not going to learn a second OS when I'm still having to learn the first. Arch linux is no solution.
Therefore, in order to build system up, I must first have a minimal Raspbian. Until that official minimal version is out, there is no other way to have it, except build my own. That means stripping out standard build. That is the best
current solution.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Wed Oct 09, 2013 1:46 am
by flyinghappy
Edit: WOW, I really need to read!!!
Re: What to remove to minimize Raspbian (no xserver)
Posted: Wed Oct 09, 2013 1:53 am
by DeanC
The reason why I ask which version of Wheezy you are using, is because I noticed the details of the last two images offered for download...
wheezy-raspbian-2013-07-26.img - 1.80 GB
and
2013-09-25-wheezy-raspbian.img - 2.75 GB
Seems the latest image is quite bloated.
Using the wheezy-raspbian-2013-07-26.img I am currently down to 677 MB. Need to test my image a bit more before I offer my script though.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Sat Oct 12, 2013 4:29 am
by DeanC
Running this script on 2013-09-25-wheezy-raspbian.img (the latest one) will reduce it to a size of 656 MB.
Some notes should be made. I use nano, as it's lite and does what I need. So to have vim and ed installed makes no sense. I also removed samba, as I have ftpd running and to me, they're the same service.
The order is somewhat important. For instance, not removing the python_games folder, will cause problems for the apt-get autoremove command with 'python*'.
I also used a slightly different remove command for the /opt directory. Removing it like you have done affects some important commands, so I didn't include it.
Also, if you are interested in trying to reduce it further, I found this command to be very helpful and revealing:
# dpkg --get-selections
That command will list all installed software.
Code: Select all
sudo rm -rf /home/pi/python_games
sudo apt-get -y autoremove python*
sudo apt-get -y autoremove omxplayer
sudo apt-get -y autoremove scratch
sudo apt-get -y autoremove midori
sudo apt-get -y autoremove dillo
sudo apt-get -y autoremove lxde-common
sudo apt-get -y autoremove hicolor-icon-theme
sudo apt-get -y autoremove galculator
sudo apt-get -y autoremove xarchiver
sudo apt-get -y autoremove lxde-icon-theme
sudo apt-get -y autoremove libpoppler19
sudo apt-get -y autoremove x11-common
sudo apt-get -y autoremove ed
sudo apt-get -y autoremove vim-common
sudo apt-get -y autoremove lxsession
sudo apt-get -y autoremove lxappearance
sudo apt-get -y autoremove lxpolkit
sudo apt-get -y autoremove lxrandr
sudo apt-get -y autoremove lxsession-edit
sudo apt-get -y autoremove lxshortcut
sudo apt-get -y autoremove lxtask
sudo apt-get -y autoremove lxterminal
sudo apt-get -y autoremove xauth
sudo apt-get -y autoremove debian-reference-common
sudo apt-get -y autoremove samba-common
sudo apt-get -y autoremove fontconfig
sudo apt-get -y autoremove fontconfig-config
sudo apt-get -y autoremove fonts-freefont-ttf
sudo apt-get -y autoremove netsurf-gtk
sudo apt-get -y autoremove netsurf-common
sudo apt-get -y autoremove dbus-x11
sudo apt-get -y autoremove desktop-base
sudo apt-get -y autoremove desktop-file-utils
sudo apt-get -y autoremove libxmuu1
sudo rm -rf /opt/vc/src/*
sudo rm -rf /usr/share/icons/*
sudo rm -rf /usr/share/sounds/
sudo rm -rf /usr/share/squeak/
sudo rm -rf /usr/share/wallpapers
sudo rm -rf /usr/share/themes
sudo rm -rf /usr/share/kde4
sudo rm -rf /usr/share/images/*
sudo apt-get -y autoremove
sudo apt-get -y clean
Re: What to remove to minimize Raspbian (no xserver)
Posted: Sat Oct 19, 2013 8:51 pm
by McGregor80
Great! Thanks DeanC
I will have to try it. 656MB is really great result.!
It's a pity that creators of raspbian don't make any minimal images which just boot and allow installation of everything else what is in raspbian full.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 22, 2013 1:24 pm
by SirLagz
McGregor80 wrote:Great! Thanks DeanC
I will have to try it. 656MB is really great result.!
It's a pity that creators of raspbian don't make any minimal images which just boot and allow installation of everything else what is in raspbian full.
Have a look at hifi's unattended raspbian installer,. which is almost exactly what you want.
I installs a very minimal installation, then you just add what you want on top.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 22, 2013 2:51 pm
by AndrewdAzotus
I've not seen anyone mention CUPS yet, unless it gets removed as part of one of the package lines above.
I'm not sure how useful CUPS is any more as most printers I've seen connect directly to the WiFi.
One reason I'm looking at stripping down Raspbian is to make it less vulnerable. I want to set up (and expose) a web server. it's possible (I think) to remove pretty much everything even 'sudo' and set up a cron job to copy the website from a read only share on another machine each night thus the website can be updated.
The nice thing about cron is that it can run as root even though root is disabled, although removing sudo means you cannot edit the root's crontab so you need to get it right...
Re: What to remove to minimize Raspbian (no xserver)
Posted: Tue Oct 22, 2013 3:26 pm
by vadim
Moebius and Archlinux are the starting points for minimal setups.
I have an old 1GB card with moebius for surveilance application. It takes 600MB (if I remember correctly) and takes only 30MB of RAM on boot. Moebius is based on Raspbian and uses same repos. So you can add whatever is missing.
I love archlinux on server pi but that's very different from Raspbian.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Wed Oct 23, 2013 3:29 am
by DeanC
McGregor80 wrote:Great! Thanks DeanC
I will have to try it. 656MB is really great result.!
It's a pity that creators of raspbian don't make any minimal images which just boot and allow installation of everything else what is in raspbian full.
Np, let me know if you come across anything that stops working from the script.
Re: What to remove to minimize Raspbian (no xserver)
Posted: Thu Oct 31, 2013 12:33 pm
by AndrewdAzotus
vadim wrote:Moebius and Archlinux are the starting points for minimal setups.
I have an old 1GB card with moebius for surveilance application. It takes 600MB (if I remember correctly) and takes only 30MB of RAM on boot. Moebius is based on Raspbian and uses same repos. So you can add whatever is missing.
I love archlinux on server pi but that's very different from Raspbian.
Being fairly new to Linux, I assume that apt-get would handle what is needed for us to 'add whatever is missing'
And, to add to the list of stuff to remove, I have also found 'sonic-pi' which looks like it could be removed, unless it's part of the list above. I want to keep the desktop but remove other unwanted programs...
Re: What to remove to minimize Raspbian (no xserver)
Posted: Thu Oct 31, 2013 8:24 pm
by JustThisGuy
Once you're done pulling all the packages, you need to do a custom build kernel.
During the configure phase, turn off all drivers and subsystems you won't be using. i.e. enable the drivers for the on board Ethernet and other on board systems and whatever additional peripherals you personally have and disable everything else. This should reduce the file system footprint by the size of the disabled modules.
Not sure how big that is.