View previous topic :: View next topic |
Author |
Message |
silvermangb n00b

Joined: 21 May 2016 Posts: 4
|
Posted: Sat May 21, 2016 9:45 pm Post subject: a lean linux distribution |
|
|
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 |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat May 21, 2016 11:38 pm Post subject: |
|
|
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 |
|
 |
silvermangb n00b

Joined: 21 May 2016 Posts: 4
|
Posted: Sun May 22, 2016 6:16 pm Post subject: |
|
|
I added
FEATURES="sandbox nodoc noman noinfo"
to make.conf, but, it did make the documents, manual, and info  |
|
Back to top |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 55200 Location: 56N 3W
|
Posted: Sun May 22, 2016 6:31 pm Post subject: |
|
|
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 |
|
 |
silvermangb n00b

Joined: 21 May 2016 Posts: 4
|
Posted: Sun May 22, 2016 6:32 pm Post subject: |
|
|
Ok, but when are they thrown away? they were still there after rebooting to the new installation. |
|
Back to top |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 55200 Location: 56N 3W
|
Posted: Sun May 22, 2016 6:34 pm Post subject: |
|
|
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 |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sun May 22, 2016 7:34 pm Post subject: |
|
|
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 |
|
 |
silvermangb n00b

Joined: 21 May 2016 Posts: 4
|
Posted: Sun May 22, 2016 10:35 pm Post subject: |
|
|
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 |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sun May 22, 2016 11:17 pm Post subject: |
|
|
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 |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 55200 Location: 56N 3W
|
Posted: Mon May 23, 2016 11:45 am Post subject: |
|
|
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 |
|
 |
szatox Advocate

Joined: 27 Aug 2013 Posts: 3619
|
Posted: Tue May 24, 2016 4:31 pm Post subject: |
|
|
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 |
|
 |
NeddySeagoon Administrator


Joined: 05 Jul 2003 Posts: 55200 Location: 56N 3W
|
Posted: Tue May 24, 2016 6:52 pm Post subject: |
|
|
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 |
|
 |
szatox Advocate

Joined: 27 Aug 2013 Posts: 3619
|
Posted: Wed May 25, 2016 5:53 pm Post subject: |
|
|
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  |
|
Back to top |
|
 |
|
|
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
|
|