3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
11 from Exceptions import *
17 Rebuilds the system initrd, on first install or in case the
21 log.write( "\n\nStep: Rebuilding initrd\n" )
23 # make sure we have the variables we need
25 SYSIMG_PATH= vars["SYSIMG_PATH"]
27 raise ValueError, "SYSIMG_PATH"
29 PARTITIONS= vars["PARTITIONS"]
30 if PARTITIONS == None:
31 raise ValueError, "PARTITIONS"
34 raise BootManagerException, "Missing variable in vars: %s\n" % var
35 except ValueError, var:
36 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
38 # mkinitrd attempts to determine if the root fs is on a logical
39 # volume by checking if the root device contains /dev/mapper in
40 # its path. The device node must exist for the check to succeed,
41 # but since it's usually managed by devfs or udev, so is probably
42 # not present, we just create a dummy file.
45 if not os.path.exists( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]) ):
47 utils.makedirs( "%s/dev/mapper" % SYSIMG_PATH )
48 rootdev= file( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]), "w" )
51 initrd, kernel_version= systeminfo.getKernelVersion(vars,log)
52 utils.removefile( "%s/boot/%s" % (SYSIMG_PATH, initrd) )
53 utils.sysexec( "chroot %s mkinitrd -v /boot/initrd-%s.img %s" % \
54 (SYSIMG_PATH, kernel_version, kernel_version), log )
56 if fake_root_lvm == True:
57 utils.removefile( "%s/%s" % (SYSIMG_PATH,PARTITIONS["mapper-root"]) )