Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Doing a tiny Gentoo install
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
Marcih
Tux's lil' helper
Tux's lil' helper


Joined: 19 Feb 2018
Posts: 147

PostPosted: Thu Mar 21, 2019 12:01 pm    Post subject: Doing a tiny Gentoo install Reply with quote

I'm looking to create a very minimal Gentoo image to be used for GNS3 projects. It needs almost nothing except a TTY and networking, kernel stripped down to the bare bones, the @selected virtually empty etc. I've managed to achieve that, the final install takes up only about 15MB of memory; the issue here is the image size, it's just over 4GB.

I've looked at SquashFS, used in the Gentoo LiveCD, but it says it's RO and I need the devices to be configurable with the configuration being persistent between reboots if at all possible. I've tried Tiny Core Linux but its memory footprint is way too big considering that I need to run sometimes tens of those VMs on a regular desktop, i.e. 4-8GB of RAM, and I haven't figured out how exactly it's constructed.

Would something like having everything except folders like /home and /etc be in SquashFS so that the those excluded can still be written to? Any and all tips are appreciated.
_________________
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
Blind_Sniper
Tux's lil' helper
Tux's lil' helper


Joined: 20 Apr 2018
Posts: 86

PostPosted: Thu Mar 21, 2019 12:45 pm    Post subject: Re: Doing a tiny Gentoo install Reply with quote

Marcih wrote:

I've looked at SquashFS, used in the Gentoo LiveCD, but it says it's RO and I need the devices to be configurable with the configuration being persistent between reboots if at all possible

You need AUFS, not a SquashFS
https://wiki.gentoo.org/wiki/Aufs
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 903
Location: Switzerland

PostPosted: Thu Mar 21, 2019 4:23 pm    Post subject: Reply with quote

Aufs is only needed to make a readonly dir/device writeable. You can easily use squashfs without any aufs or such on top, if you don't need it writeable.
The only thing that you need to worry about is that the root gets assembled before you start the system. This is done via an initrd. if you want to split out things like /etc, then you need to write your own init script in a custom initramfs (I guess genkernel can't do that).
I use custom precompiled VMs with a readonly root (besides /var). I don't use squashfs by now on them, as I got quite good results with just excluding unnecessary stuff like manpages, documentation, headerfiles and such.
This is the rsync command I use to populate the destination root.
Code:
rsync -urlopgtD --exclude=/usr/lib64/python3.6/turtledemo --exclude=/usr/lib64/python3.6/unittest \
--exclude=/usr/x86_64-pc-linux-gnu --exclude=/usr/lib64/python3.6/test --exclude=/usr/share/zoneinfo --exclude=/usr/share/doc --exclude=/usr/share/man \
--exclude=/usr/lib/gcc/*/*/include* --exclude=/usr/lib/gcc/*/*/*/include --exclude=/usr/share/gtk* --exclude=*systemd* \
--exclude=/share/man --exclude=/usr/share/gcc-data --exclude=/var/db/pkg --exclude=/usr/src/* \
--exclude=usr/libexec/gcc --exclude=/usr/lib64/*.h --exclude=/usr/lib64/pkgconfig --exclude=/usr/lib/portage --exclude=/etc/portage \
--exclude=/usr/share/eselect --exclude=/usr/share/info --exclude=/var/db/pkg --exclude=/usr/lib64/php*/include --exclude=/usr/lib64/php*/lib/build \
--exclude=*.a --exclude=*.o --exclude=/usr/share/GeoIP --exclude=/var/lib/gentoo --exclude=/var/lib/portage --exclude=/var/cache/edb \
--exclude=/usr/include --exclude=/usr/share/bison --exclude=/usr/share/info /build/vm/root/* /build/vm/target/

The list of exclusions may vary for your needs and is far from complete, but strips the targetsystem down quite much already.
_________________
Power to the people!
Back to top
View user's profile Send private message
Marcih
Tux's lil' helper
Tux's lil' helper


Joined: 19 Feb 2018
Posts: 147

PostPosted: Sun Mar 24, 2019 12:42 pm    Post subject: Reply with quote

nativemad wrote:
Aufs is only needed to make a readonly dir/device writeable.
That's what confused me about Blind_Sniper's suggestion, I'm not trying to make a LiveCD.
nativemad wrote:
You can easily use squashfs without any aufs or such on top, if you don't need it writeable.
That's the issue: I do need it writeable (or at least parts of the system need to be). I need to be able to change things like the system's hostname, routing table, fully configure the netif and make all this persistent if possible (the way I understand it is SquashFS + aufs appears writeable but the changes are lost one you reboot).
nativemad wrote:
The only thing that you need to worry about is that the root gets assembled before you start the system. This is done via an initrd. if you want to split out things like /etc, then you need to write your own init script in a custom initramfs (I guess genkernel can't do that).
This would be the case if I split a vital part of the root filesystem from it right? Meaning splitting /etc from /.
nativemad wrote:
I use custom precompiled VMs with a readonly root (besides /var). I don't use squashfs by now on them, as I got quite good results with just excluding unnecessary stuff like manpages, documentation, headerfiles and such.
I've actually managed to trim the system down to a managable 400MB. I've even deleted things like /usr/portage because I don't need Portage to work, only the very basics. I'm of course looking to compress it even further so I may try SquashFS root with /etc split.
I've come across a small issue though: GNS3 needs either telnet, VNC or SPICE to connect to the VM. Since all I need is a TTY and don't have X installed I figured telnet would be the most fitting. However the machine doesn't seem to respond via telnet. Is there something I'm missing here? A kernel option or a package maybe?
_________________
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
Blind_Sniper
Tux's lil' helper
Tux's lil' helper


Joined: 20 Apr 2018
Posts: 86

PostPosted: Sun Mar 24, 2019 3:52 pm    Post subject: Reply with quote

Marcih wrote:
That's the issue: I do need it writeable (or at least parts of the system need to be). I need to be able to change things like the system's hostname, routing table, fully configure the netif and make all this persistent if possible (the way I understand it is SquashFS + aufs appears writeable but the changes are lost one you reboot).


AUFS gives you opportunity to save changes you made, if you want to make your changes persistent.
AUFS image has RO and RW layers. If you want to fixate changes you made since last boot, you easily recreating AUFS image "on the fly" when you shutting your system down. The difference between RW and RO layers will be applied to an image. New image reflects all the changes, and on next boot your system will use settings which you set during previous session, you can easily sync your portage tree and save current tree state, install software and use installed programs on next boots. In other words it's an ordinary system (like on your HDD), but it compressed into squash image in order to reduce a space and fit it to DVD or USB stick.
If you do not want to make any changes you just skipping image recreation stage when shutting your system down.
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 903
Location: Switzerland

PostPosted: Sun Mar 24, 2019 5:50 pm    Post subject: Reply with quote

Aufs can use a ramdrive as it's store for livecds and such. Changes will get lost after a reboot that way obviously.
Aufs can also use a normal directory to store the changes. That way you'll be able to reassemble the fs after a reboot.
You can also make a combination and write out the ramdrive upon shutdown and repopulate it on startup.
With a squashfs as root, you'll need an initrd anyway. It doesn't really matter if you use aufs to get a writeable /etc or if you just use a normal other partition,disk,imagefile,WhateverIsWriteable to store /etc and mount that on top of the mounted squashfs. /etc shouldn't be that large, so the difference will not be that much...
_________________
Power to the people!
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