From f76137882711b367de7303a193a32ab8ac282d19 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 2 May 2018 16:37:16 -0700 Subject: [PATCH 1/6] Use a longer wait during debug installs - else the serial console speed gets in the way --- builds/any/installer/installer.sh.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/builds/any/installer/installer.sh.in b/builds/any/installer/installer.sh.in index 470bc882..c5e33f3b 100644 --- a/builds/any/installer/installer.sh.in +++ b/builds/any/installer/installer.sh.in @@ -141,6 +141,9 @@ if has_boot_env onl_installer_debug; then installer_debug=1; fi if test "$installer_debug"; then echo "Debug mode" set -x + installer_wait=30 +else + installer_wait=3 fi # Pickup ONIE defines for this machine. @@ -254,7 +257,7 @@ if test "${onie_platform}"; then installer_umount - if installer_reboot; then + if installer_reboot $installer_wait; then : else sync @@ -587,7 +590,7 @@ trap - 0 1 installer_umount if test "${onie_platform}"; then - installer_reboot + installer_reboot $installer_wait fi exit From d39868c23b87dc806fd607901fda7327e2b61a16 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 2 May 2018 16:38:14 -0700 Subject: [PATCH 2/6] load the efivarfs module if possible --- packages/base/all/initrds/loader-initrd-files/src/bin/switchroot | 1 + packages/base/all/initrds/loader-initrd-files/src/bin/sysinit | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/switchroot b/packages/base/all/initrds/loader-initrd-files/src/bin/switchroot index 2eb8ead6..16529007 100644 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/switchroot +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/switchroot @@ -54,6 +54,7 @@ if [ -d /sys/firmware/efi/efivars ]; then fi mount --move /sys /newroot/sys if [ -d /newroot/sys/firmware/efi/efivars ]; then + modprobe efivarfs || : mount -t efivarfs efivarfs /newroot/sys/firmware/efi/efivars fi mount --move /dev /newroot/dev diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit index 910b3fcf..9d869beb 100755 --- a/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit +++ b/packages/base/all/initrds/loader-initrd-files/src/bin/sysinit @@ -36,6 +36,7 @@ trap "restoreconsole; reboot -f" EXIT mount -t proc proc /proc mount -t sysfs sysfs /sys if [ -d /sys/firmware/efi/efivars ]; then + modprobe efivarfs || : mount -t efivarfs efivarfs /sys/firmware/efi/efivars fi mount -o remount,size=1M /dev From 7b7fef083a1198fce70ee5f30035d667666ec6b3 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 2 May 2018 16:38:20 -0700 Subject: [PATCH 3/6] load the efivarfs module if possible --- packages/base/all/vendor-config-onl/src/lib/install/lib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh index d684cf15..bb6730c3 100644 --- a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh +++ b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh @@ -114,6 +114,7 @@ installer_mkchroot() { fi mount -t devpts devpts "${rootdir}/dev/pts" if test -d "${rootdir}/sys/firmware/efi/efivars"; then + modprobe efivarfs || : mount -t efivarfs efivarfs "${rootdir}/sys/firmware/efi/efivars" fi From e09559d6dc3d8b0aa559b11f93469cc578ee9d66 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 2 May 2018 16:39:59 -0700 Subject: [PATCH 4/6] load the efivarfs filesystem if needed --- .../src/python/onl/install/InstallUtils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py index 85fe2c01..834eeaac 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/InstallUtils.py @@ -1059,6 +1059,16 @@ class InitrdContext(SubprocessMixin): cmd = ('mount', '-t', 'sysfs', 'sysfs', dst,) self.check_call(cmd, vmode=self.V1) + # Hurr, the efivarfs module may not be loaded + with open("/proc/filesystems") as fd: + buf = fd.read() + if "efivarfs" not in buf: + cmd = ('modprobe', 'efivarfs',) + try: + self.check_call(cmd, vmode=self.V1) + except subprocess.CalledProcessError: + pass + dst = os.path.join(self.dir, "sys/firmware/efi/efivars") if os.path.exists(dst): cmd = ('mount', '-t', 'efivarfs', 'efivarfs', dst,) From 9b282495fada6a4a0f91d5622672c90356228243 Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 2 May 2018 16:41:04 -0700 Subject: [PATCH 5/6] Better support for UEFI - throw a proper error if we cannot find the ESP partition - don't forget to parse the GPT first before starting the ESP search --- .../src/python/onl/install/BaseInstall.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py index 3290ec34..7416c20b 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/BaseInstall.py @@ -726,6 +726,9 @@ class GrubInstaller(SubprocessMixin, Base): ctx['boot_loading_name'] = sysconfig.installer.os_name if self.isUEFI: + if not self.espFsUuid: + self.log.error("cannnot find ESP UUID") + return 1 ctx['onie_boot_uuid'] = self.espFsUuid else: ctx['onie_boot_uuid'] = "" @@ -846,6 +849,16 @@ class GrubInstaller(SubprocessMixin, Base): self.blkidParts = BlkidParser(log=self.log.getChild("blkid")) + code = self.findGpt() + if code: return code + + if self.isUEFI: + code = self.findEsp() + if code: return code + self.im.grubEnv.__dict__['espPart'] = self.espDevice + else: + self.im.grubEnv.__dict__['espPart'] = None + code = self.installGrubCfg() if code: return code From e9c760edd2a4b103ed49501a32cc963c0f1eb95f Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 2 May 2018 16:42:08 -0700 Subject: [PATCH 6/6] Fixed broken loader upgrade - too many nested chroots - update loader system query to use a proper onie-sysinfo call --- .../src/python/onl/upgrade/loader.py | 69 +++++++++++-------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py index 9ebec5b5..bf3bbe51 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py @@ -89,6 +89,8 @@ class LoaderUpgrade_Fit(LoaderUpgradeBase): path = os.path.join(octx.initrdDir, "etc/machine.conf") if os.path.exists(path): machineConf = ConfUtils.MachineConf(path=path) + else: + machineConf = ConfUtils.MachineConf(path='/dev/null') installerConf = ConfUtils.InstallerConf(path="/dev/null") # start with an empty installerConf, fill it in piece by piece @@ -171,41 +173,54 @@ class LoaderUpgrade_x86_64(LoaderUpgradeBase, InstallUtils.SubprocessMixin): onlPlatform = onl.platform.current.OnlPlatform() - with OnieBootContext(log=self.logger) as octx: + with OnieBootContext(log=self.log) as octx: + + octx.ictx.attach() + octx.ictx.unmount() + octx.ictx.detach() + # XXX roth -- here, detach the initrd mounts + + octx.detach() + # hold on to the ONIE boot context for grub access + + if os.path.exists("/usr/bin/onie-shell"): + machineConf = OnieSysinfo(log=self.logger.getChild("onie-sysinfo")) + else: path = os.path.join(octx.initrdDir, "etc/machine.conf") - machineConf = ConfUtils.MachineConf(path=path) + if os.path.exists(path): + machineConf = ConfUtils.MachineConf(path=path) + else: + machineConf = ConfUtils.MachineConf(path='/dev/null') - # hold on to the ONIE boot context for grub access + installerConf = ConfUtils.InstallerConf(path="/dev/null") - installerConf = ConfUtils.InstallerConf(path="/dev/null") + # XXX fill in installerConf fields + installerConf.installer_platform = onlPlatform.platform() + installerConf.installer_arch = machineConf.onie_arch + installerConf.installer_platform_dir = os.path.join("/lib/platform-config", + onlPlatform.platform()) - # XXX fill in installerConf fields - installerConf.installer_platform = onlPlatform.platform() - installerConf.installer_arch = machineConf.onie_arch - installerConf.installer_platform_dir = os.path.join("/lib/platform-config", - onlPlatform.platform()) + mfPath = os.path.join(sysconfig.upgrade.loader.package.dir, "manifest.json") + mf = onl.versions.OnlVersionManifest(mfPath) + installerConf.onl_version = mf.RELEASE_ID - mfPath = os.path.join(sysconfig.upgrade.loader.package.dir, "manifest.json") - mf = onl.versions.OnlVersionManifest(mfPath) - installerConf.onl_version = mf.RELEASE_ID + grubEnv = ConfUtils.ChrootGrubEnv(octx.initrdDir, + bootDir=octx.onieDir, + path="/grub/grubenv", + log=self.logger.getChild("grub")) - grubEnv = ConfUtils.ChrootGrubEnv(octx.initrdDir, - bootDir=octx.onieDir, - path="/grub/grubenv", - log=self.logger.getChild("grub")) + ubootEnv = None - ubootEnv = None + installer = self.installer_klass(machineConf=machineConf, + installerConf=installerConf, + platformConf=onlPlatform.platform_config, + grubEnv=grubEnv, + ubootEnv=ubootEnv, + force=True, + log=self.logger) - installer = self.installer_klass(machineConf=machineConf, - installerConf=installerConf, - platformConf=onlPlatform.platform_config, - grubEnv=grubEnv, - ubootEnv=ubootEnv, - force=True, - log=self.logger) - - installer.upgradeBootLoader() - installer.shutdown() + installer.upgradeBootLoader() + installer.shutdown() self.reboot()