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 attempts to determine if the root fs is on a logical
40 # volume by checking if the root device contains /dev/mapper in
41 # its path. The device node must exist for the check to succeed,
42 # but since it's usually managed by devfs or udev, so is probably
43 # not present, we just create a dummy file.
46 if not os.path.exists( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]) ):
48 utils.makedirs( "%s/dev/mapper" % SYSIMG_PATH )
49 rootdev= file( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]), "w" )
52 initrd, kernel_version= systeminfo.getKernelVersion(vars,log)
53 utils.removefile( "%s/boot/%s" % (SYSIMG_PATH, initrd) )
54 if checkKern() == True:
55 utils.sysexec( "chroot %s mkinitrd -v /boot/initrd-%s.img %s" % \
56 (SYSIMG_PATH, kernel_version, kernel_version), log )
58 shutil.copy("./mkinitrd.sh","%s/tmp/mkinitrd.sh" % SYSIMG_PATH)
59 os.chmod("%s/tmp/mkinitrd.sh" % SYSIMG_PATH, 755)
60 utils.sysexec( "chroot %s /tmp/mkinitrd.sh %s" % (SYSIMG_PATH, kernel_version))
62 if fake_root_lvm == True:
63 utils.removefile( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]) )
66 # Older bootcds only support LinuxThreads. This hack is to get mkinitrd
67 # to run without segfaulting by using /lib/obsolete/linuxthreads
68 kver = os.popen("/bin/uname -r", "r").readlines()[0].rstrip().split(".")
71 elif int(kver[1]) <=4: