grub-installer fails on disks > 26th (restrictive shell pattern)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grub-installer (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Problem:
-------
grub-installer fails on disks greater than the 26th disk.
Upfront, I acknowledge this is an unlikely scenario, but that problem was caught by test teams,
and it might be worth fixing (proposal included below) for some application/
Cause:
-----
Shell pattern matching rule (/usr/bin/
case $prefix in
[...]
/
[...]
*)
[...]
That pattern disallows disks named after /dev/sdaa, for example.
Names with 2 letters are assigned to the 27th disk forwards (i.e., sda-sdz for the first 26).
With the current code, disks > 26 will match the '*' (asterisk) rule, and hit the grub-installer error.
Solution Proposal:
-----------------
sed '327 s,|,*|,' -i /usr/bin/
i.e.,
case $prefix in
[...]
- /dev/[hsv]
+ /dev/[hsv]
[...]
*)
[...]
This would allow the old pattern to exist (* matches /zero/ or more characters),
while allowing more characters after an initial alphanumeric character.
Caveat: ok, the new characters can now be anything (asterisk), not only alphanumeric
chars, but I think it's unlikely to see anything named after "/dev/[
where '(more chars)' isn't also '[a-z0-9]', specially on the (mostly controlled) installer scenario.
Problem Test-case:
-----------------
Install with 27 disks, choosing the 27th disk (sdaa, or vdaa.. anything w/ 2 alphas before a partition number)
Step 0) create 27 disk images
$ for i in {1..27}; do qemu-img create -f qcow2 disk-$i.qcow2 1g; done
Formatting 'disk-1.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off
[...]
Formatting 'disk-27.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off
$
Step 1) install ubuntu server on it
Using ppc64el as an example, but should occur on other archs too:
(use 'eval' for the correct expansion of '-drive\ file=disk-
$ eval qemu-system-ppc64 -enable-kvm -M pseries -cpu POWER7 -smp 1,cores=1,threads=1 -m 1G -vga none -nographic -boot once=d -device spapr-vscsi -drive media=cdrom,
Step 2) proceed until grub install stage; it will fail.
Solution Test-case:
------------------
Same steps as 'problem test-case', but on the 'Partition disks' stage (or anything
after /usr/bin/
[...]
Partition disks
Go Back
Execute a shell
Continue
~ # sed '327 s,|,*|,' -i /usr/bin/
~ # exit
(back to the installer, resume normal installation by pressing enter.. selection should be at Partition Disks)
The grub-installer should pass correctly.
Note: after the installation finishes, grub2 will not boot the correct drive since it only attemps
from disks 'disk (0) to disk7' (which is another story/bug). So, if you want to see the system
booting, change the qemu command line from 'disk-{1..27}' to 'disk-{20-27}' (i.e., disk7 is the
installed disk).
You should see:
Trying to load: from: disk ...
E3404: Not a bootable device!
Trying to load: from: disk1 ...
E3404: Not a bootable device!
Trying to load: from: disk2 ...
E3404: Not a bootable device!
Trying to load: from: disk3 ...
E3404: Not a bootable device!
Trying to load: from: disk4 ...
E3404: Not a bootable device!
Trying to load: from: disk5 ...
E3404: Not a bootable device!
Trying to load: from: disk6 ...
E3404: Not a bootable device!
Trying to load: from: disk7 ... Successfully loaded
[ ... booting ... ]
Thanks.
Status changed to 'Confirmed' because the bug affects multiple users.