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