3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
11 from Exceptions import *
17 # 14:42:27(UTC) No module dm-mem-cache found for kernel 2.6.22.19-vs2.3.0.34.33.onelab, aborting.
18 # http://kbase.redhat.com/faq/docs/DOC-16528;jsessionid=7E984A99DE8DB094D9FB08181C71717C.ab46478d
19 def bypassRaidIfNeeded(sysimg_path):
21 [ a,b,c,d]=file('%s/etc/redhat-release'%sysimg_path).readlines()[0].strip().split()
22 if a !='CentOS': return
23 [major,minor]=[int(x) for x in c.split('.')]
25 utils.sysexec_noerr('echo "DMRAID=no" >> %s/etc/sysconfig/mkinitrd/noraid' % sysimg_path)
26 utils.sysexec_noerr('chmod 755 %s/etc/sysconfig/mkinitrd/noraid' % sysimg_path)
33 Rebuilds the system initrd, on first install or in case the
37 log.write( "\n\nStep: Rebuilding initrd\n" )
39 # make sure we have the variables we need
41 SYSIMG_PATH= vars["SYSIMG_PATH"]
43 raise ValueError, "SYSIMG_PATH"
45 PARTITIONS= vars["PARTITIONS"]
46 if PARTITIONS == None:
47 raise ValueError, "PARTITIONS"
50 raise BootManagerException, "Missing variable in vars: %s\n" % var
51 except ValueError, var:
52 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
54 # mkinitrd needs /dev and /proc to do the right thing.
55 # /proc is already mounted, so bind-mount /dev here
56 utils.sysexec("mount -o bind /dev %s/dev" % SYSIMG_PATH)
57 utils.sysexec("mount -t sysfs none %s/sys" % SYSIMG_PATH)
59 initrd, kernel_version= systeminfo.getKernelVersion(vars,log)
61 utils.removefile( "%s/boot/%s" % (SYSIMG_PATH, initrd) )
63 print "%s/boot/%s is already removed" % (SYSIMG_PATH, initrd)
66 bypassRaidIfNeeded(SYSIMG_PATH)
67 utils.sysexec_chroot( SYSIMG_PATH, "mkinitrd -v --allow-missing /boot/initrd-%s.img %s" % \
68 (kernel_version, kernel_version), log )
70 utils.sysexec_noerr("umount %s/sys" % SYSIMG_PATH)
71 utils.sysexec_noerr("umount %s/dev" % SYSIMG_PATH)