Development/Howto/Stage One Install

From Mandriva

Jump to: navigation, search
Stage 1 HOWTO

Stage1 is the program that will load second-stage install

Contents


[edit]

Features

[edit]

CD-ROM install

[edit]

Network install (ftp, http, nfs)

The installer now displays a mirror list in ftp install.

It is fetched from http://www.mandrivalinux.com/mirrorsfull.list

It allows the user to choose the medium and the host, then it automatically finds the right path on the mirror.

[edit]

Disk install (from mirror tree or ISO images)

Mandriva Linux can be installed from a mirror tree or ISO images on disk. Supported partition types are ext2, vfat, ntfs and reiserfs.

The disk install can now use multiple ISO images.

Instead of specifying the whole path of the ISO image, you now only need to specify the directory where the ISO images are located. If this directory contains ISO images with a stage2 installer (typically the first CD of a CD set), the installer lets you choose one of those suitable images.

Then it launches the stage2 installer from this ISO image, and the stage2 installer will automatically use other ISO images in this directory (relying on volume names of ISO images).

[edit]

Getting stage1

stage1 can be downloaded from CVS : http://cvs.mandriva.com/cgi-bin/cvsweb.cgi/gi/mdk-stage1/

This page will assume the gi CVS tree is directly fetched in the home directory.

% cd ~
% export CVS_RSH=ssh
% export CVSROOT=:ext:[email protected]:/cooker
% cvs checkout gi/mdk-stage1

password is cvs

[edit]

Debugging and testing the stage1 installer on a test machine with grub and tftp

[edit]

Building stage1 initrd

First, grab the whole gi CVS tree and prepare a kernel.

% cd ~
% cvs checkout gi/
% cd ~/gi/kernel/
% ./update_kernel /RPMS/kernel-BOOT-2.6.7.0.rc2.1mdk-1-1mdk.i586.rpm

Then make sure the stage1 isn't in testing mode ( MODE_TESTING shouldn't be set) and build it.

% cd ~/gi/mdk-stage1
% make

Finally, build the initrd containing modules and binaries.

% cd ~/gi
% DEBUGSTAGE1=yes ./make_boot_img all.rdz

all.rdz-2.6.7-0.rc2.1mdkBOOT is now built in ~/gi

[edit]

Setting a tftp server on the workstation

First, make the initrd and vmlinuz binary available in the tftp server root.

% sudo urpmi tftp-server
% sudo cp -f ~/gi/kernel/all.kernels/2.6.7-0.rc2.1mdkBOOT/boot/vmlinuz-2.6.7-0.rc2.1mdkBOOT /var/lib/tftpboot/vmlinuz
% sudo cp -f ~/gi/all.rdz-2.6.7-0.rc2.1mdkBOOT /var/lib/tftpboot/all.rdz

Then write a grub menu that will allow a choice between multiple install methods, using vmlinuz and all.rdz from the tftp server. This grub menu will be put in /var/lib/tftpboot/menu.lst

% sudo emacs /var/lib/tftpboot/menu.lst

In this file, (nd)' represents the tftp server root.

Here's a sample file with multiple config and some automatic settings :

timeout 10
default 0

title all
dhcp
tftpserver 192.168.100.42
kernel (nd)/vmlinuz ramdisk=32000 vga=788 kickstart=Mandrake/base/auto_inst.cfg.pl useless_thing_accepted automatic=method:disk,\
network:static,ip:192.168.100.119,dns:192.168.100.11,gateway:192.168.100.1
initrd (nd)/all.rdz

title nfs
dhcp
tftpserver 192.168.100.42
kernel (nd)/vmlinuz ramdisk=32000 vga=788 kickstart=Mandrake/base/auto_inst.cfg.pl useless_thing_accepted automatic=method:nfs,\
network:static,ip:192.168.100.119,dns:192.168.100.11,gateway:192.168.100.1,server:192.168.100.42,directory:/export,user:a,pass:a
initrd (nd)/all.rdz

title ftp
dhcp
tftpserver 192.168.100.42
kernel (nd)/vmlinuz ramdisk=32000 vga=788 kickstart=Mandrake/base/auto_inst.cfg.pl useless_thing_accepted automatic=method:ftp,\
network:static,ip:192.168.100.119,dns:192.168.100.11,gateway:192.168.100.1,server:192.168.100.42,directory:/export,user:a,pass:a
initrd (nd)/all.rdz

title rescue
dhcp
tftpserver 192.168.100.42
kernel (nd)/vmlinuz rescue rw root=/dev/ram3 ramdisk=32000 vga=788 kickstart=Mandrake/base/auto_inst.cfg.pl useless_thing_accepted automatic=method:nfs,\
network:static,ip:192.168.100.119,dns:192.168.100.11,gateway:192.168.100.1,server:192.168.100.42,directory:/export,user:a,pass:a
initrd (nd)/all.rdz
[edit]

Writing a grub boot disk to boot on the tftp server

Now that the tftp server is ready and offers vmlinuz, all.rdz and menu.lst files, a boot disk has to be written to start the stage1 installer on the test machine.

This boot disk will use grub to fetch the files from the tftp server. Some grub boot utilities can be found in ~/gi/tools/i386/netboot/

% cd ~/gi/tools/i386/netboot/

A grub file has to be written so that the boot disk uses the tftp server previously set up. This menu.lst file will actually do nothing but reload the menu.lst file from the tftp server.

% emacs menu.lst

Here's a sample menu.lst file :

timeout 0
default 0

title loadmenu
dhcp
tftpserver 192.168.100.42
configfile (nd)/menu.lst

The grub boot disk is actually network card specific. In this ~/gi/tools/i386/netboot/ directory, there are grub binaries for various network cards in sub-directories.

Insert a floppy in your floppy drive and make a boot disk suited for the network card of your test machine (in this case, the driver for the network card of the test machine is in the 3c90x sub-directory).

% ./make_boot_network 3c90x

The grub boot disk is now ready.

[edit]

Booting the test machine

Insert the grub boot disk in the floppy drive of the test machine and boot on it. grub will read the menu.lst file on this boot disk and then switch to the menu.lst file on the tftp server to give the choice between boot entries defined in the /var/lib/tftpboot/menu.lst file of your tftp server.

[edit]

Debugging and testing the stage1 installer on a workstation

[edit]

Running stage1 on the workstation

First, the stage1 needs to be in testing mode. A good way to do this for now is to add set_param(MODE_TESTING) at the beginning of the main() function in ~/gi/mdk-stage1/stage1.c

% cd ~/gi/mdk-stage1
% make
% sudo ./stage1-full
[edit]

Current ways to debug and test stage1

  • global variable testing in init; if set, disables :
    • screen blanking
    • /proc mount
    • /dev/console open
    • hostname setting
    • klog open
    • unmount and reboot at end
  • DEBUG macro in init
    • if set, print a message and sleep(10), that's all folks ...
  • name of the installer
    • if the stage1 is named debugstage1, set MODE_DEBUGSTAGE1
  • MODE_DEBUGSTAGE1 and IS_DEBUGSTAGE1 macros
    • if set, hangs with a while(1) in do_pivot_root(), called from finish_preparing(), probably to prevent stage2 from being launched
  • MODE_TESTING and IS_TESTING macros, if set:
    • log in debug.log instead of SLASH_LOCATION /tmp/stage1.log
    • do not spawn shell
    • do not spawn interactive
    • do not load modules
    • do not configure network interfaces and routes
    • stage1 returns 0 instead of 66
  • SPAWN_SHELL macro
    • defined in Makefile
    • if set, try to launch a shell
  • SPAWN_INTERACTIVE macro
    • not defined
    • if set, try to spawn interactive
  • DEBUGSTAGE1 environment variable in gi/make_boot_img
    • if set, add a shell in image
[edit]

How to actually launch stage1 in debug/testing mode

MODE_TESTING

[edit]

Possible evolutions

  • drop DEBUG macro since the reboot code is debugged
  • drop name of the installer (debugstage1) check
  • merge MODE_DEBUGSTAGE1 macro with MODE_TESTING macro
  • set testing variable in init and MODE_TESTING in stage1 if the DEBUGSTAGE1 environment variable is set
  • run install2 in test mode if MODE_TESTING is set
  • add a compile option to include debug symbols
  • use another command line than /proc/cmdline if MODE_TESTING is set
[edit]

Problems

  • two ways to pass the stage2 method ( --method option or METHOD environment variable)
  • no way in stage2 to distinguish between disk install from mirror tree or from ISO images
Personal tools