Brian, I made a patch to reduce the size of the UYOK initrd.img, adding the --optimize-uyok to si_prepareclient. Using this option only the modules loaded in the golden client (and the mandatory modules from UYOK.modules_to_include) are included into the initrd. Moreover I added other useless modules to the UYOK.modules_to_exclude list.
I've successfully tested it with suse10 and the UYOK initrd.img has been reduced from 24MB to 5.4MB. What do you think? any suggestion? Cheers, -Andrea
Index: lib/SystemImager/UseYourOwnKernel.pm =================================================================== --- lib/SystemImager/UseYourOwnKernel.pm (revision 3581) +++ lib/SystemImager/UseYourOwnKernel.pm (working copy) @@ -29,12 +29,13 @@ # # Usage: -# SystemImager::UseYourOwnKernel->create_uyok_initrd($arch); +# SystemImager::UseYourOwnKernel->create_uyok_initrd($arch, $optimize, $all_modules, $verbose); # sub create_uyok_initrd() { my $module = shift; my $arch = shift; + my $optimize = shift; my $all_modules = shift; $verbose = shift; @@ -84,11 +85,22 @@ # # Copy modules # + my @modules = get_load_ordered_list_of_running_modules(); print ">>> Copying modules to new initrd from: /lib/modules/$uname_r...\n" if( $verbose ); mkdir("$staging_dir/lib/modules", 0755) or die "$!"; - $cmd = qq(rsync -a --exclude=build --exclude=source $modules_to_exclude /lib/modules/$uname_r $staging_dir/lib/modules/); - !system( $cmd ) or die( "Couldn't $cmd." ); - + unless ($optimize) { + $cmd = qq(rsync -a --exclude=build --exclude=source $modules_to_exclude /lib/modules/$uname_r $staging_dir/lib/modules/); + !system( $cmd ) or die( "Couldn't $cmd." ); + } else { + # Copy only loaded modules ignoring exclusions. + foreach my $module ( @modules ) { + $cmd = qq(rsync -aR $module $staging_dir); + !system( $cmd ) or die( "Couldn't $cmd." ); + } + # Copy module configuration files. + $cmd = qq(rsync -R /lib/modules/$uname_r/* $staging_dir); + !system( $cmd ) or die( "Couldn't $cmd." ); + } # # add modules and insmod commands # @@ -97,7 +109,6 @@ open( FILE,">>$file" ) or die( "Couldn't open $file for appending" ); print ">>> Appending insmod commands to ./my_modules_dir/INSMOD_COMMANDS...\n" if( $verbose ); - my @modules = get_load_ordered_list_of_running_modules(); foreach my $module ( @modules ) { print " >> insmod $module\n" if( $verbose ); print FILE "insmod $module\n"; Index: sbin/si_prepareclient =================================================================== --- sbin/si_prepareclient (revision 3581) +++ sbin/si_prepareclient (working copy) @@ -160,6 +160,11 @@ is advantageous if you know you don't need a UYOK kernel, and you want this command to complete faster. + --optimize-uyok + Optimize UYOK (Use Your Own Kernel) initrd.img for size including + only the kernel modules loaded in the golden client and the modules + in /etc/systemimager/UYOK.modules_to_include. + --all-modules Include every single module under /lib/modules/`uname -r`/ when creating the UYOK (Use Your Own Kernel) initrd.img. @@ -183,6 +188,7 @@ "quiet" => \my $quiet, "rpm|rpm-install" => \my $rpm, "no-uyok" => \my $no_uyok, + "optimize-uyok" => \my $optimize_uyok, "all-modules" => \my $all_modules, "version" => \my $version, "server=s" => \my $server, @@ -209,6 +215,24 @@ exit 1; } +if($no_uyok and $optimize_uyok) { + print "FATAL: --no_uyok option conflicts with --optimize_uyok!\n"; + print qq(Try "$progname --help" for more info.\n); + exit 1; +} + +if($no_uyok and $all_modules) { + print "FATAL: --no_uyok option conflicts with --all_modules!\n"; + print qq(Try "$progname --help" for more info.\n); + exit 1; +} + +if($optimize_uyok and $all_modules) { + print "FATAL: --optimize_uyok option conflicts with --all_modules!\n"; + print qq(Try "$progname --help" for more info.\n); + exit 1; +} + # Make sure we have certain tools that we need. which('rsync') or croak("'rsync' is required for $progname to function properly. Please see http://systemimager.org for more details."); which('systemconfigurator') or croak("'systemconfigurator' is required for $progname to function properly. Please see http://systemimager.org for more details."); @@ -651,7 +675,7 @@ my $arch = get_arch(); my $verbose; unless($quiet) { $verbose = 1; } - SystemImager::UseYourOwnKernel->create_uyok_initrd( $arch, $all_modules, $verbose ); + SystemImager::UseYourOwnKernel->create_uyok_initrd( $arch, $optimize_uyok, $all_modules, $verbose ); } SystemImager::Common->write_auto_install_script_conf_footer($file); Index: etc/UYOK.modules_to_exclude =================================================================== --- etc/UYOK.modules_to_exclude (revision 3581) +++ etc/UYOK.modules_to_exclude (working copy) @@ -21,8 +21,11 @@ kernel/sound/* kernel/drivers/video/* kernel/drivers/parport/* +kernel/net/ipv4/netfilter/* +kernel/net/ipv6/netfilter/* +kernel/drivers/input/joystick/* +kernel/drivers/media/* - # # Locally customized exclusions go here: #