Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Striping gentoo down: what can be removed?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3104

PostPosted: Sun Dec 08, 2013 4:35 pm    Post subject: Striping gentoo down: what can be removed? Reply with quote

WTF-section. Feel free to go straight to next paragraph if you don't like it.
I like doing weird things, and here's one of those: /-less ram-only gentoo. Building initramfs is a matter of `find . | cpio -H newc -o | gzip -c > ../initramfs` (And waiting like 5 sec for command to execute), however it seems initramfs has it's limits, particularly compressed image size. Sure I can change compression from gzip to lzma, but it's not gonna be even close to stuffing 1,5GB gentoo into ~85MB archive.
I don't mind inflicting heavy damage to this particular image, so I've deleted some stuff from /usr. `du -h | grep M` was my helper there. Kernel sources were an obvious shot. Documentation also. Locales dropped like another 100MB. Some shared stuff. Yeah, it worked pretty well taking 1,5GB working copy down to 240MB, which gives 88MB cpio.gz, the biggest I've managed to run on qemu with pxelinux so far. In fact, striping down worked too well, since mplayer refuses to start now. Do you think I've deleted some shared libraries? Good, it's exacly what mplayer complains about. Time to scrap working copy, and start over, a bit more carefully.

So, here's the point:
What can I remove from gentoo without affecting userrs experience?

What is user's experience:
* it has to boot
* it has to detect and mount mass storage
* mplayer has to run (and play movies :D ) - that's what I consider a good start here

What is not user's experience:
* docs
* logs
* bootloader (it's external binary)
* anything related to build-time only (like compilers and portage itself)

So, i'm going safe mode so far, dropped expendable USE flags, added -Os to CFLAGS, removed kernel sources... How can deal with packages in @system? I guess I need to modify set file manually, but I don't see it in the most obvious locations
Also looking for hints what else can I drop (most likely from /usr as it's where the heavy stuff resides, but I don't limit it only to this)
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3104

PostPosted: Tue Dec 10, 2013 3:33 pm    Post subject: Reply with quote

Removing /usr/share /usr/lib/pyhton* /usr/lib/perl* /usr/lib/locales and obviosuly /usr/src/linux allowed the remaining files fit into ~76MB lzma image. It does boot and mplayer does play mooovies using framebuffer (yeah, i love plaing movies inside text console :) ) in qemu as well as on real pc with radeon. Stone-age-old intel gpu fails to display video, perhaps due to some kernel misconfiguration. I'll deal with it later, as I'm fine with testing it on qemu.

Some hint on removing system packages in "cleaner" way than `rm -rf /` would be appreciated though, as current stage is still very, very far from what DSL has proven possible.
Yes, I know @system is there to protect key packages, but there must be some way to drop them regardless.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3104

PostPosted: Wed Dec 18, 2013 11:43 am    Post subject: Reply with quote

As I had some time for tricks today, I tried a different approach this time. I took and image with mplayer2 installed, mounted it with aufs as the readonly branch (with empty directory as rw), and ran `emerge -e mplayer2`.
Well, it seemed to be worth giving a shot, but it emerged for example perl, providing like 500 MB worth of modified files.. Maybe I missed some option for building only runtime dependencies? Or should I build the image using binary packages instead? Maybe there is some other way to make actually usable system fit under 300MB
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Wed Dec 18, 2013 12:15 pm    Post subject: Reply with quote

Not that I can help you much with this, but I just remembered the Trinity Rescue Kit, which is a Gentoo based rescue livecd that has an option to boot completely from ram. It might worth to see how they did it.
Back to top
View user's profile Send private message
broken_chaos
Guru
Guru


Joined: 18 Jan 2006
Posts: 370
Location: Ontario, Canada

PostPosted: Wed Dec 18, 2013 11:09 pm    Post subject: Reply with quote

szatox wrote:
Yes, I know @system is there to protect key packages, but there must be some way to drop them regardless.

Edit /etc/portage/profile/packages, putting lines such as "-sys-apps/busybox" to remove packages from @system. It's dangerous if you aren't careful -- be sure to carefully check before depcleaning if you're doing this.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3104

PostPosted: Fri May 23, 2014 1:07 pm    Post subject: Reply with quote

Well, I accidentaly stumbled over a really neat portage's feature, and I'm a bit surprised nobody pointed me at this direction just after the very first post in this topic.
The trick is to use emerge -e with ROOT=<target directory> variable.
Also, usng binary packages seems to help with weird build-time errors. So, the easy way to do what I wanted seems to be:

emerge -eb[ @system ] [packages]
ROOT=<target> emerge -e --getbinpkg --root-deps=rdeps

Maybe someone will find this usefull
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3104

PostPosted: Fri May 30, 2014 10:07 am    Post subject: Reply with quote

As I got new toys to play with I came back to this little (by current standards) project. In hope to make it tiny instead, I managed to get fairly lightweight, static (linke in not to ever be updated) image. Current, bz2 compressed image is a bit over 20MB, which grows to ~50MB after including mplayer, and is made of:

sys-apps/busybox
sys-apps/openrc
sys-apps/util-linux
app-shells/bash
sys-apps/net-tools
sys-apps/grep
sys-process/procps
sys-apps/shadow
sys-apps/coreutils
sys-apps/baselayout
sys-libs/glibc

A huge improvement, yet I still want more. Well, actually I want less. And make it play videos rather than simply boot and show a nice, black screen of bash, since mplayer crashes on launch with error saing it needs libstdc++.so.6 and it can't find it.
Quote:
equery b /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++*
* Searching for /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++.a,/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++.so,/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++.so.6,/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++.so.6.0.17 ...

Yup. Nothing here. No pakage owns those even though they are installed by regular gentoo stage3 and its @system. Bug in some ebuild?

Anyway, as soon as I get mplayer back to work I'm gonna try to replace some stuff there with lighter counterparts.
Getting rid of glibc (it's binary tbz is 18MB) would be really really cool.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Fri May 30, 2014 11:22 am    Post subject: Reply with quote

szatox wrote:
sys-apps/net-tools

szatox ... it may or may not help reduce the size but I have net-tools in package.provided as I use sys-apps/iproute2 exclusively. The only components from net-tools that you might generally want (or are expected by some apps) are 'hostname' and 'ifconfig' but these are provided by busybox and so can be symlinked in /bin. That said iproute2 weighs in at a little under 2mb ...

Code:
# equery size iproute2
 * sys-apps/iproute2-3.8.0
    Total files : 123
    Total size  : 1.88 MiB

szatox wrote:
sys-apps/grep
sys-process/procps
[...]
sys-apps/coreutils

busybox also provides grep, ps, pgrep, tail, uniq, tty, etc ... commands provided by the above. In fact, if you install busybox it seems odd not to then call 'busybox --install' or have the 'symlink' useflag.

szatox wrote:
since mplayer crashes on launch with error saing it needs libstdc++.so.6 and it can't find it.
Code:
equery b /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++*
 * Searching for /usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++.a,/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++.so,/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++.so.6,/usr/lib64/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++.so.6.0.17 ...

libstdc++ is enabled via the 'cxx' useflag ... perhaps the target has this disabled.

szatox wrote:
Getting rid of glibc (it's binary tbz is 18MB) would be really really cool.

blueness (Anthony Basile) has a recent post on some of the problems with uClibc wherein sys-libs/musl is presented as "much more attractive".

best ... khay
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3104

PostPosted: Fri May 30, 2014 12:17 pm    Post subject: Reply with quote

Thanks for hints, it seems you have just saved me quite a lot of reseach, particularly on busybox (perhaps that was a mistake, but I was more interested in figuring out what I can remove without breaking everything and debugging build script)
I tried to build a few versions of libc, dietlibc looks promissing. I think building uclibc failed on my buildhost, but w/e, time for a little cleanup on buildhost, I'll check out on that mplayer first and I hope to post some success report soo. (e.g. when it's ready :D )

edit: I had to take a few steps back after messing up with buildhost's profile. Back to work though, uclibc can only be compiled with crossdev, and crossdev refuses to build toolchain for native arch, so while it seems to really be worth giving it a shot, I'm going to do that german-spanish hybrid way (it has to be done perfectly... tommorow :lol: ). In the meantime I tried to make a full use of busybox, and I found myself in dependency hell. I think I'll have to get a closer look at declared dependencies and either modify ebuilds (a lot of work as there are 50-70 packages pulled in) or assemble correct set manualy and install them all with --nodeps. Of course it's not busybox's fault. It was just a trigger that made it obvious. Silly me :oops: should have noticed it long long time ago.


Last edited by szatox on Sat May 31, 2014 7:03 pm; edited 2 times in total
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Fri May 30, 2014 12:39 pm    Post subject: Reply with quote

szatox wrote:
Thanks for hints, it seems you have just saved me quite a lot of reseach, particularly on busybox (perhaps that was a mistake, but I was more interested in figuring out what I can remove without breaking everything and debugging build script)

szatox ... you're welcome. Using busybox for coreutils, etc, would make sense, and will save some considerable space, but there are the odd occasions in which the busybox modules will not have some of the switches that the standard utils have ... it should work fine for most things.

szatox wrote:
I tried to build a few versions of libc, dietlibc looks promissing.

I'd use musl or uClibc in preference to dietlibc, see this comparison and note that dietlibc has no gcc libstdc++ compatibility (which would be required for mplayer). The comparison is a little outdated but the dietlibc checklist is probably that of the current release.

best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum