[Bug 2051732] [NEW] update-grub fails with 'Syntax error at line 194'

Radu Marinescu 2051732 at bugs.launchpad.net
Tue Jan 30 20:47:20 UTC 2024


Public bug reported:

I have followed the tutorial https://openzfs.github.io/openzfs-
docs/Getting%20Started/Ubuntu/Ubuntu%2022.04%20Root%20on%20ZFS.html to
install Ubuntu Server 22.04 with root on zfs. However, after installing
grub-efi-amd64-signed I got a syntax error when running the update-grub
command.

The culprit seems to be the following section in /etc/grub.d/10_linux_zfs (lines 861-867):
```
    if [ -n "$boot_devices" ]; then
        for device in ${boot_devices}; do
            echo "${submenu_indentation}        if [ "${boot_device}" = "${device}" ]; then"
            echo "$(prepare_grub_to_access_device_cached "${device}" $(( submenu_level +1 )) )"
            echo "${submenu_indentation}        fi"
        done
    else
```

In my situation, this section generated an empty 'then' section in /boot/grub/grub.cfg in each menu entry:
```
                if [ ${boot_device} = /dev/mapper/root_zdrive1 ]; then

                fi
```

Adding an `echo ":"` in /etc/grub.d/10_linux_zfs solved the problem:
```
    if [ -n "$boot_devices" ]; then
        for device in ${boot_devices}; do
            echo "${submenu_indentation}        if [ "${boot_device}" = "${device}" ]; then"
            echo ":"
            echo "$(prepare_grub_to_access_device_cached "${device}" $(( submenu_level +1 )) )"
            echo "${submenu_indentation}        fi"
        done
    else
```

[Environment]

Ubuntu 22.04.3 LTS

grub-efi-amd64-signed:
  Installed: 1.187.6+2.06-2ubuntu14.4
  Candidate: 1.187.6+2.06-2ubuntu14.4
  Version table:
 *** 1.187.6+2.06-2ubuntu14.4 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
        100 /var/lib/dpkg/status
     1.180+2.06-2ubuntu7 500
        500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages


I hope this helps!
There is a similar bug to this, involving the same file, but that is for 19.03 and the fix and cause of the error seem to be different.

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: grub-common 2.06-2ubuntu7.2
ProcVersionSignature: Ubuntu 6.5.0-14.14~22.04.1-generic 6.5.3
Uname: Linux 6.5.0-14-generic x86_64
NonfreeKernelModules: zfs
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Tue Jan 30 20:02:36 2024
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=C.UTF-8
 SHELL=/usr/bin/bash
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: grub2
UpgradeStatus: No upgrade log present (probably fresh install)
mtime.conffile..etc.grub.d.10_linux_zfs: 2024-01-30T19:59:34.274482

** Affects: grub2 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug grub-common grub2 jammy zfs zsys

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/2051732

Title:
  update-grub fails with 'Syntax error at line 194'

Status in grub2 package in Ubuntu:
  New

Bug description:
  I have followed the tutorial https://openzfs.github.io/openzfs-
  docs/Getting%20Started/Ubuntu/Ubuntu%2022.04%20Root%20on%20ZFS.html to
  install Ubuntu Server 22.04 with root on zfs. However, after
  installing grub-efi-amd64-signed I got a syntax error when running the
  update-grub command.

  The culprit seems to be the following section in /etc/grub.d/10_linux_zfs (lines 861-867):
  ```
      if [ -n "$boot_devices" ]; then
          for device in ${boot_devices}; do
              echo "${submenu_indentation}        if [ "${boot_device}" = "${device}" ]; then"
              echo "$(prepare_grub_to_access_device_cached "${device}" $(( submenu_level +1 )) )"
              echo "${submenu_indentation}        fi"
          done
      else
  ```

  In my situation, this section generated an empty 'then' section in /boot/grub/grub.cfg in each menu entry:
  ```
                  if [ ${boot_device} = /dev/mapper/root_zdrive1 ]; then

                  fi
  ```

  Adding an `echo ":"` in /etc/grub.d/10_linux_zfs solved the problem:
  ```
      if [ -n "$boot_devices" ]; then
          for device in ${boot_devices}; do
              echo "${submenu_indentation}        if [ "${boot_device}" = "${device}" ]; then"
              echo ":"
              echo "$(prepare_grub_to_access_device_cached "${device}" $(( submenu_level +1 )) )"
              echo "${submenu_indentation}        fi"
          done
      else
  ```

  [Environment]

  Ubuntu 22.04.3 LTS

  grub-efi-amd64-signed:
    Installed: 1.187.6+2.06-2ubuntu14.4
    Candidate: 1.187.6+2.06-2ubuntu14.4
    Version table:
   *** 1.187.6+2.06-2ubuntu14.4 500
          500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
          500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
          100 /var/lib/dpkg/status
       1.180+2.06-2ubuntu7 500
          500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages

  
  I hope this helps!
  There is a similar bug to this, involving the same file, but that is for 19.03 and the fix and cause of the error seem to be different.

  ProblemType: Bug
  DistroRelease: Ubuntu 22.04
  Package: grub-common 2.06-2ubuntu7.2
  ProcVersionSignature: Ubuntu 6.5.0-14.14~22.04.1-generic 6.5.3
  Uname: Linux 6.5.0-14-generic x86_64
  NonfreeKernelModules: zfs
  ApportVersion: 2.20.11-0ubuntu82.5
  Architecture: amd64
  CasperMD5CheckResult: unknown
  Date: Tue Jan 30 20:02:36 2024
  ProcEnviron:
   TERM=xterm-256color
   PATH=(custom, no user)
   XDG_RUNTIME_DIR=<set>
   LANG=C.UTF-8
   SHELL=/usr/bin/bash
  RebootRequiredPkgs: Error: path contained symlinks.
  SourcePackage: grub2
  UpgradeStatus: No upgrade log present (probably fresh install)
  mtime.conffile..etc.grub.d.10_linux_zfs: 2024-01-30T19:59:34.274482

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2051732/+subscriptions




More information about the foundations-bugs mailing list