HowTo Build Images: step by step process

From ComputeMode
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
[[Category:User doc]]
 
[[Category:User doc]]
 
[[Category:Status Draft]]
 
[[Category:Status Draft]]
[[Category:Version 2.1.5]]
+
[[Category:Version 2.1.6]]
   
 
This page describes the steps to build your own images to boot on with an example: the Debian Squeeze 32 or 64bits system.
 
This page describes the steps to build your own images to boot on with an example: the Debian Squeeze 32 or 64bits system.
Line 68: Line 68:
 
cd /tmp && wget http://downloads.sourceforge.net/project/modules/Modules/modules-3.2.8/modules-3.2.8a.tar.gz && tar zxvf modules-3.2.8a.tar.gz
 
cd /tmp && wget http://downloads.sourceforge.net/project/modules/Modules/modules-3.2.8/modules-3.2.8a.tar.gz && tar zxvf modules-3.2.8a.tar.gz
 
cd /tmp/modules-3.2.8 && ./configure && make && make install && rm -Rf /tmp/modules*
 
cd /tmp/modules-3.2.8 && ./configure && make && make install && rm -Rf /tmp/modules*
  +
apt-file update
 
EOF
 
EOF
   
Line 98: Line 99:
 
tcl8.4-dev
 
tcl8.4-dev
 
tcllib
 
tcllib
  +
apt-file
 
EOF
 
EOF
   
Line 164: Line 166:
 
# dpkg-reconfigure locales
 
# dpkg-reconfigure locales
 
# dpkg-reconfigure tzdata
 
# dpkg-reconfigure tzdata
# touch /etc/resolv.conf
+
# rm /etc/resolv.conf && touch /etc/resolv.conf
 
# exit
 
# exit
 
# chroot /cm/debian/orig bash -c 'mknod -m 660 /dev/watchdog c 10 130'
 
# chroot /cm/debian/orig bash -c 'mknod -m 660 /dev/watchdog c 10 130'
Line 170: Line 172:
 
# rm -Rf /cm/debian/orig/dev/.udev
 
# rm -Rf /cm/debian/orig/dev/.udev
 
# chroot /cm/debian/orig bash -c 'if [ ! -c /dev/rtc0 ]; then mknod /dev/rtc0 c 254 0 && ln -s rtc0 /dev/rtc; fi'
 
# chroot /cm/debian/orig bash -c 'if [ ! -c /dev/rtc0 ]; then mknod /dev/rtc0 c 254 0 && ln -s rtc0 /dev/rtc; fi'
  +
# chroot /cm/debian/orig bash -c 'wget -q http://oar-ftp.imag.fr/oar/oarmaster.asc -O- | sudo apt-key add - && apt-get update && updatedb"
   
   

Revision as of 13:17, 14 December 2011


This page describes the steps to build your own images to boot on with an example: the Debian Squeeze 32 or 64bits system.

Note.png Note

HowTo Build Images: using kameleon are also available for a quick setup of ComputeMode node

Contents

The environment

  • Create your work environment: (in your computemode server, images are usually stored into the /cm directory)

A computemode image contains:

  • an "orig" directory with a basic operating system (this one will be created later)
  • a "patch" directory with files to update the basic operating systems
  • a "purge" file and a "rules" file, describing how to update the basic operating system (copy, link...)
  • we will use the "build-image" directory to build the new system
# mkdir -p /cm/build-image
# cd /cm/build-image


The orig file system

  • First you have to install the Debian Live packages:
# echo "deb http://live.debian.net/ squeeze-snapshots main contrib non-free" >> /etc/apt/sources.list
# wget http://live.debian.net/debian/project/keys/archive-key.asc -O - | apt-key add -
# apt-get update
# apt-get install live-build  live-helper  live-manual live-config
# apt-get install schroot
# lb config --distribution squeeze -a amd64 -b net --apt-options "--force-yes --yes" --debconf-frontend dialog --chroot-filesystem plain

For a 32bit mode system:

# lb config --distribution squeeze -a i386 -b net --apt-options "--force-yes --yes" --debconf-frontend dialog --chroot-filesystem plain

The "lb config" command makes the basic directories, you can, after that, create your new image. We will use the "config" directory and hooks scripts to manage the build of the new system. Some explanations about the lb config options:

  • --distribution: choose your distribution between unstable, sid and squeeze
  • -a: for the architecture
  • -b: to choose what kind of boot we want to use
  • --apt-options: some options for apt
  • --debconf-frontend: to use (or not) the dialog box from apt
  • --chroot-filesystem: to choose what kind of filesystem to build


  • Then you have to configure your new environement:

The "config/chroot_sources" is used to configure the apt repositories for the new system. To configure additional repositories, create config/chroot_sources/your-repository.chroot

# cat <<EOF > ./config/chroot_sources/oar.chroot
deb http://oar-ftp.imag.fr/oar/2.4/debian/ squeeze main
EOF


For the povray's demos:

# cat <<EOF > ./config/chroot_sources/povray.chroot
deb http://ftp.fr.debian.org/debian/ stable main non-free contrib
EOF


The "config/chroot_local-hooks" directory is used to run commands in the chroot stage:

# cat <<EOF> ./config/chroot_local-hooks/post-build.sh 
#!/bin/sh
echo "Launching some chrooted commands"
updatedb
echo "Installing Modules environment manager software"
cd /tmp && wget http://downloads.sourceforge.net/project/modules/Modules/modules-3.2.8/modules-3.2.8a.tar.gz && tar zxvf modules-3.2.8a.tar.gz
cd /tmp/modules-3.2.8 && ./configure && make && make install && rm -Rf /tmp/modules*
apt-file update
EOF


The "config/chroot_local-packageslists" is used to configure what packages have to be installed into the new system:

# cat <<EOF> ./config/chroot_local-packageslists/packages.list
## This file is describing what packages we want to install iin addition of the standard flavour
# For a computemode node:
openssh-server 
less
mingetty 
nis 
nfs-common 
acpid 
mlocate 
bind9 
dnsutils 
bind9-doc 
resolvconf
hwloc
ntpdate
# For running demos:
imagemagick
gfortran
g++
povray 
povray-examples
ttf-mscorefonts-installer
tcl8.4
tcl8.4-dev
tcllib
apt-file
EOF


  • To build the new system just type:
# lb build

A new image is created in binary/live/filesystem.dir (you can change the filesystem type, see man lb_config). To finish the installation you just have to copy this directory into the exported /cm place.

# mkdir /cm/debian
# cp -R binary/live/filesystem.dir /cm/debian/orig


  • If you want to customize your image, just take a look on the man page of lb config:
# man lb_config

or the online documentation:

# http://live.debian.net/manual/en/html/live-manual.html

The patch and utils directories

Now you have a basic operating system, now you have to configure the "patch" directory to have this system working in computemode. You have an example of the "patch" directory from computemode server:

# cd /cm/debian/
# wget http://computemode.imag.fr/files/debian/squeeze/images/rootfs/patch-squeeze.tar.gz
# tar zxvf ./patch-squeeze.tar.gz
# chown -R root:root ./patch
# rm patch-squeeze.tar.gz
# wget http://computemode.imag.fr/files/debian/squeeze/images/rootfs/utils.tar.gz 
# tar zxvf ./utils.tar.gz |xargs chown root:root
# rm utils.tar.gz

The purge and rules files

You can find an example of those files linked to the orig and patch installation done before:

# cd /cm/debian/
# wget http://computemode.imag.fr/files/debian/squeeze/images/rootfs/purge
# wget http://computemode.imag.fr/files/debian/squeeze/images/rootfs/rules


Finishing the installation

The schroot command is used to install some packages and to manage automatically /proc mounts:

# cat <<EOF > /etc/schroot/chroot.d/squeeze
[squeeze]
description=squeeze
root-groups=root
root-users=root
type=directory
directory=/cm/debian/orig
EOF

You can now customize you new system and finishing the installation:

# cp /etc/resolv.conf /cm/debian/orig/etc/resolv.conf
# schroot -c squeeze -d /root
# chown -R man:root /var/cache/man
# apt-get install --reinstall openssh-server
# apt-get install --reinstall oar-node 
# apt-get install --reinstall watchdog
# rm -Rf /var/spool/cron/* && mkdir /var/spool/cron/atjobs && mkdir /var/spool/cron/atspool && mkdir /var/spool/cron/crontabs
# echo "0" > /var/spool/cron/atjobs/.SEQ
# chown -R daemon:daemon /var/spool/cron/atjobs /var/spool/cron/atspool && chown root:crontab /var/spool/cron/crontabs
# passwd
# ssh-keygen -t rsa
# cat /root/.ssh/id_rsa.pub > /root/.ssh/authorized_keys
# dpkg-reconfigure locales
# dpkg-reconfigure tzdata
# rm /etc/resolv.conf && touch /etc/resolv.conf
# exit
# chroot /cm/debian/orig bash -c 'mknod -m 660 /dev/watchdog c 10 130'
# chroot /cm/debian/orig bash -c 'chmod 666 /dev/null'
# rm -Rf /cm/debian/orig/dev/.udev
# chroot /cm/debian/orig bash -c 'if [ ! -c /dev/rtc0 ]; then mknod /dev/rtc0 c 254 0 && ln -s rtc0 /dev/rtc; fi'
# chroot /cm/debian/orig bash -c 'wget -q http://oar-ftp.imag.fr/oar/oarmaster.asc -O- | sudo apt-key add - && apt-get update && updatedb"


To finish to configure OAR, you have to add the SSH key from your OAR server:

# cp -R /var/lib/oar/.ssh /cm/debian/patch/var/lib/oar/

To fix OAR and Bind rights:

# chown -R 105:108 /cm/debian/patch/var/lib/oar
# chown 107:110 /cm/debian/orig/etc/bind/rndc.key

Just change the userid (105 and 107) and groupid (108 and 110) with your own informations from your chrooted environment (for the OAR and BIND users id and groups id in the /cm/debian environement).

  • Copy needed files:
# cat /root/.ssh/id_rsa.pub >> /cm/debian/orig/root/.ssh/authorized_keys
# cp /cm/debian/orig/etc/ssh/ssh_host_* /cm/debian/patch/etc/ssh/

Note: you should have the same ssh_host* key files for all your nodes.

Check if the environment="OAR_KEY=1" variable is set into the /cm/debian/patch/var/lib/oar/.ssh/authorized_keys file, if it is not the case, just run the following command:

# sed -i 's/.*/environment="OAR_KEY=1" &/g' /cm/debian/patch/var/lib/oar/.ssh/authorized_keys


  • To authorize povray to write results you have to edit the povray.conf file on your image:
# vi /cm/debian/orig/etc/povray/3.6/povray.conf

and change the section:

[File I/O Security]
restricted

to:

[File I/O Security]
none

The tftpboot initrd and kernel

We will use the tftpboot directory generated by the previous debian-live build.

# cd /cm/build-image/tftpboot/debian-live/amd64

or :

# cd /cm/build-image/tftpboot/debian-live/i386

In this directory you will find a kernel and a initrd. You don't have to build a new kernel you can reuse the one in the tftpboot directory:

# cp vmlinuz-2.6.32-5-amd64 /var/www/bootdirectory/images/debkaufs

or:

# cp vmlinuz-2.6.32-5-686 /var/www/bootdirectory/images/debkaufs


The initrd need some cutomizations to work in computemode system:

# mkdir custom-initrd
# cd custom-initrd
# gzip -dc  ../initrd.img-2.6.32-5-amd64 | cpio -id
# wget http://computemode.imag.fr/files/debian/squeeze/images/initrd/custom-initrd-squeeze-amd64.tar.gz
# tar zxvf custom-initrd-squeeze-amd64.tar.gz -C ./
# rm custom-initrd-squeeze-amd64.tar.gz
# find ./ | cpio -H newc -o |gzip > /var/www/bootdirectory/images/debiaufs

or for the 32bit mode system:

# mkdir custom-initrd
# cd custom-initrd
# gzip -dc  ../initrd.img-2.6.32-5-686 | cpio -id
# wget http://computemode.imag.fr/files/debian/squeeze/images/initrd/custom-initrd-squeeze-i386.tar.gz 
# tar zxvf custom-initrd-squeeze-i386.tar.gz -C ./
# rm custom-initrd-squeeze-i386.tar.gz
# find ./ | cpio -H newc -o |gzip > /var/www/bootdirectory/images/debiaufs


You just have to configure the computemode web interface with the new initrd debiaufs and the new kernel debkaufs.

Personal tools
Namespaces

Variants
Actions
user portal
developer portal
wiki stuff
Tools