Wednesday, June 13, 2012

Fedora 17, Lenovo B570, Windows 7 and GPT

I bought a new laptop a few weeks ago. This time the Lenovo B570 which is pretty similar to the G570 I talked about previously.

I had a new challenge with this one. Fedora 17 would not install with the plan I used with the G570 and Fedora 16.  It insisted on having a GPT labeled hard drive because it detected the laptop's EFI support or something but my first problem was the hard drive didn't have enough unused partitions. Since it was an MBR label there was a max of 7 partitions. Windows took up 2, the Lenovo One Key recovery thing took another primary partition and then there was another driver partition as a logical volume. So no primary partitions for Linux and only 3 extended partions left in the middle of the drive. this is of course after following my old steps to shrink Windows' C: drive and move the start of the extended partitions.

After deleting the driver partition I still couldn't satisfy the Fedora installer so I decided to fix this by converting my MBR labeled hard drive to a GPT label and I didn't want to reinstall Windows either so fixing it's ability to boot was going to need to be figured out.

Converting the drive from MBR to GPT

First, I needed to resize the hidden recovery partition at the end of the drive.  Well I could have just deleted it but I decided not to. Turns out GPT need a little bit of room to store a backup copy of the partition so I used a LiveUSB with Fedora 16, installed gparted, selected that last partition and shrunk it. No big deal. Then for safety I dd'd the first 10 MB of my drive to a file on a usb drive so I might be able to roll back to MBR. I didn't care about any data on the drive so I didn't mind being this reckless. So with the last partition shrunk by 250 MB (excessive I know) and a backup of the MBR (and more since 10MB was excessive too) I proceeded to do the conversion. I had to yum install gdisk because the LiveUSB was missing it but then it was as easy as gdisk /dev/sda and then pressing w to write it. The first time I did it I got a warning (before pressing w) about that last partition being too close to the end.
Quit out of that and done. Well sort of. I still needed to install Fedora 17 which went smoothly this time. 

Fixing Window's Ability to Actually Boot

As expected, Windows would not boot anymore. From the GRUB menu I tried the old rootnoverify and chainload to boot to windows but the commands wouldn't work and it seemed to be because the filename format you need to pass to chainload changed by being a GPT drive. I didn't have any idea if that would work anyways and gave up and decided I needed to try to use Windows repair tools to write a new boot record. Turns out I don't have a Windows 7 install disc. The Lenovo recovery media just re-images the drive rather than running Windows 7 and the One Key recovery button was similarly broken. What I did have was a Windows 2011 SBS install disk which was good enough to let me use a command prompt to try to fix it. Between using bootrec /fixboot, bootrec /scanos, and bcdboot d:\windows I was able to get the laptop to offer Windows on the boot menu (F12 at power-on). (And yes it was D:\windows because that's where /scanos found it.)


Windows 7 runs like normal.
Fedora 17 runs like normal*.
The Lenovo recovery button doesn't work.
The hard drive is GPT labeled with 8 partitions.

UPDATE 1: I would recommend you not try this at home. It has issues. One is when Windows Hibernates the system you cannot resume Windows without first booting to Linux and then rebooting if Linux is the default boot target. It skips giving you the option to press F12 for the boot menu. You can't even get into setup. If I can get a clean Lenovo Win 7 Install disc I would probably try reinstalling everything from scratch to see if it fixes things like that. Also, I had no idea what I was doing when I was fixing Window's boot loader with bcdboot so maybe I did it wrongly. The commands had boot in the name and /? showed those options and I just tried them haphazardly. Again I had a full backup of the hard drive so I didn't care about screwing up anything. Actually that's the only issue I've found so maybe it's not such a big deal.

Other update goodness. Fedora 17 KDE is working fairly well. I installed a CAD program and it works well enough when I plug in an external projector however I'm disappointed by the choices of resolution when I try to mirror. It' was a 1080p projector via HDMI so extended desktop works best.

Command (? for help): p
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 86753090-2233-AACC-8888-123456789012
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 554989 sectors (271.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1           10240          411647   196.0 MiB   0700  Microsoft basic data
   2          411648       456042495   217.3 GiB   0700  Microsoft basic data
   3       456042496       456452095   200.0 MiB   EF00  EFI System Partition
   4       456452096       457476095   500.0 MiB   EF02 
   5       457476096       562333695   50.0 GiB    0700 
   6       562333696       574457855   5.8 GiB     8200 
   7       574457856       945829887   177.1 GiB   0700 
   8       945829888       976228351   14.5 GiB    2700  Microsoft basic data


Lorenz Leutgeb said...


I'm currently in a similar scenario. I converted my partition table to gdisk the same way you did, but when trying to install Fedora 17, the installer says "you have not created a stage1 bootloader target device". After some googeling I read that I maybe need a "BIOS boot" partition, so I created a EF02 labelled partition on my drive, but that did not help. Do you have any hints for me?

Thank you!

Chris said...

I didn't have my laptop with me when I wrote that last reply. It seems EFI mode is always on on this model. You didn't say you had the same one but I assumed that when I deleted my previous reply. In any case, if it's an option on your computer, make sure the boot mode is efi or uefi and not bios. Fedora's installer is complaining because bios boot can't boot from gpt normally. Well it can but it needs a little help for GRUB and that's the 1 MB partition it wants to make, the "BIOS boot partition".
Make sure you have enough free space when you run the installer and you should be able to tell it to use remaining free space and if it still needs the BIOS boot partition it should add it itself with the correct size but then don't expect Windows to work with a gpt disk but bios boot. I'm going to update post above with my final partition layout from gdisk.
This link explains what I think is going on: