Bug 759287

Summary: grub2-mkconfig identifies recovery partition as 'Windows NT/2000/XP'
Product: [Fedora] Fedora Reporter: Patrick C. F. Ernzer <pcfe>
Component: os-proberAssignee: Hedayat Vatankhah <hedayatv>
Status: CLOSED INSUFFICIENT_DATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 16CC: dennis, hedayatv, mads, pjones
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-04-18 13:05:12 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 494832    

Description Patrick C. F. Ernzer 2011-12-01 21:55:57 UTC
Description of problem:
Many modern machines that come pre-loaded with Windows use a recovery partition, usually invoked by a keypress during POST, to install Win again.
When installing Linux on such a machine, I tend to keep that recovery partition so that the machine can be set back to a factory state (when reselling, making a support case with the vendor or simply because the person I did the install for is new to Linux and wants the peace of mind that they can "make it like it was before' themselves)

with grub2-mkconfig they get a bootloader entry that looks like it would boot an installed windows, as opposed to kicking off the recovery function. This leaves the user only the hope that the vendor scripts on that partition will ask for confirmation before putting the harddisk back into factory state )and thus destroying the Linux install).

Version-Release number of selected component (if applicable):
grub2-1.99-12.fc16.x86_64

How reproducible:
always

Steps to Reproduce:
1. Have a recovery partition on /dev/sda2

2. # grub2-mkconfig -o /tmp/banana
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.1.2-1.fc16.x86_64
Found initrd image: /boot/initramfs-3.1.2-1.fc16.x86_64.img
Found linux image: /boot/vmlinuz-3.1.0-7.fc16.x86_64
Found initrd image: /boot/initramfs-3.1.0-7.fc16.x86_64.img
Found linux image: /boot/vmlinuz-2.6.41.1-1.fc15.x86_64
Found initrd image: /boot/initramfs-2.6.41.1-1.fc15.x86_64.img
Found Windows NT/2000/XP on /dev/sda2
Found Fedora release 15 (Lovelock) on /dev/mapper/VG_x60_internal-LV_slash_F15
done

Actual results:
recovery partition is labelled 'Windows NT/2000/XP'

Expected results:
one of
a) recovery partition is labelled 'Windows NT/2000/XP or recovery partition'
b) recovery partion is clearly labelled 'vendor recovery partition'
c) this entry is not shown at all (that would be ideal, as recovery can be called with a keypress from POST, after all it is meant as a self help for the user who kept windows but managed to make Windows unbootable)

Additional info:
At least on this box (lenovo ThinkPad x60), the partition type could be used for auto-detection
# fdisk -l /dev/sda

Disk /dev/sda: 100.0 GB, 100030242816 bytes
255 heads, 63 sectors/track, 12161 cylinders, total 195371568 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xed1f86f7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      417689      208813+  83  Linux
/dev/sda2       186157440   195365519     4604040   12  Compaq diagnostics
/dev/sda3          417690   186145154    92863732+  8e  Linux LVM

Partition table entries are not in disk order

(do not mind the order warning, AFAIK the keypress in POST on this box is hardcoded to sda2)

Oh and the partition's content (to show it's really a recovery partition)
# mount -o ro /dev/sda2 /mnt/import/
# ls /mnt/import/
AUTOEXEC.BAT  BOOTSECT.DOS  DOS          IBMDOS.COM    ntdetect.com  peldr        REXX.EXE    TPDIAG2.EXE   TPPLGD14.EXE  TPPLGT1.EXE   TPPLGW12.EXE  WIN51IP
AUTOEXEC.ICR  COMMAND.COM   FINDDRV.BAT  LAUNCHIT.BAT  NTLDR         PLNRCHK.BAT  RXDINFO.RX  TPDIAG.EXE    TPPLGD15.EXE  TPPLGT2.EXE   TPTOOLS       WIN51IP.SP2
BOOT.INI      CONFIG.ICR    HIMEM.SYS    MFGSTAT       PCYCLE.EXE    preboot      SCRREC.VER  TPPLGA10.EXE  TPPLGE2.EXE   TPPLGW10.EXE  VERSION.ID
bootsec.py    CONFIG.SYS    IBMBIO.COM   minint        PDLDR         RECOVERY     swwork      TPPLGD14.002  TPPLGE3.EXE   TPPLGW11.EXE  WIN51
# cat /mnt/import/AUTOEXEC.BAT 
@ECHO OFF
break=off
launchit.bat



# head /mnt/import/LAUNCHIT.BAT 
@ECHO OFF
BREAK=OFF
COPY AUTOEXEC.ROD AUTOEXEC.BAT /Y
COPY CONFIG.ROD   CONFIG.SYS   /Y
cls

call finddrv.bat
prompt PCDR$l$n$g
C:\DOS\MOUSE.COM > NUL
%RAMDRIVE%


maybe looking for traces of WinPE might be a good autodetection.

Comment 1 Mads Kiilerich 2011-12-08 19:33:55 UTC
grub2 relies on the output of os-prober. What do direct invocation of os-prober show?

Comment 2 Patrick C. F. Ernzer 2012-04-18 12:54:09 UTC
bad news, the HD on the machine in question started acting up a month ago and has been replaced. Oddly enough, bugzilla mail tells me the needinfo is from yesterday. Still I should have caught your question in december.

If you do not have a machine with a Windows restore partition at hand, close this as insufficient info. But with some luck there is a fairly new laptop, that came win a Win restore partition, near you.

Alternatively, the dying disk is probably still readable, can I point os-prober at an external disk? If yes, how?

$ man os-prober
No manual entry for os-prober

Comment 3 Mads Kiilerich 2012-04-18 13:05:12 UTC
I guess it requires a machine with a 'Compaq diagnostics' to reproduce the problem. That partition might be based on some windows version, so the entry might not be completely wrong.

AFAIK os-prober can't be controlled and will look at all available devices.

Comment 4 Hedayat Vatankhah 2012-04-18 15:11:58 UTC
Well, AFAIK os-prober does not look at the partition types at all. It looks inside partitions to acquire required information. You probably cannot reproduce this bug in newer laptops with Windows Vista or newer recovery partitions (os-prober works fine to detect my ThinkPad X61 recovery partition). It can find the correct title inside bcd. 
For Windows NT/2000/XP, it looks inside boot.ini to find the title; if failed it'll use the generic "Windows NT/2000/XP" title. Which looks like to be what happened on your old hard disk. I wonder if os-prober should be asked to look at the partition type too.