Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Any tips on minimizing the gentoo installation?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
jenkler
Apprentice
Apprentice


Joined: 28 Apr 2003
Posts: 209
Location: Sweden - Stockholm

PostPosted: Sat Aug 25, 2018 10:34 am    Post subject: Any tips on minimizing the gentoo installation? Reply with quote

Optimize my build:

Code:
CFLAGS="-march=corei7 -Os -pipe"
CHOST="x86_64-pc-linux-gnu"
CPU_FLAGS_X86="mmx sse sse2 sse3 ssse3 sse4_1 sse4_2"
CXXFLAGS="${CFLAGS}"
FEATURES="nodoc noinfo noman unmerge-orphans"
LINGUAS="en sv"
MAKEOPTS="-j9"
USE="
hardened
minimal mmx
nptl nptlonly
sse sse2 sse3 ssse3 sse4_1 sse4_2
threads
-X"

PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"


After install cleanup

Code:
function clean {
  if [ -f "/build/$build/usr/bin/eselect" ]; then
    chroot /build/$build eselect news read
    chroot /build/$build eselect news purge
  fi
  if [ $build != 'gentoo-base-minimal' ] && [ $build != 'distcc' ]; then
    emerge --color=n --nospinner --root="/build/$build" -Cqv app-portage/gentoolkit app-portage/portage-utils sys-devel/autoconf \
    sys-devel/autoconf-wrapper sys-devel/autogen sys-devel/automake sys-devel/automake-wrapper sys-devel/bin86 sys-devel/binutils \
    sys-devel/binutils-config sys-devel/bison sys-devel/flex sys-devel/gcc sys-devel/gcc-config sys-devel/gettext \
    sys-devel/gnuconfig sys-devel/libtool sys-devel/llvm sys-devel/m4 sys-devel/make
  fi

  rm /build/$build/etc/group- &> /dev/null
  rm -r /build/$build/etc/modprobe.d &> /dev/null
  rm -r /build/$build/root/* &> /dev/null
  rm -r /build/$build/root/.* &> /dev/null
  rm -r /build/$build/tmp/* &> /dev/null
  rm -r /build/$build/tmp/.* &> /dev/null
  rm -r /build/$build/usr/local &> /dev/null
  rm -r /build/$build/usr/portage &> /dev/null
  rm -r /build/$build/usr/share/doc &> /dev/null
  rm -r /build/$build/usr/share/info &> /dev/null
  rm -r /build/$build/usr/share/man &> /dev/null
  rm -r /build/$build/var/tmp/* &> /dev/null
  rm -r /build/$build/var/tmp/.* &> /dev/null
  rm -r /build/$build/var/log/* &> /dev/null
  rm -r /build/$build/var/log/.* &> /dev/null
  touch /build/$build/root/.keep /build/$build/tmp/.keep /build/$build/var/tmp/.keep /build/$build/var/log/.keep &> /dev/null
}

More stuff I can remove? Or other tips? More packages that is for compile time only, is there a list?

[Moderator edit: added [code] tags to preserve output layout. -Hu]
_________________
This is me: Mikael Jenkler, use google translate when viewing my page, please!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43198
Location: 56N 3W

PostPosted: Sat Aug 25, 2018 11:13 am    Post subject: Reply with quote

jenkler,

Tell us the problem you want to solve rather than your solution.

e.g.
Code:
rm -r /build/$build/usr/share/doc &> /dev/null
rm -r /build/$build/usr/share/info &> /dev/null
rm -r /build/$build/usr/share/man &> /dev/null
is the same as FEATURES="nodoc noinfo noman" so that they are not installed in the first place.

/usr/local should be empty.
If you have the RAM on the build host, /var/tmp/ and /var/log/ can be in RAM, so its gone after reboot.

If /etc/group- is a concern, so is /etc/passwd- and /etc/shadow-
My own use case is to fit Gentoo onto a 2008 Acer One netbook with a 8G SSD.

I do that by building on an external HDD, to avoid the SSD writes, with the HDD partitioned to leave things behind that I don't want when I copy the install over.
You don't need /usr/src, which in the kernel build location. That's about 1G per compiled kernel.

You don't need the toolchain either, unless you plan on having the capability to install more software.

With Mate, Xfce4 and the toolchain, my stripped down Gentoo is about 6G. That gives me 1.5G for swap, so I can hibernate the system. About 32M for swap and a little left over for /home.

If you have the RAM on the build host, /var/tmp/ and /var/log/ can be in RAM, so its gone
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
jenkler
Apprentice
Apprentice


Joined: 28 Apr 2003
Posts: 209
Location: Sweden - Stockholm

PostPosted: Sat Aug 25, 2018 9:37 pm    Post subject: Reply with quote

Thanks for the input :)

This is my build script for my docker files. The clean func runs after build time to remove unnecessary stuff. I build the system in a new root with root= arg to emerge. I want to be 100 sure of removal so, i can run rm on stuff that not installed.


"You don't need the toolchain either, unless you plan on having the capability to install more software. " <-- What pkg is that, do you have a list ?


Here is the updated version:

function clean {
if [ -f "$path/usr/bin/eselect" ]; then
chroot $path eselect news read
chroot $path eselect news purge
fi
if [ $build != 'gentoo-base-minimal' ] && [ $build != 'distcc' ]; then
emerge --color=n --nospinner --root="$path" -Cqv app-portage/gentoolkit app-portage/portage-utils sys-devel/autoconf \
sys-devel/autoconf-wrapper sys-devel/autogen sys-devel/automake sys-devel/automake-wrapper sys-devel/bin86 sys-devel/binutils \
sys-devel/binutils-config sys-devel/bison sys-devel/flex sys-devel/gcc sys-devel/gcc-config sys-devel/gettext \
sys-devel/gnuconfig sys-devel/libtool sys-devel/llvm sys-devel/m4 sys-devel/make
fi

rm $path/etc/group- $path/etc/passwd- $path/etc/shadow- &> /dev/null
rm -r $path/etc/modprobe.d &> /dev/null
rm -r $path/root/* $path/root/.* &> /dev/null
rm -r $path/tmp/* $path/tmp/.* &> /dev/null
rm -r $path/usr/local &> /dev/null
rm -r $path/usr/portage &> /dev/null
rm -r $path/usr/share/doc &> /dev/null
rm -r $path/usr/share/info &> /dev/null
rm -r $path/usr/share/man &> /dev/null
rm -r $path/var/tmp/* $path/var/tmp/.* &> /dev/null
rm -r $path/var/log/* $path/var/log/.* &> /dev/null
touch $path/root/.keep $path/tmp/.keep $path/var/tmp/.keep $path/var/log/.keep &> /dev/null
}
_________________
This is me: Mikael Jenkler, use google translate when viewing my page, please!
Back to top
View user's profile Send private message
mike155
Veteran
Veteran


Joined: 17 Sep 2010
Posts: 1294
Location: Frankfurt, Germany

PostPosted: Sun Aug 26, 2018 12:44 am    Post subject: Reply with quote

Quote:
USE="... mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 ..."

Those atoms shouldn't be in your USE flags. Move them to CPU_FLAGS_X86.
Back to top
View user's profile Send private message
jenkler
Apprentice
Apprentice


Joined: 28 Apr 2003
Posts: 209
Location: Sweden - Stockholm

PostPosted: Sun Aug 26, 2018 8:29 am    Post subject: Reply with quote

mike155 wrote:
Quote:
USE="... mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 ..."

Those atoms shouldn't be in your USE flags. Move them to CPU_FLAGS_X86.


Thanks for the heads up. Found doc about it here: https://wiki.gentoo.org/wiki/CPU_FLAGS_X86

But as you can see I have them in both CPU_FLAGS_X86 and USE. I think it can do some good to have then on both places, NOTE: Any hardcore Gentoo devs that can confirm that those flags does something in the USE also.

Love the feedback people, anything else?
_________________
This is me: Mikael Jenkler, use google translate when viewing my page, please!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43198
Location: 56N 3W

PostPosted: Sun Aug 26, 2018 9:04 am    Post subject: Reply with quote

jenkler,

Code:
USE="... mmx sse sse2 sse3 ssse3 sse4_1 sse4_2 ..."
and friends were moved to the CPU_FLAGS_X86 use expand in the main portage tree several years ago.
However, if you use overlays, its up to the overlay maintainer to do the migration.
The flags are harmless in both places. Note that they are not options passed to the compiler, rather they instruct build system to include specially optimised code that takes advantage of these instruction sets.


The toolchain and a few other packages are built by /usr/portage/scripts/bootstrap.sh
That's the script that does stage1 of of a stage1 install. It will give you some ideas of what else you can remove.
gcc and portage come to mind but not glibc.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
jenkler
Apprentice
Apprentice


Joined: 28 Apr 2003
Posts: 209
Location: Sweden - Stockholm

PostPosted: Sun Aug 26, 2018 9:11 am    Post subject: Reply with quote

Wow, how could i forget sys-apps/portage. Thanks

Updated:



function clean {
if [ -f "$path/usr/bin/eselect" ]; then
chroot $path eselect news read
chroot $path eselect news purge
fi
if [ $build != 'gentoo-base-minimal' ] && [ $build != 'distcc' ]; then
emerge --color=n --nospinner --root="$path" -Cqv app-portage/gentoolkit app-portage/portage-utils sys-apps/portage sys-devel/autoconf \
sys-devel/autoconf-wrapper sys-devel/autogen sys-devel/automake sys-devel/automake-wrapper sys-devel/bin86 sys-devel/binutils \
sys-devel/binutils-config sys-devel/bison sys-devel/flex sys-devel/gcc sys-devel/gcc-config sys-devel/gettext \
sys-devel/gnuconfig sys-devel/libtool sys-devel/llvm sys-devel/m4 sys-devel/make virtual/*
fi

rm $path/etc/group- $path/etc/passwd- $path/etc/shadow- &> /dev/null
rm -r $path/etc/modprobe.d &> /dev/null
rm -r $path/root/* $path/root/.* &> /dev/null
rm -r $path/tmp/* $path/tmp/.* &> /dev/null
rm -r $path/usr/local &> /dev/null
rm -r $path/usr/portage &> /dev/null
rm -r $path/usr/share/doc &> /dev/null
rm -r $path/usr/share/info &> /dev/null
rm -r $path/usr/share/man &> /dev/null
rm -r $path/var/db &> /dev/null
rm -r $path/var/tmp/* $path/var/tmp/.* &> /dev/null
rm -r $path/var/log/* $path/var/log/.* &> /dev/null
touch $path/root/.keep $path/tmp/.keep $path/var/tmp/.keep $path/var/log/.keep &> /dev/null
}


/var/db must be safe to remove ?


gcc is removed but as you say not glibc :P Fun to take that one away... My new brick system hehe
_________________
This is me: Mikael Jenkler, use google translate when viewing my page, please!
Back to top
View user's profile Send private message
Marcih
Apprentice
Apprentice


Joined: 19 Feb 2018
Posts: 152

PostPosted: Mon Aug 27, 2018 12:52 pm    Post subject: Reply with quote

Unimportant but worth considering:

_________________
Bones McCracker wrote:
It wouldn't be so bad, if it didn't suck.

===
I refuse to move on from GTK+2.
Back to top
View user's profile Send private message
Anon-E-moose
Advocate
Advocate


Joined: 23 May 2008
Posts: 3948
Location: Dallas area

PostPosted: Mon Aug 27, 2018 1:06 pm    Post subject: Reply with quote

good advice on march native.

Re the jobs vs cores, even from the command line with me doing nothing but emerge I like to keep # of jobs = # of cores.
If I'm in X and doing something I might even run the # of jobs to half the # of cores, since I consider it background, I don't care if it takes a little longer.
_________________
Asus m5a99fx, FX 8320 - nouveau, oss4, rx550 for qemu passthrough
Acer laptop E5-575, i3-7100u - i965, alsa
---both---
5.0.13 zen kernel, profile 17.0 (no-pie) amd64-no-multilib
gcc 8.2.0, eudev, openrc, openbox, palemoon
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43198
Location: 56N 3W

PostPosted: Mon Aug 27, 2018 2:05 pm    Post subject: Reply with quote

jenkler,

Rather than the top down approach of building too much and ripping things out, consider bottom up. Only putting into the container what is actually needed.

I wrote Installing Gentoo Using Packages on the liveDVD a long time ago, mostly because someone told me it wasn't possible. :)

The interesting bit for you is how little you need in the chroot to be able to chroot. See Section 5.
The method is to make or acquire some binary packages, then unpack them.
Add your app and anything that it needs and you are done.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
jenkler
Apprentice
Apprentice


Joined: 28 Apr 2003
Posts: 209
Location: Sweden - Stockholm

PostPosted: Mon Aug 27, 2018 2:48 pm    Post subject: Reply with quote

Yes, indeed. But a lot of things are needed at gentoo buildtime. Those things need to be removed afterwards ;)
_________________
This is me: Mikael Jenkler, use google translate when viewing my page, please!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43198
Location: 56N 3W

PostPosted: Mon Aug 27, 2018 2:55 pm    Post subject: Reply with quote

jenkler,

With the bottom up approach you only untar the required binaries into your container filesystem space.
The Gentoo build system stays outside so the container gets only what is required.
There is nothing to remove.

You can have emerge do that directly. It understands several different $ROOT environmental variables, so you can keep your build system and container run time completely separate.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
jenkler
Apprentice
Apprentice


Joined: 28 Apr 2003
Posts: 209
Location: Sweden - Stockholm

PostPosted: Mon Aug 27, 2018 3:11 pm    Post subject: Reply with quote

Thats what I am doing, see the code. Note the --root arg. This is just some extra cleanup :p
_________________
This is me: Mikael Jenkler, use google translate when viewing my page, please!
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


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

PostPosted: Mon Aug 27, 2018 5:56 pm    Post subject: Reply with quote

jenkler wrote:
Thats what I am doing, see the code. Note the --root arg. This is just some extra cleanup :p

jenkler ... I see no mention of it anywhere ... but anyhow, as you're getting buildtime deps, and have to then remove them, you probably should be using '--root-deps=rdeps' in conjunction with '--root'

best ... khay
Back to top
View user's profile Send private message
jenkler
Apprentice
Apprentice


Joined: 28 Apr 2003
Posts: 209
Location: Sweden - Stockholm

PostPosted: Mon Aug 27, 2018 6:04 pm    Post subject: Reply with quote

Wtf... That one was a great one ;) Thanks man! Testing now!

SO this:

emerge --color=n --nospinner --root="$path" --root-deps=rdeps -qv dev-java/oracle-jre-bin

is better than

emerge --color=n --nospinner --root="$path" -qv dev-java/oracle-jre-bin

if I dont want extra files in my new root (--root). correct?


should i use SYSROOT also or what is EAPI 7?


-------------

--root-deps[=rdeps]
If no argument is given then build-time dependencies of packages for ROOT are installed to ROOT instead of /. If the rdeps argument is given then discard all build-time dependencies of packages for ROOT. This option is only meaningful when used together with ROOT and it should not be enabled under normal circumstances!
Does not affect EAPIs that support BDEPEND or HDEPEND. EAPI 7 introduces BDEPEND and experimental EAPI 5-hdepend features HDEPEND as a means to adjust installation into / and ROOT. Use the SYSROOT environment variable to control where DEPEND is installed to under EAPI 7.

When ebuilds with different EAPIs feature in the same emerge run, the appropriate behaviour for each EAPI is applied independently to each ebuild.

---------------
_________________
This is me: Mikael Jenkler, use google translate when viewing my page, please!
Back to top
View user's profile Send private message
jenkler
Apprentice
Apprentice


Joined: 28 Apr 2003
Posts: 209
Location: Sweden - Stockholm

PostPosted: Mon Aug 27, 2018 6:43 pm    Post subject: Reply with quote

Sorry but the --root-deps=rdeps option broke the build. Better to have deps, its more safe that way! I guess that some packages dont like this :P

Thanks anyway!
_________________
This is me: Mikael Jenkler, use google translate when viewing my page, please!
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


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

PostPosted: Mon Aug 27, 2018 6:55 pm    Post subject: Reply with quote

jenkler wrote:
Sorry but the --root-deps=rdeps option broke the build. Better to have deps, its more safe that way! I guess that some packages dont like this :P

jenkler ... that doesn't exclude (runtime) deps (rdeps), it excludes bdeps (build deps). You should probably add '--with-bdeps=y' to the emerge, as your failure may be due to their being an older bdep that satisfies the dependency, but that may need updated for the package to build (that would be my first assumption anyhow, but without the build.log its next to impossible to say what went wrong).

best ... khay
Back to top
View user's profile Send private message
jenkler
Apprentice
Apprentice


Joined: 28 Apr 2003
Posts: 209
Location: Sweden - Stockholm

PostPosted: Mon Aug 27, 2018 7:16 pm    Post subject: Reply with quote

Ok, thanks. Will lab with the settings :)
_________________
This is me: Mikael Jenkler, use google translate when viewing my page, please!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing 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