(focal update-grub) 10_linux_zfs: causes lots of warnings (invalid version number, bpool does not exist)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grub2 (Ubuntu) |
Fix Released
|
Medium
|
Jean-Baptiste Lallement | ||
Focal |
Triaged
|
Medium
|
Unassigned | ||
Groovy |
Won't Fix
|
Medium
|
Unassigned | ||
grubzfs-testsuite (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Focal |
Confirmed
|
Undecided
|
Unassigned | ||
Groovy |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
On our upgrade Focal system (which had ZFS-on-root _before_ this was an installer option in Ubuntu) we're seeing these non-fatal warnings when running update-grub:
```
# update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/
Generating grub configuration file ...
cannot open 'bpool/
Found linux image: vmlinuz-
Found initrd image: initrd.
Found linux image: vmlinuz-
Found initrd image: initrd.
(start loop)
cannot open 'bpool/
dpkg: warning: version '12-06-
dpkg: warning: version '12-06-
Found linux image: vmlinuz-
Found initrd image: initrd.
Found linux image: vmlinuz-
Found initrd image: initrd.
(repeat loop for a number of times)
Adding boot menu entry for UEFI Firmware Settings
done
```
There are two problems here:
- checking of files on 'bpool', even though I only have an 'rpool' zpool; having that error appear for all snapshots is awkward
- the invalid character in version number (caused by the version_find_latest not coping with full path names)
First error:
```
$ update-grub 2>&1 | grep 'does not'
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
cannot open 'bpool/
```
This is really confusing if you haven't set up a bpool zpool at all.
Simple fix:
```
--- a/grub.
+++ b/grub.
@@ -369,6 +369,7 @@ is_secure_
get_dataset_info() {
local dataset="$1"
local mntdir="$2"
+ local has_bpool="$3"
local base_dataset=
local etc_dir=
@@ -405,7 +406,10 @@ get_dataset_info() {
mountpoint -q "${mntdir}/etc" && umount "${mntdir}/etc" || true
# read available kernels from /boot
- boot_dir=
+ local boot_dir=
+ if [ $has_bpool -eq 1 ]; then
+ boot_dir=
+ fi
if [ -z "${boot_dir}" ]; then
fi
@@ -534,14 +538,15 @@ get_dataset_info() {
bootlist() {
local mntdir="$1"
local boot_list=""
+ local has_bpool=$(zpool list -Honame bpool >/dev/null 2>&1 && echo 1 || echo 0)
for dataset in $(get_root_
# get information from current root dataset
- boot_list=
+ boot_list=
# get information from snapshots of this root dataset
for snapshot_dataset in $(zfs list -H -o name -t snapshot "${dataset}"); do
- boot_list=
+ boot_list=
done
done
echo "${boot_list}"
```
Now it will skip trying the bpool if no such pool exists.
The second error is:
```
# update-grub 2>&1 | grep 'invalid character'
dpkg: warning: version '12-06-
dpkg: warning: version '12-06-
dpkg: warning: version '12-06-
...
dpkg: warning: version '20201002T0600Z
dpkg: warning: version '20201002T0700Z
dpkg: warning: version '20201002T0700Z
```
They are caused by the dash (hyphen) in the directory name, and passing the full path to the version_find_latest function.
See this:
```
# . /usr/share/
# version_find_latest app1-1.9.3.4 app1-1foo-bar-baz app1-1.10
app1-1.10
# version_find_latest /path/to/
/somewhere/
# version_find_latest /path/to/
dpkg: warning: version 'X/app1-1.9.3.4' has bad syntax: version number does not start with digit
/path/to/
```
We could fix the grub-mkconfig_lib version_
```
# version_find_latest app1-1.9.3.4 app1-1.10
app1-1.10
```
Changes required:
```
--- a/grub.
+++ b/grub.
@@ -422,7 +422,9 @@ get_dataset_info() {
kernel_list=""
list=$(find "${boot_dir}" -maxdepth 1 -type f -regex '.*/\(vmlinuz\
while [ "x$list" != "x" ] ; do
- linux=`
+ list_basename=
+ linux=`
+ linux=$(for l in $list; do test "${l##*/}" = "${linux}" && echo "$l" && break; done)
list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '`
if ! grub_file_
```
With both patches in place, the output of `update-grub` is not 113 lines, but 37. And all warnings are gone.
Patch attached!
Cheers,
Walter Doekes
OSSO B.V.
Changed in grub2 (Ubuntu): | |
importance: | Undecided → Low |
status: | New → Triaged |
assignee: | nobody → Jean-Baptiste Lallement (jibel) |
importance: | Low → Medium |
status: | Triaged → In Progress |
Changed in grub2 (Ubuntu Focal): | |
status: | New → Triaged |
Changed in grub2 (Ubuntu Groovy): | |
status: | New → Triaged |
Changed in grub2 (Ubuntu Focal): | |
importance: | Undecided → Medium |
Changed in grub2 (Ubuntu Groovy): | |
importance: | Undecided → Medium |
Changed in grubzfs-testsuite (Ubuntu): | |
status: | Fix Released → Triaged |
The attachment "grub2- fix-10_ linux_zfs- warnings. patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.
[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]