Mandriva Installer Tips and Tricks

From Mandriva Community Wiki

Jump to: navigation, search


Contents


Basic architecture of the installer

The installer is divided in two parts: stage 1 (StageOne), written in C, to initialize the system, and stage 2, written in perl, exposed here.

The stage2 is provided in a squashfs image containing various files listed here. The result is install/stage2/mdkinst.sqfs, built by drakx-installer-stage2 src.rpm.

Keyboard shortcuts

In the Mandriva Installer GUI, you can use the following keyboard shortcuts:

  • F2: make a screenshot to place in /root/DrakX-screenshots after installation
  • Ctrl-Alt-Home: go back to the first step of install. It is used to debug the "language selection" step, and must not be used for other purpose (especially, it will fail horribly if some partitions have been mounted).

Useful info

You can find the original documentation of AutoInstall here.

Or as one large raw HTML file (tarred): Media:auto_inst.tar.bz2

From DrakX README:

Making screenshots through network

On a test machine, make a network install, switch to console (ctrl-alt-F2), enter:

% xhost+

then, on another computer:

% DISPLAY=test_machine:0 xwd -root | convert - screenshot.png

Virtual consoles

During install, a lot of interesting stuff can be found in different places: in consoles and in files. To switch to console 2 for example, do Ctrl-Alt-F2 from the X install.

  • alt-F1: the stdout of the install. Not very interesting stuff
  • alt-F2: simple shell. Quite a lot of commands are available but as they are written in perl (for space), they do not handle the very same options as normally. After install, you can do chroot /mnt to see your system just like after rebooting. rpm -qa works for example.
  • alt-F3: a lot of interesting things. Be careful, some ERROR messages are not interesting.
  • alt-F4: kernel's place, i.e. the output of dmesg.
  • alt-F7: the graphical install lives there

Log files

  • /tmp/ddebug.log: same (or nearly the same) as alt-F3
  • /tmp/syslog: same as alt-F4
  • /mnt/root/ddebug.log: at the end of each step, DrakX tries to backup /tmp/ddebug.log to /mnt/root. Available only after mounting of /mnt.
  • /mnt/root/install.log: the log of the installation (or upgrade) of the rpms
  • /mnt/root/auto_inst.cfg.pl: a kickstart file generated at the end of each step. Can be used in 2 ways: kickstart install or defcfg install. Hopefully you know about kickstart. defcfg is a way to customize the default values in install. For example, French can be the default language with a qwerty keyboard, the auto-partitioning of partitions can be changed...

Command bug puts on usb key (or floppy) a lot of interesting stuff, including files above

Passing options to the installer

Various options

Drakx can use various options to change its behaviour (this list not complete, most of the code is in install2.pm):

  • flang, lang: change the translation of the installer. flang will skip the question.
  • patch, defcfg: used to patch the installer in live mode (see next chapter).
  • display, askdisplay: export the installation on another X11

How to pass an option

The installer will take the options from the kernel command-line (/proc/cmdline), so either add it in isolinux.cfg or add it dynamically in gfxboot (ask for "Kernel Options" to display kernel command-line)

Special mode of installation

Using brltty

By passing the brltty parameter to the kernel you will activate the brltty software, allowing to install Mandriva Linux with a Braille display.

Using a serial cable for the installation

The installer should be able to use a serial link, as it is something standard on linux. All you have to do is to pass options to the kernel:

  • console=ttyS0,1152008n
  • text
  • vga=text

And use minicom to do the installation. But this is untested by the author of this document. You can see the documentation of the kernel for the syntax of the console option.

Exporting the X11 display

You can run the graphical installation on another display. Either pass the option display=ip:0, or use askdisplay. You may need to lower the security ( using xhost + ) to make this work.

Debugging the stage2

write a test program

Many functions of the installer are used in standalone tools, so in some cases, you can simply run the associated configuration program (bootloader-config, XFdrake...).

Many other functions can be called from a small test program. Eg:

#!/usr/bin/perl

use lib qw(/usr/lib/libDrakX);

use standalone;     #- warning, standalone must be loaded very first, for 'explanations'

use common;
use interactive;
use security::level;
use any;

my $users = [ map { { name => $_, realname => $_ } } grep { ! /^-/ } @ARGV ]; 
my $in = 'interactive'->vnew('su');
any::ask_user_and_root($in, { password => "tot"}, $users, security::level::get(), needauser => 1);

(to be run in the perl-install/ directory)

When you have such a reproducer, it's easy to debug, using a combination of perl -d:Trace, perl -d...

Still, the behaviour can be somewhat different.

drakx-in-chroot

drakx-in-chroot is a special way to run the stage2 on a live system. Some steps are skipped completly (partitioning, formatting, bootloader). This means you can't debug those steps. Also note that the code used is sometimes a little different. Still, drakx-in-chroot is quite useful to reproduce some issues, especially since starting the stage2 that way is very fast, no need to reboot a test box.

You can find drakx-in-chroot in package drakx-installer-stage2. For example you can run as root:

/usr/lib/drakx-installer-stage2/misc/drakx-in-chroot /mnt/xxx/devel/cooker/i586 /tmp/foo

It will display the installer in a window using Xephyr or Xnest.

modifying the stage2

The following implies you have a /export directory containing /export/install/stage2/mdkinst.sqfs.

You can easily adapt to another directory by modifying variable ROOTDEST in drakx/trunk/perl-install/install/Makefile.

modifying the stage2

To uncompress the stage2, use mdkinst_stage2_tool:

% cd /export
% misc/mdkinst_stage2_tool --uncompress install/stage2 
Creating install/stage2/live from install/stage2/mdkinst.sqfs

You can then modify files in /export/install/stage2/live/.

Note that this command leaves /export/install/stage2/mdkinst.sqfs unmodified. live/ will be preferred to mdkinst.sqfs for nfs,cdrom,hd,drakx-in-chroot installs. But if you need to do http or ftp installs, you can't use live/ so must do misc/mdkinst_stage2_tool --compress install/stage2 after modifying live/.

testing a modification on a perl module

If you want to test a modification on a .pm file in drakx/trunk/perl-install/, do:

cd perl-install/install
make install_pms

It's quite cheap, and allow cheap tests combined with drakx-in-chroot.

Note that this command leaves /export/install/stage2/mdkinst.sqfs unmodified but creates /export/install/stage2/live/ which can be modified by hand. But if you need to do http or ftp installs, you can't use live/ so must also do make install_pms compress instead of simply make install_pms.

building the stage2 from scratch

cd perl-install/install
make stage2
# or
DEBUG_INSTALL=1 make stage2

will build install/stage2/live/ from scratch. To directly build install/stage2/mdkinst.sqfs, use make stage2 compress.

With DEBUG_INSTALL=1, it will add interesting binaries to the stage2: gcc, strace, top...

Note that you must first install all the needed packages. You can do this with urpmi cooker/SRPMS/main/release/drakx-installer-*.src.rpm.

debug the stage2 when it crashes early

When the stage2 crashes, the init process prepares for reboot doing:

sending termination signals...done
sending kill signals...done

One way to debug those issues is:

cd perl-install/install
make dont_run_directly_stage2

The stage2 won't be run directly, and you will get a shell. You can then run install2 which starts the stage2. If the stage2 crashes, the shell should still be available to run stage2 once again. This is especially useful for nfs installs where /export/install/stage2/live/ can be modified, then install2 can be called again.

Customisation of the install by patching it

Drakx can be fully customised without recompilation or modification of the code, by using a perl script run in the context of the installer used to change variables or functions. This approach has many advantages over a real patch:

  • this requires no modification of the source code, so the file can be changed and the patch still be valid.
  • you have access to all the power of perl and the library used by install, allowing to add questions, and test them without running a full install
  • it can be added on an iso very quickly, or on a network installation without changing anything in the layout

Examples: patches fixing bugs on mdv 2008.0 installer.

One typical use is to remove a step of the installer:

package install::install2;
undef *selectLanguage;
*selectLanguage = sub { 1 };

You can also use it to set some default variables. In fact, the auto_inst file is using the same mechanism.

The easiest way to use this is to place a file install/patch-oem.pl on the CD. This file will be read if it exists. You can also place a file named as you want, and use option defcfg=filename, to load this patch.

If you need to add some backgrounds, or change some files, you can also place an rpm in the file install/oem-theme.rpm, it will be installed with the command rpm -U (code in file installs_step.pm )

Testing the patch without burning a cd

Stage 2 of the installer can be run on a live system. First, you need to get a Mandriva Linux tree, the same you can find on cd or ftp mirror. You can use mount -o bind to not copy the whole tree on your disk:

mount /mnt/cdrom/
cp -R /mnt/cdrom/install/ ~/install
sudo mount -o bind ~/install /mnt/cdrom/install/
emacs ~/install/patch-oem.pl

You can then run drakx-in-chroot from package drakx-installer-stage2 as root:

/usr/lib/drakx-installer-stage2/misc/drakx-in-chroot /mnt/cdrom /tmp/foo

It will display the installer in a window using Xephyr or Xnest.

Personal tools
In other languages
Looking for a job?