Public bug reported:

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/cases/environments.


Cause:
-----

Shell pattern matching rule (/usr/bin/grub-installer, line 327).

                 case $prefix in
                     [...]
                    /dev/[hsv]d[a-z0-9]|[...])     <<---
                     [...]
                     *)
                     [...]

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/grub-installer

i.e.,

                 case $prefix in
                     [...]
                -    /dev/[hsv]d[a-z0-9]|[...])
                +    /dev/[hsv]d[a-z0-9]*|[...])    
                     [...]
                     *)
                     [...]

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/[hsv]d[a-z0-9](more chars)" 
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-{1..27}.qcow2')

$ 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,file=ubuntu-14.04-server-ppc64el.iso
-drive\ file=disk-{1..27}.qcow2


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/grub-installer is present), drop to a shell and modify the 
script:

        [...]
        Partition disks
        Go Back
        Execute a shell
        Continue

        ~ # sed '327 s,|,*|,' -i /usr/bin/grub-installer
        ~ # 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.

** Affects: grub-installer (Ubuntu)
     Importance: Undecided
         Status: Confirmed

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

Title:
  grub-installer fails on 26+ disks (restrictive shell pattern)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub-installer/+bug/1325606/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to