update-grub fails to add ZFS menu entries
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grub2 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
This is for:
Ubuntu 20.04 LTS
grub-common 2.04-1ubuntu26
I don't know how I got into this mess (maybe by removing ZFS @install snapshots?), but update-grub stopped adding any Ubuntu entries to my menu.cfg.
The culprit is the use of \t as a field separator in /etc/grub.
There's a line that says:
echo "${dataset}
Instead, it should say:
echo -e "${dataset}
By default, echo does not interpret the escaped tab sequence, \t. So all of the awk lines that use it as a field separator elsewhere in the script fail.
Adding the above -e flag fixed my problem.
I have experienced this problem too. Adding the -e flag, substituting printf for echo, or changing the shebang line into #!/bin/dash fixes the issue, as does switching /bin/sh from Bash to Dash by running dpkg-reconfigure dash. My guess is that this is a Dashism, i.e. an incompatibility with systems configured to use Bash as /bin/sh, as the two shells are not 100% compatible.