3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
11 from Exceptions import *
16 # 14:42:27(UTC) No module dm-mem-cache found for kernel 2.6.22.19-vs2.3.0.34.33.onelab, aborting.
17 # http://kbase.redhat.com/faq/docs/DOC-16528;jsessionid=7E984A99DE8DB094D9FB08181C71717C.ab46478d
18 def bypassRaidIfNeeded(sysimg_path, log):
20 [ a,b,c,d]=file('%s/etc/redhat-release'%sysimg_path).readlines()[0].strip().split()
21 if a !='CentOS': return
22 [major,minor]=[int(x) for x in c.split('.')]
24 utils.sysexec_noerr('echo "DMRAID=no" >> %s/etc/sysconfig/mkinitrd/noraid' % sysimg_path , log )
25 utils.sysexec_noerr('chmod 755 %s/etc/sysconfig/mkinitrd/noraid' % sysimg_path, log )
32 Rebuilds the system initrd, on first install or in case the
36 log.write( "\n\nStep: Rebuilding initrd\n" )
38 # make sure we have the variables we need
40 SYSIMG_PATH= vars["SYSIMG_PATH"]
42 raise ValueError, "SYSIMG_PATH"
44 PARTITIONS= vars["PARTITIONS"]
45 if PARTITIONS == None:
46 raise ValueError, "PARTITIONS"
49 raise BootManagerException, "Missing variable in vars: %s\n" % var
50 except ValueError, var:
51 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
53 # mkinitrd needs /dev and /proc to do the right thing.
54 # /proc is already mounted, so bind-mount /dev here
55 # xxx tmp - trying to work around the f14 case:
56 # check that /dev/ is mounted with devtmpfs
57 # tmp - sysexec_noerr not returning what one would expect
58 # if utils.sysexec_noerr ("grep devtmpfs /proc/mounts") != 0:
59 utils.sysexec_noerr("mount -t devtmpfs none /dev")
60 utils.sysexec("mount -o bind /dev %s/dev" % SYSIMG_PATH)
61 utils.sysexec("mount -t sysfs none %s/sys" % SYSIMG_PATH)
63 initrd, kernel_version= systeminfo.getKernelVersion(vars,log)
65 utils.removefile( "%s/boot/%s" % (SYSIMG_PATH, initrd) )
67 print "%s/boot/%s is already removed" % (SYSIMG_PATH, initrd)
70 bypassRaidIfNeeded(SYSIMG_PATH , log )
71 # specify ext3 for fedora14 and above as their default fs is ext4
72 utils.sysexec_chroot( SYSIMG_PATH, "mkinitrd -v --with=ext3 --allow-missing /boot/initrd-%s.img %s" % \
73 (kernel_version, kernel_version), log )
75 utils.sysexec_noerr("umount %s/sys" % SYSIMG_PATH , log )
76 utils.sysexec_noerr("umount %s/dev" % SYSIMG_PATH , log)