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 [] (I've decided to go with one full gpt partition.).

next, preform the stage unpack [] 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 []. 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