blino's website

Free software developer and more

Here comes a new draklive release, it's been a long time since the previous pre-2007.0 release. Developping Mandriva Flash required some new features, but also helped to stabilize my (precious) live creation tool.

There has been a bunch of changes, to sum up:

  • easier to create CD-Rom/USB boot images for live systems
  • easier to create 32 bits live systems from x86_64 host
  • improve writable loopbacks reliability on USB devices, by doing an early fsck check from initrd
  • support USB devices that need partition tables to be reread in initrd after a PIN code has been entered
  • improve live copy in (yet unused) live copy wizard
  • use config/live.cfg as default config file
  • allow to override settings from config/settings.cfg file using –define command line options
  • use drakx-in-chroot from the repository (instead of the locally installed one)
  • switch to wodim/genisoimage from the cdrkit project

See NEWS file for details.

The CD-Rom ejection at reboot feature was broken in live cooker snapshots, because the CDROM_LOCKDOOR ioctl wasn't defined anymore in our c perl-XS DrakX module.

It should now be fixed (and CDROMCLOSETRAY is now exported as well, which avoids hardcoding 0x5319...).

I've uploaded the initial package of draklive is our Live systems generation and copying tool.

It allows to generate Mandriva live systems, and to copy running live systems to CD or USB media (draklive --copy-wizard).


This new package will allow the copy wizard to be present on Mandriva 2007.0 beta snapsshots, that is to say, to create live systems on USB from a live CD-Rom (sure, we can do that).

USB keys are cheap now (1 GB for 25 euros), try it!

draklive now uses system's mount to mount NFS loopbacks. It used busybox's mount to do that, but our busysbox mount isn't built with NFS nolock support.

draklive now uses an optionnal config/distrib.sort file if available to sort the squashfs image. It allows to optimizes the image by ordering files according to their access order.

For now, the sort file is generated from a bootlog.list boot profile with this command: perl -MMDK::Common -e 'print map_index { (32767 - $::i) . " $_" } grep { !m,^/(?:dev|proc|sys|live/distrib), } uniq(<>)' < bootlog.list > config/distrib.sort

I've uploaded the draklive-install package, which is used to do live installations from a running live system (for example in Mandriva One).

Now, I just have to clean it a bit, so that it doesn't "borrow" (well, duplicate) code from our installer anymore.

draklive now passes langs to the installer using DRAKLIVE_LANGS environment, which is then used in the auto_install file.

Else, $o->{locale} from auto_inst will override --langs command line options (it worked in 2006.0 because the --langs support patch was applied on the fly, after the auto-install wazs read).

Next Mandriva One live systems may have some tools to make a full live system on a single USB key. The live configuration now specifies to build basic files (initrd image and some configuration) for USB live as well.

We've been testing the live USB technology for some weeks, and it looks like Mandriva behaves great on USB keys!

Since we now want to generate both Gnome and KDE live systems, we need some way to keep a common installer configuration with some desktop specific parts.

draklive now allows to specify environment variables in the config file, using $live->{system}{install_env}. These variables can then be used in the installer.

For exemple, we export a DRAKLIVE_DESKTOP variable, which is used in the file to select packages and categories according to the desktop. It is also useful to select arch specific packages or tricks.

Sometimes, we need to include additionnal modules in live systems, for example the unionfs module the kernel team forget to build, or some crappy profiling module.

draklive now alllows to include additional modules by specifying a .ko list in $live->{system}{additional_modules}.

Syscall hijacking

To trace file access and get a boot profile, I've chosen to hijack sys_open and/or sys_read system calls.

Doing it using LD_PRELOAD (like esddsp and artsdsp do) isn't enough, since it won't work for programs that don't use the libc.

I could have used LSM (Linux Security Modules) or the Linux audit subsystem, but none of them felt convenient to me.

So, I did it the hijacking way, overridding system calls.

sys_call_table symbol

Starting from kernel 2.6 serie, the sys_call_table symbol isn't exported anymore. Sebek and gnome-startup looked for it in a precise memory section, but the sys_call_table symbol isn't located anymore between the loops_per_jiffy and boot_cpu_data variables in our 2.6.16 compiled vmlinuz.

A solution is to look for sys_call_table in the whole data section (between init_mm.end_code and init_mm.end_data), see a System calls replacement article.

Logging, using debugfs

sysfs doesn't support seq_file, which basically allows to map data structures to file lines (heavily used in /proc). So, I've used debugfs to make my boot profile readable in /debug (needs to mount -t debugs none /debug).

The file list is stored in memory using the kernel doubly linked list implementation (which I was already familiar with, using it for mandi in userspace /o\), and protected using kernel mutexes.


To get a faster boot on our live systems, we need to get a boot profile (the access order to files contained in loopback). This will avoid CD drives to spin back-and-forth to get files that could have been nearer on the CD medium.

Some solutions

Readahead only (no need to regenerate the loopback)

  • sort the access filelist according to their position in the compressed loopback
  • drop this sorted filelist next to the loopback
  • add a service that readaheads the loopback-position-sorted filelist

Loopback sort (and readahead)

This method adds optimization even if readahead is disabled (preferable on low-memory systems).

  • regenerate loopback according to file access order
  • optionnally do readahead, using the access-ordered filelist

What others are doing


They use inotify in their readahead-watch profiling program, but this requires to add a watch for all existing directories, and it maybe lose early events since it isn't run at startup.

Accelerated Knoppix

Accelerated Knoppix patched the cloop module to add profiling code, which can be controlled using /proc.


echo 1 > /proc/sys/vm/block_dump

gnome-startup (my favorite approach)

Other tools

The grub/isolinux/syslinux title can now be configured using the $live->{media}{title} configuration field. It allows to build custom media more easily.

draklive now guesses the grub partition that should be used in the menu.lst file, based on the recording device name. It previously used the hardcoded (hd0,0) partition.

This is useful when writing to USB keys that must have a Windows partition as first partition.

  • apply patches and install files after the configuration is cleaned to allow special configuration files (especially modprobe.preload)

Previously, we cleaned the configuration files (fstab, mtab, modprobe.conf, modprobe.preload, iftab, shorewall interfaces, mdadm.conf) after all other post-install stuff, to remove references to the build host hardware.

But this also cleaned the new modprobe.preload file that could have been copied after the installation.

  • preselect guest user in kdm
  • install busybox in live system
  • add required settings to build live on usb media

  • preselect user in kdm only if specified
  • allow to use ext3 as well as ext2 for master images
  • run busybox from chroot to get busybox functions list, since it may not be present on build host
  • use grub for USB devices

remove hardcoded kernel (draklive can guess it)

  • use nash and busybox from cooker host
  • check for kdmrc in chroot, not build host (to have "guest" user preselected)

Mandriva live distributions are not currently speed optimized, this includes Mandriva Move, the 2006.0 live CDs, and even the latest Mandriva One.

Some other live distributions, such as Knoppix or recently Accelerated Knoppix, have efficient speed optimizations techniques.

Knoppix sorts files according to their access time in the compressed image, so that the CD drive doesn't move too much back and forth. See this discussion on Knoppix ML.

Accelerated Knoppix uses more advanced tools to optimize the block order in the compressed cloop image, using a block access profiler.

A similar effort has been made for Damn Small Linux. qemu is used to trace block access on the CD medium, and then a script is used to find the matching files. See this thread in DSL forums.

When enough memory is available, readahead is an interesting option. It makes the CD drive reads more consecutive data than it needs, to keep some in cache benifiting the drive speed. An interesting thread on Knoppix forums.

An interesting pointer about CD drive speed and cache

Other live distributions:

wait some minutes for the sync to be done when umounting USB devices (avoid corrupted transfers)

blosxom Optimised for standards.
Olivier Blin (2005)