From 4acf4acdfb7dbc8d87c5ef0c980b0577dd934e43 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Tue, 10 Apr 2012 20:30:53 +0000 Subject: installer: allow generation of host-only initrd during install During install dracut will generate a generic (i.e. large) initrd. As we now start udev early, we can use udev metadata when generating our initrd and thus we can generate our default, hostonly initrd. Thus ensure relevant directories (/run) are bind mounted and fake a /run/initramfs folder which is used in dracut to detect a boot which will have sufficient metadata in the udev DB. Tested with an install on a new disk and creating LVMs and also on an install where the pre-existing LVMs were reused. Suitable fixes to drakx-in-chroot have also been added, but remain untested --- perl-install/NEWS | 1 + perl-install/install/install2.pm | 9 +++++++-- perl-install/install/steps.pm | 6 ++++++ tools/drakx-in-chroot | 18 ++++++++++++++++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/perl-install/NEWS b/perl-install/NEWS index a03cd4eee..24f9feb88 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -1,5 +1,6 @@ - interactive::curses: o make sure ranges are always within limits (mga#646) +- allow generation of host-only initrd during install Version 14.3 - 7 April 2012 diff --git a/perl-install/install/install2.pm b/perl-install/install/install2.pm index 03f617154..44d9bf916 100644 --- a/perl-install/install/install2.pm +++ b/perl-install/install/install2.pm @@ -291,8 +291,11 @@ sub start_udev() { # Ensure /run is mounted mkdir("/run", 0755); run_program::run("mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run"); - mkdir_p("/run/udev/rules.d"); - $ENV{UDEVRULESD} = "/run/udev/rules.d"; + + # Fake dracut boot (due to checks employed when running dracut during install) + # as we know that we'll have the needed metadata in udevadm db due to us + # starting udev nice and early here. + mkdir_p("/run/initramfs"); # Start up udev and trigger cold plugs run_program::run("mount", "-t", "devtmpfs", "-o", "mode=0755,nosuid", "devtmpfs", "/dev"); @@ -300,6 +303,8 @@ sub start_udev() { run_program::run("mount", "-t", "devpts", "-o", "gid=5,mode=620,noexec,nosuid", "devpts", "/dev/pts"); run_program::run("mount", "-t", "tmpfs", "-o", "mode=1777,nosuid,nodev", "tmpfs", "/dev/shm"); + mkdir_p("/run/udev/rules.d"); + $ENV{UDEVRULESD} = "/run/udev/rules.d"; run_program::run("/lib/udev/udevd", "--daemon", "--resolve-names=never"); run_program::run("udevadm", "trigger", "--type=subsystems", "--action=add"); run_program::run("udevadm", "trigger", "--type=devices", "--action=add"); diff --git a/perl-install/install/steps.pm b/perl-install/install/steps.pm index 53e87f0c3..85de324cb 100644 --- a/perl-install/install/steps.pm +++ b/perl-install/install/steps.pm @@ -377,6 +377,12 @@ sub beforeInstallPackages { run_program::run('mount', '--bind', '/tmp/.X11-unix', "$::prefix/tmp/.X11-unix"); } + if (-e '/run') { + mkdir "$::prefix/run"; + run_program::run('mount', '--bind', '/run', "$::prefix/run"); + } + + log::l("setting excludedocs to $o->{excludedocs}"); substInFile { s/%_excludedocs.*//; $_ .= "%_excludedocs yes\n" if eof && $o->{excludedocs} } "$::prefix/etc/rpm/macros"; diff --git a/tools/drakx-in-chroot b/tools/drakx-in-chroot index 380e4b47d..42ebedb71 100755 --- a/tools/drakx-in-chroot +++ b/tools/drakx-in-chroot @@ -58,7 +58,7 @@ if (-d $SLASH_LOCATION) { rm_rf($SLASH_LOCATION); } -mkdir_p("$SLASH_LOCATION$_") foreach '/dev', '/dev/usb', '/etc', '/var', '/proc', '/sys', $STAGE2_LOCATION_ROOTED, $MEDIA_LOCATION_ROOTED, $prefix_ROOTED; +mkdir_p("$SLASH_LOCATION$_") foreach '/dev', '/dev/usb', '/etc', '/var', '/proc', '/sys', '/run', $STAGE2_LOCATION_ROOTED, $MEDIA_LOCATION_ROOTED, $prefix_ROOTED; sys("$sudo rm -rf $dir") if $ENV{CLEAN}; -e $dir or sys("$sudo mkdir -p $dir"); @@ -82,6 +82,20 @@ sys("$sudo mount -o bind $repository_uri $SLASH_LOCATION$MEDIA_LOCATION_ROOTED") sys("$sudo mount -t proc none $SLASH_LOCATION/proc"); sys("$sudo mount -t sysfs none $SLASH_LOCATION/sys"); +sys("$sudo mount -t tmpfs none $SLASH_LOCATION/run"); + +if (-d "/run/udev") { + # Ensure we mount the udev run dir for various extra metadata from udevadm + mkdir_p("$SLASH_LOCATION/run/udev"); + sys("$sudo mount -o bind /run/udev $SLASH_LOCATION/run/udev"); +} + +if (-d "/run/initramfs") { + # If dracut has been used (and thus udev has yummy metadata) make sure + # drakx knows about it when running in the chroot + mkdir_p("$SLASH_LOCATION/run/initramfs"); + sys("$sudo mount -o bind /run/initramfs $SLASH_LOCATION/run/initramfs"); +} if ($disk_iso_repository) { my $repository_arch = $repository_arch || 'i586'; @@ -179,7 +193,7 @@ sub create_initial_devices() { sub umount_all() { my $err; clean_stage2_updates(); - my @procs = ('/proc/bus/usb', '/proc', '/sys'); + my @procs = ('/proc/bus/usb', '/proc', '/sys', '/run/udev', '/run/initramfs', '/run'); foreach ((map { "$prefix_ROOTED$_" } @procs, ''), @procs, $STAGE2_LOCATION_ROOTED, $LOOP_MOUNT_POINT, $MEDIA_LOCATION_ROOTED, $IMAGE_LOCATION_ROOTED) { my $dir = "$SLASH_LOCATION$_"; rmdir $dir; -- cgit v1.2.1