Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
a lean linux distribution
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
silvermangb
n00b
n00b


Joined: 21 May 2016
Posts: 4

PostPosted: Sat May 21, 2016 9:45 pm    Post subject: a lean linux distribution Reply with quote

I am learning gentoo because I want to create a very lean distribution, minimizing the total number of bytes for all files before installing my application software.

After building gentoo there are hundreds of megabytes of files I need to eliminate, such as the portage package manager, python2 and python3, etc. The software on these machines will never need to update or upgrade, they will have all software completely reinstalled.

What procedures are there to remove unnecessary files?
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


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

PostPosted: Sat May 21, 2016 11:38 pm    Post subject: Reply with quote

silvermangb ...

if you want "very lean" then perhaps gentoo isn't the best choice, something like Alpine or Aboriginal would be better suited. That said, you should look at '--root=/path' and '--root-deps=rdeps' (man emerge), and INSTALL_MASK, FEATURES="nodoc noman noinfo", in the portage and make.conf manpages. You might also think about building from either the uClibc or musl stage3.

HTH & best ... khay
Back to top
View user's profile Send private message
silvermangb
n00b
n00b


Joined: 21 May 2016
Posts: 4

PostPosted: Sun May 22, 2016 6:16 pm    Post subject: Reply with quote

I added

FEATURES="sandbox nodoc noman noinfo"

to make.conf, but, it did make the documents, manual, and info :(
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sun May 22, 2016 6:31 pm    Post subject: Reply with quote

silvermangb,

Yes, they are still made ... then they are thrown away. Its a feature.
_________________
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
silvermangb
n00b
n00b


Joined: 21 May 2016
Posts: 4

PostPosted: Sun May 22, 2016 6:32 pm    Post subject: Reply with quote

Ok, but when are they thrown away? they were still there after rebooting to the new installation.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Sun May 22, 2016 6:34 pm    Post subject: Reply with quote

silvermangb,

They are thrown away at install time. Those FEATURE changes will not affect packages that are already installed.
_________________
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
khayyam
Watchman
Watchman


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

PostPosted: Sun May 22, 2016 7:34 pm    Post subject: Reply with quote

silvermangb ...

I was pointing out how you might build a "very lean" install, so, from the start of the build. This you would do by firstly using a suitable stage3, or build, and using '--root=/path' and '--root-deps=rdeps' so that the target (the path stipulated by --root) would only be runtime requirements (which is all you need given the install won't be updated ... no build time dependencies are required). Using FEATURES, INSTALL_MASK, etc, you could further slim it down, but as you're not going to be using any method to manage the install you can as well remove these paths by hand:

Code:
# rm -fr /usr/share/{man,doc,info}

This all comes down to what "very lean" means, you can probably build something that is only a few megabytes, ie, using a lighter libc implimentation (dietlibc, uClibc, musl), busybox in place of many tools, etc, etc, but gentoo is probably not the most suitable for such a system, as much of what makes gentoo gentoo is being able to manage the install subsequently and so you have to work around the fact with the above features. A distribution such as Alpine Linux might be better suited, it is binary (so no build time requirements needed), uses musl libc and busybox, and a full install runs about 130MB (which could be further slimmed down, as that also includes much you may not want/need ... like manpages).

best ... khay
Back to top
View user's profile Send private message
silvermangb
n00b
n00b


Joined: 21 May 2016
Posts: 4

PostPosted: Sun May 22, 2016 10:35 pm    Post subject: Reply with quote

For my current project, less than 500MB of system and application files would be lean enough. I took a trial run at using the root, say --root=/target-root, and root-deps command line parameters on emerge and it looks as though that could do the trick. But, it looks like, at some point, I would have to chroot to target-root to build and install the kernel and grub. Ot takes a very long time by trial and error to find out what works, so, I ask, can I emerge everything to target-root and chroot into it after the emerges are done?

Thanks
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


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

PostPosted: Sun May 22, 2016 11:17 pm    Post subject: Reply with quote

silvermangb wrote:
[...] so, I ask, can I emerge everything to target-root and chroot into it after the emerges are done?

silvermangb ... yes, of course, 'target-root' would be a functioning system, though without /proc /sys /dev/{,pts} (as these are populated at boot), you could bind mount them from the boot medium if needed.

As for the kernel sources, and grub, you should probably build a kernel outside of target-root as there is no builtime tools within (and so installing sys-kernel/*-sources to it is pointless). As for grub, you can run grub*-install from another medium onto the bootdisk (though obviously not the --root= if that is part of the root of the build system).

best ... khay
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Mon May 23, 2016 11:45 am    Post subject: Reply with quote

silvermangb,

It sounds as if you are doing what the embeded project was designed for, except you do not need a cross compiler.
It may be useful.
_________________
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
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3136

PostPosted: Tue May 24, 2016 4:31 pm    Post subject: Reply with quote

Quote:
But, it looks like, at some point, I would have to chroot to target-root to build and install the kernel and grub. Ot takes a very long time by trial and error to find out what works, so, I ask, can I emerge everything to target-root and chroot into it after the emerges are done?
You can build kernel with your buildhost and then copy it to the target.
You can install build host's grub onto the target device as well. You don't have to install it inside guest as long as you do not have to reinstall it later without build host's support. E.g. you're making a static, non-servisable image, or use bootloader that does not require reinstalling when configuration changes (grub legacy -> config in a simple plain text file)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Tue May 24, 2016 6:52 pm    Post subject: Reply with quote

szatox,

szatox wrote:
You can install build host's grub onto the target device as well.


Maybe. When grub is installed to the MBR, there is some binary patching done, so you may not be able to lift the installed MBR with dd.
The patching allows the MBR code to find the next stage of grub.
_________________
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
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3136

PostPosted: Wed May 25, 2016 5:53 pm    Post subject: Reply with quote

Yes Neddy, AFAIK it hardcodes location of the next stage loaded by the piece located in MBR, so you have to be careful when you play with partition layout. However, if you're going to move it with dd, it's not an installation to the target device.
Good news is, if you actually have to move that build with dd, all it takes is putting the rest of grub on the first partition. It can be either root or (better) separate boot partition. The last partition can be expanded after writing image to a disk, and additional partitions may be created afterwards, it doesn't matter. Don't touch stage files and you will be fine.
Oh, and this tool comes in handy if things go very wrong: LINK I'm a bit disappointed it grew that fat over time. I can remember running it from a floppy :roll:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat 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