6 # Copyright (c) 2003 Intel Corporation
9 # Copyright (c) 2004-2006 The Trustees of Princeton University
10 # All rights reserved.
14 from Exceptions import *
20 # 14:42:27(UTC) No module dm-mem-cache found for kernel 2.6.22.19-vs2.3.0.34.33.onelab, aborting.
21 # http://kbase.redhat.com/faq/docs/DOC-16528;jsessionid=7E984A99DE8DB094D9FB08181C71717C.ab46478d
22 def bypassRaidIfNeeded(sysimg_path):
24 [ a,b,c,d]=file('%s/etc/redhat-release'%sysimg_path).readlines()[0].strip().split()
25 if a !='CentOS': return
26 [major,minor]=[int(x) for x in c.split('.')]
28 utils.sysexec_noerr('echo "DMRAID=no" >> %s/etc/sysconfig/mkinitrd/noraid' % sysimg_path)
29 utils.sysexec_noerr('chmod 755 %s/etc/sysconfig/mkinitrd/noraid' % sysimg_path)
36 Rebuilds the system initrd, on first install or in case the
40 log.write( "\n\nStep: Rebuilding initrd\n" )
42 # make sure we have the variables we need
44 SYSIMG_PATH= vars["SYSIMG_PATH"]
46 raise ValueError, "SYSIMG_PATH"
48 PARTITIONS= vars["PARTITIONS"]
49 if PARTITIONS == None:
50 raise ValueError, "PARTITIONS"
53 raise BootManagerException, "Missing variable in vars: %s\n" % var
54 except ValueError, var:
55 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
57 # mkinitrd needs /dev and /proc to do the right thing.
58 # /proc is already mounted, so bind-mount /dev here
59 utils.sysexec("mount -o bind /dev %s/dev" % SYSIMG_PATH)
60 utils.sysexec("mount -t sysfs none %s/sys" % SYSIMG_PATH)
62 initrd, kernel_version= systeminfo.getKernelVersion(vars,log)
64 utils.removefile( "%s/boot/%s" % (SYSIMG_PATH, initrd) )
66 print "%s/boot/%s is already removed" % (SYSIMG_PATH, initrd)
69 bypassRaidIfNeeded(SYSIMG_PATH)
70 utils.sysexec_chroot( SYSIMG_PATH, "mkinitrd -v /boot/initrd-%s.img %s" % \
71 (kernel_version, kernel_version), log )
73 utils.sysexec_noerr("umount %s/sys" % SYSIMG_PATH)
74 utils.sysexec_noerr("umount %s/dev" % SYSIMG_PATH)