User avatar
vicary
Posts: 27
Joined: Tue Jul 17, 2012 4:37 am
Location: Hong Kong

Removing xorg from raspbian

Wed Aug 08, 2012 2:10 pm

While managing linux web server for a few years, I am quite new to all the xorg things (embarrassing :oops: )

I am currently accessing my Pi through SSH and planned to run it headless, I am thinking of removing the whole xorg thing to squeeze the installed further to a minimal SD image.

Will do works on USB webcam streaming, but I think it didn't have dependency on xorg libs.

Would like to know if it is safe to remove all of the xorg packages?

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Removing xorg from raspbian

Wed Aug 08, 2012 2:23 pm

Yes it is safe.
I've gotten Raspbian down to under 100 megabytes after I stripped it down.
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

User avatar
vicary
Posts: 27
Joined: Tue Jul 17, 2012 4:37 am
Location: Hong Kong

Re: Removing xorg from raspbian

Wed Aug 08, 2012 3:17 pm

Thanks for the prompt response, now my Pi is stripped down to a few hundred megabytes with node.js and some video libraries.

Feeling clean now :lol:

User avatar
truehl
Posts: 642
Joined: Sun Mar 04, 2012 6:47 pm
Contact: Website

Re: Removing xorg from raspbian

Wed Aug 08, 2012 5:44 pm

What's the best way to strip down?
truehl
http://www.squeezeplug.de

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Removing xorg from raspbian

Thu Aug 09, 2012 6:10 am

apt-get purge anything you don't want
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

User avatar
truehl
Posts: 642
Joined: Sun Mar 04, 2012 6:47 pm
Contact: Website

Re: Removing xorg from raspbian

Thu Aug 09, 2012 6:17 am

SirLagz wrote:apt-get purge anything you don't want
Yes, I know the apt-get purge command, but which packages dd you purge to delete all the x-stuff?
truehl
http://www.squeezeplug.de

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Removing xorg from raspbian

Thu Aug 09, 2012 6:38 am

it's a pretty big list.
I did a dpkg -l to see what was installed, then systematically went through the list to purge anything that looked like it was related to X.
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

User avatar
truehl
Posts: 642
Joined: Sun Mar 04, 2012 6:47 pm
Contact: Website

Re: Removing xorg from raspbian

Thu Aug 09, 2012 10:36 am

:roll: O.k. Let's become a bit concrete: I did this:

Code: Select all

apt-get --yes purge xserver-common x11-xfs-utils x11-xserver-utils xinit libsmbclient
rm /usr/lib/xorg/modules/linux /usr/lib/xorg/modules/extensions /usr/lib/xorg/modules /usr/lib/xorg -r
apt-get --yes autoremove
apt-get --yes autoclean
apt-get --yes clean
What do you think?
truehl
http://www.squeezeplug.de

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Removing xorg from raspbian

Thu Aug 09, 2012 11:55 am

There is LOADS more. All related to LXDE (lx*), everything gtk, gnome, the default educational programs (don't recall their names) and then a good bit more. After cleaning for a while you'll suddenly get rid of the "last" dependency program and everything will unravel with the apt-get autoremove command.

Run this command:

Code: Select all

aptitude -F "%p" search \!~M~i~T
This will list all your manually installed packages. Remove everything that's X related in the slightest (guess, know or luck out) and autoremove after every time. In the end you'll have removed hundreds of packages and have a nice clean system :)

User avatar
vicary
Posts: 27
Joined: Tue Jul 17, 2012 4:37 am
Location: Hong Kong

Re: Removing xorg from raspbian

Thu Aug 09, 2012 4:03 pm

I was going back and forth in the debian package list for the package details, it was a bit exhausting...

I came across some packages like colord, can I still encode and stream videos through the ethernet if I remove all the color management thing?

Also, are we talking of removing a part of essential packages that will have apt-get warned me of? Coz they don't really seems useful to me at all... ( I don't use python, and I care nothing of perl )

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Removing xorg from raspbian

Fri Aug 10, 2012 1:22 am

You can safely remove python.
There could be some system scripts that use perl though, so I'd leave pearl.
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

plugwash
Forum Moderator
Forum Moderator
Posts: 3435
Joined: Wed Dec 28, 2011 11:45 pm

Re: Removing xorg from raspbian

Fri Aug 10, 2012 2:12 pm

Python can be safely removed from a debian system (though you may find it removes a lot of other stuff with it), perl can't as it is used by many system scripts.

Naps62
Posts: 3
Joined: Sat Aug 18, 2012 3:09 am

Re: Removing xorg from raspbian

Sat Aug 18, 2012 3:57 am

I just used the info in this thread to clean up my Raspbian SD card, since it was consuming something like 1.4GB out of my 2GB SD Card (will probably buy a bigger one soon enough)

Here's the list of packages i removed

Code: Select all

xserver* x11-common x11-utils x11-xkb-utils x11-xserver-utils xarchiver xauth xkb-data console-setup xinit lightdm libx{composite,cb,cursor,damage,dmcp,ext,font,ft,i,inerama,kbfile,klavier,mu,pm,randr,render,res,t,xf86}* lxde* lx{input,menu-data,panel,polkit,randr,session,session-edit,shortcut,task,terminal} obconf openbox gtk* libgtk* alsa* nano python-pygame python-tk python3-tk scratch tsconf
To sum it up, i removed everything related to: X, LXDE, Openbox, GTK, Alsa and TTF fonts
Note that i also removed the packages nano (text editor), scratch (a programming environment aimed for kids) and tsconf (for touch screens). Anyone who needs any of those, make sure to remove them from this list

Finally, here's the before & after partition usage:
Before (raw Raspbian installation)

Code: Select all

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.8G  1.4G  334M  81% /
After (including autoremove, autoclean and clean)

Code: Select all

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.8G  782M  891M  47% /

User avatar
vicary
Posts: 27
Joined: Tue Jul 17, 2012 4:37 am
Location: Hong Kong

Re: Removing xorg from raspbian

Sat Aug 18, 2012 1:07 pm

This is more or less the point I've got to, but actually could go a bit further if you don't need the raspi-* tools come with Raspbian.

My image lies slightly over 1GB as I'd keep nodejs and some GPIO, SPI and I2C things inside.

User avatar
vicary
Posts: 27
Joined: Tue Jul 17, 2012 4:37 am
Location: Hong Kong

Re: Removing xorg from raspbian

Tue Sep 11, 2012 5:53 am

Further squeezing, is it a good decision by replacing all essential binaries with BusyBox?

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Removing xorg from raspbian

Tue Sep 11, 2012 7:37 am

I'm trying it out now.
Looks ok to be honest.

I would think you could get more space savings still...
Seems a bit big to me, though I don't know how much space nodejs, GPIO etc etc require though.
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

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Removing xorg from raspbian

Tue Sep 11, 2012 3:04 pm

Naps62 wrote:Here's the list of packages i removed

Code: Select all

xserver* x11-common x11-utils x11-xkb-utils x11-xserver-utils xarchiver xauth xkb-data console-setup xinit lightdm libx{composite,cb,cursor,damage,dmcp,ext,font,ft,i,inerama,kbfile,klavier,mu,pm,randr,render,res,t,xf86}* lxde* lx{input,menu-data,panel,polkit,randr,session,session-edit,shortcut,task,terminal} obconf openbox gtk* libgtk* alsa* nano python-pygame python-tk python3-tk scratch tsconf
Adding to your list:

Code: Select all

xdg-tools desktop-file-utils
I also took away

Code: Select all

python3-numpy python3 python omxplayer
That's not X-related, but not neccessary for me.

Blars
Posts: 88
Joined: Sun Aug 28, 2011 3:22 am
Contact: Website

Re: Removing xorg from raspbian

Tue Sep 11, 2012 3:23 pm

If you want to go for more space saving, you may look at replacing packages with the emdebian versions. emdebian is compatable with debian packages, but drops stuff like documentation.

brs
Posts: 70
Joined: Fri Aug 17, 2012 9:27 pm
Location: Zurich

Re: Removing xorg from raspbian

Tue Sep 11, 2012 7:36 pm

http://sirlagz.net/?p=662 might also be worth while to look at for a stripped-down server version based on Raspbian.

User avatar
vicary
Posts: 27
Joined: Tue Jul 17, 2012 4:37 am
Location: Hong Kong

Re: Removing xorg from raspbian

Sat Sep 15, 2012 8:25 pm

By using ncdu to check in directory basis, it ends up a few locations was eating up my free spaces.

1. Unused locales
I guess I have wrongly chosen both GB and UK english and I even checked the zh_TW for some reason.. did a localepurge and 200mb is gone.

2. Sample build codes in /opt
That H.624 movie clip lies in hello_pi is obvious, but I just kinda missed it.

3. build-essential, git and crypto
I didn't know you even means to strip these off to get around 100mb, I'd rather keep these.

4. /usr/share/docs
Should I really remove this? I guess I'm good with man pages, need someone confirm here...

5. /usr/share/i18n and /usr/share/fonts
What exactly they did? Are they essential that even consoles use them? Or just some developer-specific data that can be easily recovered when needed?

6. git repo by rpi-update
Hm... should I keep it? It will just be there again when I check for firmware upgrade I guess.

7. /lib/module.bak
I guess this is the last 50mb I can get safely rid of, as long as I am keeping an image of the SD card as the backup.


800MB at this point. I'm not sure from 4. to 7. so I prefer someone confirms me before doing that.

By deleting them my RPi will gets about 200mb more free space, still very far from where you guys did... where else should I try? :?

sharpapotheosis
Posts: 58
Joined: Thu May 24, 2012 6:47 pm

Re: Removing xorg from raspbian

Tue Sep 18, 2012 10:11 am

I tried "sudo apt-get remove lx*" but this generated a massive list of things to remove that apt-get deemed dangerous to remove (a message I've never seen before). This list included things like apt and dpkg, which surely I don't want to remove? Just a warning for anyone reading this.

chrisb
Posts: 8
Joined: Fri Sep 21, 2012 10:53 am

Re: Removing xorg from raspbian

Tue Oct 02, 2012 11:56 am

sharpapotheosis wrote:I tried "sudo apt-get remove lx*" but this generated a massive list of things to remove that apt-get deemed dangerous to remove (a message I've never seen before). This list included things like apt and dpkg, which surely I don't want to remove? Just a warning for anyone reading this.
That's because lx* is a POSIX regular expression that matches all packages that contain the character l. x* means "x zero or more times" and the match is based on substrings, so it looks for any package containing 'l'. If you want to match the start you have to be explicit and match the beginning with ^.

Also you probably want to use purge rather than remove, so all the config files get deleted too.

Conclusion: apt-get purge ^lx

el_Salmon
Posts: 17
Joined: Thu Jan 10, 2013 2:22 pm

Re: Removing xorg from raspbian

Thu Jan 10, 2013 3:40 pm

From 1.4 GB to 760 MB used size, nice advices!

Sosukodo
Posts: 5
Joined: Mon Nov 12, 2012 6:04 am

Re: Removing xorg from raspbian

Mon Dec 30, 2013 2:56 am

You can free up even more space by removing the locales you don't plan on using. This can be safely done by
sudo apt-get install localepurge
and picking the ones you want to keep during setup. Then, finally run localepurge:
sudo localepurge

Return to “Raspbian”