System state with 'space' in name prevent update-grub to create menu entries in grub.cfg
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grub2 (Ubuntu) |
Fix Released
|
Medium
|
Jean-Baptiste Lallement | ||
Focal |
Triaged
|
Medium
|
Jean-Baptiste Lallement | ||
Groovy |
Won't Fix
|
Medium
|
Jean-Baptiste Lallement | ||
grubzfs-testsuite (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
zsys (Ubuntu) |
Fix Released
|
Medium
|
Jean-Baptiste Lallement | ||
Focal |
Triaged
|
Medium
|
Jean-Baptiste Lallement | ||
Groovy |
Won't Fix
|
Medium
|
Jean-Baptiste Lallement |
Bug Description
[Impact]
Some characters are not supported in snapshot names by either zfs, grub or init. As a consequence a system cannot be reverted to a snapshot created with such characters, and the system fails to boot with various errors.
This patch forces the name of snapshot created with zsysctl to the following characters: a-z, A-Z, 0-9, _, -, .
Space is not unsupported by ZFS and would be perfectly correct to create a snapshot with a space in it. However it creates issues in GRUB when it generates the boot command line due to the way it quotes the argument root= by adding a double before root which is then wrongly interpreted by init. It also creates issues in init which uses for loop to read the command line and splits it on spaces, and in the middle of the root argument while it should be a single argument. Fixing space handling in GRUB and init is really intrusive and beyond the scope of this bug so we decided to prevent spaces too in snapshot names.
[Test Case]
1. Boot a system with zsys without the patch
* Positive test *
2. Create a system snapshot with a valid character. Valid characters are "a-z", "A-Z", "0-9", "_", "-", "." Name must not start by . or -
=> Verify that the snapshot is created successfully
3. Reboot to the grub menu and in the history menu select the snapshot you just created.
=> Verify that the system boot to the reverted state of the snapshot
* Negative test 1*
4. Create a snapshot with an invalid character.
=> Verify that the creation fails with an error message listing the invalid character/s
* Negative test 2*
5. Create a snapshot that starts with '-'
=> Verify that the snapshot cannot be created.
* Negative test 3*
5. Create a snapshot names '.' or '..'
=> Verify that the snapshot cannot be created.
[Regression potential]
If filtering is not done properly the patch can either:
1. prevent supported characters to be used in snapshot names but snapshots can still be created and names generated by auto snapshots are supported.
2. allow unsupported characters to be used in snapshot names. In this case we are back to current situation.
The patch is covered by several tests in the included test suite.
[Original Description]
From https:/
Describe the bug
I did create few days ago a System state with a 'space' in the name : "pool/ROOT/
server:~$ zsysctl show
Name: rpool/ROOT/
ZSys: true
Last Used: current
History:
- Name: rpool/ROOT/
Created on: 2020-10-16 06:49:59
- Name: rpool/ROOT/
Created on: 2020-10-15 06:40:13
- Name: rpool/ROOT/
Created on: 2020-10-08 06:46:34
- Name: rpool/ROOT/
Created on: 2020-10-07 06:20:00
- Name: rpool/ROOT/
Created on: 2020-10-03 19:18:18
- Name: rpool/ROOT/
Created on: 2020-10-03 17:58:19
(truncated)...
I found myself in the impossibility to boot the server few days after as the Grub menu had only the UEFI entry in it. No more entries for current kernel or zsys history.
server:~$ cat /boot/grub/grub.cfg
...(truncated)
### END /etc/grub.
### BEGIN /etc/grub.
### END /etc/grub.
### BEGIN /etc/grub.
menuentry 'UEFI Firmware Settings' $menuentry_
fwsetup
}
### END /etc/grub.
### BEGIN /etc/grub.
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.
(truncated)...
After chrooting into the server, I tried to rebuild the menu with update-grub and got a weird error message on ignoring datasets:
server:~$ update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/
Generating grub configuration file ...
Found linux image: vmlinuz-
Found initrd image: initrd.
Found linux image: vmlinuz-
Found initrd image: initrd.
...(truncated)...
Found initrd image: initrd.
Warning: Failed to find a valid directory 'etc' for dataset 'rpool/
Warning: Ignoring rpool/ROOT/
filesystem 'Plex' cannot be mounted, unable to open the dataset
Adding boot menu entry for UEFI Firmware Settings
done
As a result the grub.cfg file was letf with only the UEFI entry.
To solve this issue, I had to delete the problematic state and reran update-grub. I then was back to normal.
server:~$ zsysctl state remove 'Stable Plex' --system
ZSys is adding automatic system snapshot to GRUB menu
server:~$ update-grub
...(truncated)...
server:~$ cat /boot/grub/grub.cfg
...(truncated)
menuentry '* Ubuntu 20.04.1 LTS, with Linux 5.4.0-48-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os ${menuentry_
recordfail
load_video
insmod gzio
if [ "${grub_platform}" = xen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod zfs
if [ x$feature_
search --no-floppy --fs-uuid --set=root 9976c549b4d44f87
else
search --no-floppy --fs-uuid --set=root 9976c549b4d44f87
fi
echo Loading Linux 5.4.0-48-generic ...
linux /BOOT/ubuntu_
echo 'Loading initial ramdisk ...'
initrd /BOOT/ubuntu_
}
}
submenu 'History for Ubuntu 20.04.1 LTS' ${menuentry_
submenu 'Revert to 10/16/2020 @ 06:49' ${menuentry_
(truncated)...
To Reproduce
Create a system state with a 'space' in the name
Run update-grub and check the warning message at the end of the process
Check /boot/grub/grub.cfg file for missing Grub menu entries
Expected behavior
A grub.cfg file with all necessary menu entries.
zsysctl should forbid to create state with space in name or zsys update-grub helper should be able to handle states' names with spaces in it.
For ubuntu users, please run and copy the following:
ubuntu-bug zsys --save=/tmp/report
Copy paste below /tmp/report content:
File is too big. Will put it in comment.
Installed versions:
OS: (/etc/os-release)
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https:/
SUPPORT_URL="https:/
BUG_REPORT_URL="https:/
PRIVACY_
VERSION_
UBUNTU_
Zsysd running version: (zsysctl version output)
zsysctl 0.4.7
zsysd 0.4.7
Additional context
It's a Ubuntu Server flavor, booting on ZFS with Zsys and installed with the following procedure: https:/
Changed in grub2 (Ubuntu): | |
status: | New → In Progress |
importance: | Undecided → Medium |
assignee: | nobody → Jean-Baptiste Lallement (jibel) |
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 grub2 (Ubuntu Focal): | |
assignee: | nobody → Jean-Baptiste Lallement (jibel) |
Changed in grub2 (Ubuntu Groovy): | |
assignee: | nobody → Jean-Baptiste Lallement (jibel) |
Changed in zsys (Ubuntu Focal): | |
assignee: | nobody → Jean-Baptiste Lallement (jibel) |
Changed in zsys (Ubuntu Groovy): | |
assignee: | nobody → Jean-Baptiste Lallement (jibel) |
Changed in zsys (Ubuntu): | |
status: | In Progress → Fix Committed |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in grubzfs-testsuite (Ubuntu): | |
status: | Fix Released → Triaged |
Adding zsys and removing grubzfs-testsuite. We now block invalid characters in zsys from state name when a user creates a system or user snapshot. Space is not really an unsupported character but it causes problems in grub itself and init so we exclude it from the list of valid characters.