What to remove to minimize Raspbian (no xserver)


28 posts   Page 1 of 2   1, 2
by McGregor80 » Mon Sep 30, 2013 9:10 pm
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/viewtopic.php?t=47902&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/84-mb-minimal-raspbian-armhf-image-for-raspberry-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
Posts: 40
Joined: Wed Feb 20, 2013 10:35 am
by AndrewS » Mon Sep 30, 2013 11:48 pm
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
User avatar
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by DavidS » Tue Oct 01, 2013 1:19 am
AndrewS wrote: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


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.
ARM BASIC: For the love of Simplicity, Fast Interpreted BASIC, and Assembly Language.
Always KISS Keep It Simple Silly.
User avatar
Posts: 3010
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
by DavidS » Tue Oct 01, 2013 1:27 am
[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.
ARM BASIC: For the love of Simplicity, Fast Interpreted BASIC, and Assembly Language.
Always KISS Keep It Simple Silly.
User avatar
Posts: 3010
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
by AndrewS » Tue Oct 01, 2013 1:45 am
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*
User avatar
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by AndrewS » Tue Oct 01, 2013 2:22 am
Here's another similar thread, which also links to other similar threads viewtopic.php?f=66&t=56283
User avatar
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by DeanC » Wed Oct 02, 2013 3:06 am
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.
We 'idiot proofed' the world, and now it's full of idiots!
User avatar
Posts: 136
Joined: Thu Sep 26, 2013 4:07 pm
Location: Vancouver, Canada
by SirLagz » Wed Oct 02, 2013 4:39 am
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.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
by AndrewS » Wed Oct 02, 2013 11:11 am
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 :oops:
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 :D

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. viewtopic.php?f=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
Last edited by AndrewS on Wed Oct 02, 2013 12:51 pm, edited 1 time in total.
User avatar
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by McGregor80 » Wed Oct 02, 2013 11:19 am
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. :?
Posts: 40
Joined: Wed Feb 20, 2013 10:35 am
by AndrewS » Wed Oct 02, 2013 11:26 am
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 ;)
User avatar
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by DeanC » Wed Oct 02, 2013 1:58 pm
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*
We 'idiot proofed' the world, and now it's full of idiots!
User avatar
Posts: 136
Joined: Thu Sep 26, 2013 4:07 pm
Location: Vancouver, Canada
by McGregor80 » Tue Oct 08, 2013 6:47 am
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
Posts: 40
Joined: Wed Feb 20, 2013 10:35 am
by DeanC » Tue Oct 08, 2013 9:22 pm
McGregor80 wrote:...it gives 764 MB


Which version of Wheezy are you starting with?
We 'idiot proofed' the world, and now it's full of idiots!
User avatar
Posts: 136
Joined: Thu Sep 26, 2013 4:07 pm
Location: Vancouver, Canada
by ramstrong » Tue Oct 08, 2013 11:10 pm
AndrewS wrote: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

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.
Raspberry Pi Journal: http://simpletongeek.blogspot.com/p/raspberry-pi-journal-directory_4.html
Posts: 36
Joined: Thu Aug 15, 2013 11:14 pm
by flyinghappy » Wed Oct 09, 2013 1:46 am
Edit: WOW, I really need to read!!!
Pi with ArchLinux running a minidlna/samba home server
Posts: 115
Joined: Mon Nov 05, 2012 5:31 pm
by DeanC » Wed Oct 09, 2013 1:53 am
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.
We 'idiot proofed' the world, and now it's full of idiots!
User avatar
Posts: 136
Joined: Thu Sep 26, 2013 4:07 pm
Location: Vancouver, Canada
by DeanC » Sat Oct 12, 2013 4:29 am
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
We 'idiot proofed' the world, and now it's full of idiots!
User avatar
Posts: 136
Joined: Thu Sep 26, 2013 4:07 pm
Location: Vancouver, Canada
by McGregor80 » Sat Oct 19, 2013 8:51 pm
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.
Posts: 40
Joined: Wed Feb 20, 2013 10:35 am
by SirLagz » Tue Oct 22, 2013 1:24 pm
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.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
by AndrewdAzotus » Tue Oct 22, 2013 2:51 pm
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...
Posts: 81
Joined: Wed Feb 06, 2013 3:07 pm
Location: Canada
by vadim » Tue Oct 22, 2013 3:26 pm
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.
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham
by DeanC » Wed Oct 23, 2013 3:29 am
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.
We 'idiot proofed' the world, and now it's full of idiots!
User avatar
Posts: 136
Joined: Thu Sep 26, 2013 4:07 pm
Location: Vancouver, Canada
by AndrewdAzotus » Thu Oct 31, 2013 12:33 pm
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...
Posts: 81
Joined: Wed Feb 06, 2013 3:07 pm
Location: Canada
by JustThisGuy » Thu Oct 31, 2013 8:24 pm
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.
Any conversation about a sufficiently complex subject is indistinguishable from babble.
Posts: 114
Joined: Thu Jan 05, 2012 11:22 pm