User:Daggystyle/Nfs based binhost setup

NFS based Server/Client BinHost setup
the following tutorial will show how to create a binhost server and client setup for gentoo. the base assumption are follows:
 * both server and client are of the same arch, in my case x86_64.
 * there is an network connection between both setups.

Build Chroot Creation
the below steps will result with a basic build chroot for the binhost server.

img and env preperation
first, create the proper tree by running the following cmd:

next, allocate an image file on the server with a size which will accommodate the new chroot. my client runs from a 16GB usb thumb drive, so I used that exactly. the cmd is:

the next step will be to load the image so it can be used, the cmd is rather simple:

this will bind /mnt/gentoo_binhost/chroot.img.raw to the first free loop device found on the system. in order to see which loop device was used, run: and examine the output. from now on, is it the same as the install handbook, e.g. create the proper partition table on the image Handbook:AMD64/Installation/Disks (I've decided to go with one full gpt partition.). next, preform the stage unpack Handbook:AMD64/Installation/Stage and don't forget to mount the root folder.

configuration
now it is time to setup the system, edit make.conf as follows:

and populate it as follows:

create the bin pkgs target folder:

the last step is to edit /mnt/gentoo_binhost/chroot/etc/profile:

and add the following to the end:

if you need to use package.{use|mask|unmask}, you can do the following: create the missing folder under /mnt/gentoo_binhost/binpkgs/portage-env, for example:

then, edit the a file inside, for example:

Chroot Utils Creation
this section will introduce the needed utils which will allow easy pkg management.

bh_emerge.sh
bh_emerge.sh is short for binhost emerge, this script will generate the required pkgs for the client to use. execute the following cmd:

and update the file as follows:

don't forget to set the proper permissions as follows:

build_kernel.sh
build_kernel.sh is the script that will compile and pack the kernel. create the file as follows:

and update the file as follows:

don't forget to set the proper permissions as follows:

binhost configuration
this section will configure the binhost.

NFS Server configuration
install nfs-utils Nfs-utils. next, configure the export by executing:

and add the following to it:

save and exit and execute:

verify there aren't any errors.

make.conf.defs
now it is time to configure the make.conf.

setting COMMON_FLAGS
the main issue with COMMON_FLAGS is -march, if the serer and client cpus are the same, -march=native can be used. if not, use -march=x86-64. using a more fitting compile opts will be added at later stage.

and populate it as follows:

CPU_FLAGS_X86 generation will be covered in a later stage.

additional portage env config
if you need to use package.{use|mask|unmask}, you'll need to follow the relevant steps the chroot config section. afterwards, create the relevant link, for example:

chroot handling utils
all the above is nice to have but abit hard to use for simple maintainment. for this there is /mnt/gentoo_binhost/manage_chroot.sh. run and populate it as follows:

save it and execute:

to allow execution.

last but not least, create the proper links so the relevant folder content will be as follows:

this concludes the binhost setup and configuration.

bin client configuration
this section will configure the bin client.

basic installation
for this stage, you will need the same basic requirements as a normal installation with one restriction, the installation env must support nfs mount. the gentoo net install cd will do just fine.

follow the guide until the configure the compile opts step (Handbook:AMD64/Installation/Stage)

first thing in order to update make.conf, run

and populate it with these settings:

continue with the installation guide until the mounting part (Handbook:AMD64/Installation/Base) be sure to skip the Gentoo ebuild repository config part as it isn't needed.

after the pre chroot mounts described in the handbook were preforemed, there is a need to monunt the portage nfs and the binpkgs mounts. run the below cmds:

continue with the chroot from the handbook but skip the emerge sync. like in the binhost configuration step.

and add the following to the end:

and apply theses changes on the current chroot by executing