FAI How to build a i386 and x86 64 compatible FAI server on Debian Etch x86 64: Difference between revisions

From FAIWiki
Jump to navigation Jump to search
("hard link not allowed for directory": needs to be ln -s)
(minor updates)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Theses procedures have only been validated on Debian Etch with FAI 3.1.8
These procedures had been validated on Debian Etch with FAI 3.1.8,
and have been revalidated (and updated) for Lenny and FAI 3.2.16.


I was installing an installserver for my company and looking for a way to build and i386 NFSROOT on a amd64 Etch and then build arch specific FAI mirrors and CD images.
I was installing an installserver for my company and looking for a
Here's how I did it.
way to build and i386 NFSROOT on a amd64 Etch and then build arch
specific FAI mirrors and CD images. Here's how I did it.


Important note: this only works if your server runs a amd64 kernel and also only works with amd64 and i386. The reason is simply, because debootstrap installs the packages and then runs the postinst scripts, which in turn (sometimes) run arch-specific binaries, so this only works on amd64, because its possible to execute i386 binaries on amd64. If you want to serve other architecture combinations, you need to create the nfsroot on the target architecture and then copy it to your nfsserver, which can run any OS on any cpu-archtiture :-)
''Important note:'' this only works if your server runs a amd64 kernel
 
and also only works with amd64 and i386. The reason is simply,
----
because debootstrap installs the packages and then runs the postinst
scripts, which in turn (sometimes) run arch-specific binaries, so
this only works on amd64, because its possible to execute i386
binaries on amd64. If you want to serve other architecture
combinations, you need to create the nfsroot on the target
architecture and then copy it to your nfsserver, which can run any
OS on any cpu-archtiture <code>:-)</code>


== FAI Configuration tuning ==
== FAI Configuration tuning ==


All the process described below relies on tuning the FAI configuration space.
All of the processes described below relies on tuning the FAI
Normally, FAI configuration can be found under an unique directory <code>/etc/fai</code>.
configuration space. Normally, FAI configuration can be found under
To make FAI work with multi architecture, you have to duplicate the configuration space for every architecture.
an unique directory <code>/etc/fai</code>. To make FAI work with
Here is an exemple of such a FAI setup :
multi architecture, you have to duplicate the configuration space
for every architecture. Here is an exemple of such an FAI setup :


<pre>
<pre>
Line 20: Line 29:
</pre>
</pre>


To be precise, the directories don't have to be really duplicated, only the <code>make-fai-nfsroot.conf</code> file must. Hard link can be used for the other files or directories under the <code>/etc/fai</code> tree.
To be precise, the directories don't have to be entirely duplicated,
 
only the <code>make-fai-nfsroot.conf</code> file must. Links can
----
be used for the other files or directories under the
<code>/etc/fai</code> tree, although <code>apt/sources.list</code>
must be a hard link or copy; a soft link will not work.


== Cross-Architecture NFSROOT ==
== Cross-Architecture NFSROOT ==
<ul>
=== Create Arch Specific FAI Configuration Direcories ===
<li> Step 1 : Create arch specifics FAI configuration direcories
 
These are the directories that will be used for FAI in this
setup. <code>/etc/fai</code> is still there, since several of the files do not
change, but shouldn't actually be used directly.
 
<pre>
<pre>
for dir in /etc/fai-i386 /etc/fai-amd64 ;
  for dir in /etc/fai-i386 /etc/fai-amd64
do
  do
mkdir $dir
mkdir $dir
cd $dir
cd $dir
ln /etc/fai/fai.conf
ln /etc/fai/fai.conf
ln /etc/fai/NFSROOT
ln /etc/fai/NFSROOT
ln -s /etc/fai/apt
        mkdir $dir/apt
ln /etc/fai/apt/sources.list apt/
ln /etc/fai/menu.lst
ln /etc/fai/menu.lst
cp /etc/fai/make-fai-nfsroot.conf .
cp /etc/fai/make-fai-nfsroot.conf .
done
  done
</pre>
</pre>


</li>
Note that you need to either use hard links or make file copies:
<li> Step 2 : Build a local <code>apt_arch.conf</code> file inside <code>/etc/fai-i386</code> or <code>/etc/fai-amd64</code>
soft links will not work, because they'll be copied as such to the
<ul>
clients and have no referents.
<li> Simply add thoses lines to <code>/etc/fai-i386/apt_arch.conf</code> ( for <code>/etc/fai-amd64/apt_arch.conf</code>, replace i386 by amd64)
 
<pre>
=== Make Per-Arch make-fai-nfsroot.conf ===
APT {
 
Architecture "i386";
Add <code>--arch i386</code> or <code>--arch amd64</code> to
}
<code>FAI_DEBOOTSTRAP_OPTS</code>.
</pre>
 
</li>
Set <code>NFSROOT</code> to <code>/srv/fai/nfsroot-i386</code> or
<li> You can create automagicaly those file running the following script
<code>/srv/fai/nfsroot-amd64</code>, as appropriate.
<pre>
for arch in i386 amd64 ; do
CONTENT='APT {\n\tArchitecture "$arch";\n}'
echo $CONTENT > /etc/fai-$arch/apt_arch.conf
done  
</pre>
</li>
</ul>
</li>


<li> Step 3 : Install fai-kernels packages for the different architectures
Set <code>APT_CONFIG</code> to
<ul><li> Configure and Run this little script for your different architectures
<code>/etc/fai-i386/apt_arch.conf</code>
<pre>
or
rm /tmp/fai-kernel*
<code>/etc/fai-amd64/apt_arch.conf</code>, as appropriate.
for arch in i386 amd64 ; do
echo "Downloading $arch fai-kernels package"
echo "--------------------------------------"
export APT_CONFIG=/etc/fai-$arch/apt_arch.conf
apt-get update
apt-cache -f search fai-kernels
PACKAGE=$(apt-cache -f search fai-kernels | grep Filename | awk ' { print $2 }')
MIRROR=http://ftp.debian.org/debian
wget $MIRROR/$PACKAGE -P /tmp
done
export -n APT_CONFIG
apt-get update
for file in /tmp/fai-kernels* ; do
echo "Unpacking $arch fai-kernels package"
echo "--------------------------------------"
dpkg-deb -x $file /
done
</pre>  
</li>
</ul>
</li>
 
<li> Step 4 : Configure make-fai-nfsroot.conf to be architecture specific
<ul>
<li> Add <code>--arch i386</code> or <code>--arch amd64</code> to <code>FAI_DEBOOTSTRAP</code></li>
<li> Modidy <code>KERNELPACKAGE</code> with the good fai kernel package.</li>
</ul>
</li>
 
 
<li> Step 5 : Build the arch dependant NFSROOT
=== Build The Per-Arch NFSROOT ===
<ul>
 
<li> Execute this commands
Run:
<pre>
 
export APT_CONFIG=/etc/fai-i386/apt_arch.conf
*  fai-setup -C /etc/fai-i386 -v
make-fai-nfsroot -C /etc/fai-i386 -V vmlinuz-install-i386 -v
*  fai-setup -C /etc/fai-amd64 -v
</pre>
 
</li>
You can also run make-fai-nfsroot instead of fai-setup; it's
</ul>
potentially less thorough, but should work.
</li>
 
=== Configure Network Installation ===
 
Run (something like) one of these, depending on what kind of host you are imaging:
 
* fai-chboot -k "initrd=$(ls -rt /srv/tftp/fai/initrd.img*i386* | tail -1 | sed 's;.*/;;') root=/dev/nfs nfsroot=$(host $(uname -n) | grep 'has address' | awk '{ print $4 }' | head -1):/srv/fai/nfsroot boot=live ip=dhcp FAI_FLAGS=verbose,sshd,createvt FAI_ACTION=install nfsroot=/srv/fai/nfsroot-i386" $(ls -rt /srv/tftp/fai/vmlinuz*i386* | tail -1 | sed 's;.*/;;') HOST
* fai-chboot -k "initrd=$(ls -rt /srv/tftp/fai/initrd.img*amd64* | tail -1 | sed 's;.*/;;') root=/dev/nfs nfsroot=$(host $(uname -n) | grep 'has address' | awk '{ print $4 }' | head -1):/srv/fai/nfsroot boot=live ip=dhcp FAI_FLAGS=verbose,sshd,createvt FAI_ACTION=install nfsroot=/srv/fai/nfsroot-amd64" $(ls -rt /srv/tftp/fai/vmlinuz*amd64* | tail -1 | sed 's;.*/;;') HOST
 
== Per-Architecture FAI Mirrors ==


<li> Step 6 : Configure network Install for a particular architecture
Here's how to make fai partial Debian mirrors for both architectures.
<ul>
<li> Run the command below
<pre>
FAI_CHBOOT_ARCH=i386
FAI_CHBOOT_OPT="-k \"ip=dhcp FAI_ACTION=install \
nfsroot=/srv/fai/nfsroot-$FAI_CHBOOT_ARCH,v3,tcp,rsize=32768,wsize=32768\" \
-F  vmlinuz-install-i386 /dev/nfs"
fai-chboot $FAI_CHBOOT_OPT computer
</pre>
</li>
</ul>


----


== Cross-Architecture FAI Mirrors ==
We need to tell apt-get and frineds what's goin on, so we make a
<code>apt_arch.conf</code> file inside <code>/etc/fai-i386</code>
and <code>/etc/fai-amd64</code>.


Simply add thoses lines to <code>/etc/fai-i386/apt_arch.conf</code> ( for <code>/etc/fai-amd64/apt_arch.conf</code>, replace i386 by amd64)


This part describe how to make cross architecture fai partial Debian mirrors.
This relies on the NFSROOT one described above.
   
To build a cross architecture fai mirror, you just have to run the following commands :
<pre>
<pre>
export FAI_ETC_DIR=/etc/fai-i386
  APT {
export APT_CONFIG=/etc/fai-i386/apt_arch.conf
Architecture "i386";
apt-get update
  }
fai-mirror -v /srv/fai/mirror-i386    
</pre>


export -n APT_CONFIG
This relies on the NFSROOT changes described above.
apt-get update
</pre>
   
A script can be written to automatize the building of a whole architecture list. Here is an exemple
   
<pre>
<pre>
for arch in i386 amd64 ; do      
for arch in i386 amd64 ; do      
export FAI_ETC_DIR=/etc/fai-$arch
    export FAI_ETC_DIR=/etc/fai-$arch
export APT_CONFIG=/etc/fai-$arch/apt_arch.conf
    export APT_CONFIG=/etc/fai-$arch/apt_arch.conf
apt-get update
    apt-get update
fai-mirror -v /srv/fai/mirror-$arch
    fai-mirror -v /srv/fai/mirror-$arch
 
    export -n APT_CONFIG
    apt-get update
done
done
</pre>
P.S.: Have a look at the option -a of fai-mirror.    


export -n APT_CONFIG
[[Category:Howto]]
apt-get update
</pre>

Latest revision as of 22:31, 21 November 2010

These procedures had been validated on Debian Etch with FAI 3.1.8, and have been revalidated (and updated) for Lenny and FAI 3.2.16.

I was installing an installserver for my company and looking for a way to build and i386 NFSROOT on a amd64 Etch and then build arch specific FAI mirrors and CD images. Here's how I did it.

Important note: this only works if your server runs a amd64 kernel and also only works with amd64 and i386. The reason is simply, because debootstrap installs the packages and then runs the postinst scripts, which in turn (sometimes) run arch-specific binaries, so this only works on amd64, because its possible to execute i386 binaries on amd64. If you want to serve other architecture combinations, you need to create the nfsroot on the target architecture and then copy it to your nfsserver, which can run any OS on any cpu-archtiture :-)

FAI Configuration tuning

All of the processes described below relies on tuning the FAI configuration space. Normally, FAI configuration can be found under an unique directory /etc/fai. To make FAI work with multi architecture, you have to duplicate the configuration space for every architecture. Here is an exemple of such an FAI setup :

/etc/fai-i386
/etc/fai-amd64

To be precise, the directories don't have to be entirely duplicated, only the make-fai-nfsroot.conf file must. Links can be used for the other files or directories under the /etc/fai tree, although apt/sources.list must be a hard link or copy; a soft link will not work.

Cross-Architecture NFSROOT

Create Arch Specific FAI Configuration Direcories

These are the directories that will be used for FAI in this setup. /etc/fai is still there, since several of the files do not change, but shouldn't actually be used directly.

  for dir in /etc/fai-i386 /etc/fai-amd64
  do
	mkdir $dir
	cd $dir
	ln /etc/fai/fai.conf
	ln /etc/fai/NFSROOT
        mkdir $dir/apt
	ln /etc/fai/apt/sources.list apt/
	ln /etc/fai/menu.lst
	cp /etc/fai/make-fai-nfsroot.conf .
  done

Note that you need to either use hard links or make file copies: soft links will not work, because they'll be copied as such to the clients and have no referents.

Make Per-Arch make-fai-nfsroot.conf

Add --arch i386 or --arch amd64 to FAI_DEBOOTSTRAP_OPTS.

Set NFSROOT to /srv/fai/nfsroot-i386 or /srv/fai/nfsroot-amd64, as appropriate.

Set APT_CONFIG to /etc/fai-i386/apt_arch.conf or /etc/fai-amd64/apt_arch.conf, as appropriate.

Build The Per-Arch NFSROOT

Run:

  • fai-setup -C /etc/fai-i386 -v
  • fai-setup -C /etc/fai-amd64 -v

You can also run make-fai-nfsroot instead of fai-setup; it's potentially less thorough, but should work.

Configure Network Installation

Run (something like) one of these, depending on what kind of host you are imaging:

  • fai-chboot -k "initrd=$(ls -rt /srv/tftp/fai/initrd.img*i386* | tail -1 | sed 's;.*/;;') root=/dev/nfs nfsroot=$(host $(uname -n) | grep 'has address' | awk '{ print $4 }' | head -1):/srv/fai/nfsroot boot=live ip=dhcp FAI_FLAGS=verbose,sshd,createvt FAI_ACTION=install nfsroot=/srv/fai/nfsroot-i386" $(ls -rt /srv/tftp/fai/vmlinuz*i386* | tail -1 | sed 's;.*/;;') HOST
  • fai-chboot -k "initrd=$(ls -rt /srv/tftp/fai/initrd.img*amd64* | tail -1 | sed 's;.*/;;') root=/dev/nfs nfsroot=$(host $(uname -n) | grep 'has address' | awk '{ print $4 }' | head -1):/srv/fai/nfsroot boot=live ip=dhcp FAI_FLAGS=verbose,sshd,createvt FAI_ACTION=install nfsroot=/srv/fai/nfsroot-amd64" $(ls -rt /srv/tftp/fai/vmlinuz*amd64* | tail -1 | sed 's;.*/;;') HOST

Per-Architecture FAI Mirrors

Here's how to make fai partial Debian mirrors for both architectures.


We need to tell apt-get and frineds what's goin on, so we make a apt_arch.conf file inside /etc/fai-i386 and /etc/fai-amd64.

Simply add thoses lines to /etc/fai-i386/apt_arch.conf ( for /etc/fai-amd64/apt_arch.conf, replace i386 by amd64)

  APT {
	Architecture "i386";
  }

This relies on the NFSROOT changes described above.

for arch in i386 amd64 ; do	    
    export FAI_ETC_DIR=/etc/fai-$arch
    export APT_CONFIG=/etc/fai-$arch/apt_arch.conf
    apt-get update
    fai-mirror -v /srv/fai/mirror-$arch

    export -n APT_CONFIG
    apt-get update
done

P.S.: Have a look at the option -a of fai-mirror.