Comment 85 for bug 1265192

Revision history for this message
Chris Bainbridge (chris-bainbridge) wrote :

This patch should fix Ubiquity not detecting Windows EFI installs.

Ubiquity uses os-prober to detect installed operating systems. os-prober iterates through each disk and each partition, calling a series of scripts to attempt to identify a given partition, and printing results to stdout in the form:

/dev/sda1:Windows XP Professional:Windows:chain
/dev/sda2:Windows 8 (loader):Windows:chain
/dev/sda3:Ubuntu 14.04.1 (14.04):Ubuntu:linux
/dev/sda4:Mac OS X:MacOSX:macosx
/dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi

Note the final result: on Windows EFI systems, os-prober runs the script /usr/lib/os-probes/mounted/efi/20microsoft, which prints not just the partition device, but also the '@' character followed by the full path to the Windows EFI boot manager. This causes Ubiquity to fail to detect Windows, because the string comparison of '/dev/sda1' to '/dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi' fails.

The patch fixes this by limiting the device path to only regular characters and digits. I should point out that I haven't fully tested this patch as I do not have a Windows EFI system to test on, but I have tested by replacing /usr/bin/os-prober with a shell script that just echoes the full EFI line to the output, eg.:

 #!/bin/sh
echo "/dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi"

With this technique it is possible to test different layouts in a VM without having to install any other operating systems. Just make the bare partitions and then have os-prober report that something is installed there.

There is another serious bug I noticed in Ubiquity:

    - os-prober returns a list of installed operating systems but the code of calculate_autopartitioning_options() in ubiquity/plugins/ubi-partman.py just gets passed a basic list of all the detected operating systems on all drives. The logic assumes that all of the operating systems are on the same drive, so on a multi-disk system it will report all operating systems on every disk as being "installed" at the same time, and when OSes are on different disks it will warn, for example, that "both Windows and Ubuntu will be deleted", which isn't true because Windows and Ubuntu are on different disks and only one disk is going to be deleted.

    - If there are two disks, and os-prober shows no operating systems on sda and Ubuntu on sdb, then the Ubiquity "Install" screen will have title "Erase Ubuntu 12.04 and reinstall" and will incorrectly select drive "sda" (Ubuntu is not on sda). If the user clicks continue, the installer will go ahead and overwrite all partitions on the first disk while claiming to be "erasing Ubuntu 12.04". It does say that "4 partitions will be deleted" (another bug, it seems to include free space gaps in the partition count) but it's easy to miss that text, given the reassuring big font text "Erase Ubuntu xx and reinstall".

The problem code was introduced in this patch: http://bazaar.launchpad.net/~ubuntu-installer/ubiquity/trunk/revision/4515.1.1/ubiquity/plugins/ubi-partman.py - unless I am missing something, it seems that the calculate_autopartitioning_options() code is based on the assumption that the user will only have one drive, and never dealt correctly with multiple drives.

Unless someone has time to fix the multiple drive automatic partitioning I would recommend just disabling it and forcing multiple drive owners to manually partition. It's better than losing data.