3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
11 from Exceptions import *
18 Rebuilds the system initrd, on first install or in case the
22 log.write( "\n\nStep: Rebuilding initrd\n" )
24 # make sure we have the variables we need
26 SYSIMG_PATH= vars["SYSIMG_PATH"]
28 raise ValueError, "SYSIMG_PATH"
30 PARTITIONS= vars["PARTITIONS"]
31 if PARTITIONS == None:
32 raise ValueError, "PARTITIONS"
35 raise BootManagerException, "Missing variable in vars: %s\n" % var
36 except ValueError, var:
37 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
39 # mkinitrd needs /dev and /proc to do the right thing.
40 # /proc is already mounted, so bind-mount /dev here
41 utils.sysexec("mount -o bind /dev %s/dev" % SYSIMG_PATH)
42 utils.sysexec("mount -t sysfs none %s/sys" % SYSIMG_PATH)
44 initrd, kernel_version= systeminfo.getKernelVersion(vars,log)
45 utils.removefile( "%s/boot/%s" % (SYSIMG_PATH, initrd) )
46 if checkKern() == True:
47 utils.sysexec( "chroot %s mkinitrd -v /boot/initrd-%s.img %s" % \
48 (SYSIMG_PATH, kernel_version, kernel_version), log )
50 shutil.copy("./mkinitrd.sh","%s/tmp/mkinitrd.sh" % SYSIMG_PATH)
51 os.chmod("%s/tmp/mkinitrd.sh" % SYSIMG_PATH, 755)
52 utils.sysexec( "chroot %s /tmp/mkinitrd.sh %s" % (SYSIMG_PATH, kernel_version))
54 utils.sysexec_noerr("umount %s/sys" % SYSIMG_PATH)
55 utils.sysexec_noerr("umount %s/dev" % SYSIMG_PATH)
58 # Older bootcds only support LinuxThreads. This hack is to get mkinitrd
59 # to run without segfaulting by using /lib/obsolete/linuxthreads
60 kver = os.popen("/bin/uname -r", "r").readlines()[0].rstrip().split(".")
63 elif int(kver[1]) <=4: