Tuesday, May 29, 2012

YAHTNG

Yet Another Helping The Next Guy

I bought my son a shiny new Ivy Bridge based Asus laptop from dealnews for high school graduation. Of course, he only runs Ubuntu, but I wanted to keep the Win 7 64 around for flashing BIOS and related reasons (and someday he may need to run some Windows program....)

It's pretty straight-forward to install Ubuntu alongside windows in a dual-boot fashion as the Live installer knows how to do this. But apparently not on some UEFI based systems--or that's what I thought. It turns out, the installer knows how to work with UEFI systems as well. It just doesn't know how to do it on a system with a broken/corrupt/obscured GUID Partition Table (gpt).

I've used gpt for years as I used to work in HP's Itanium Linux lab. And I've seen some GPT tables corrupted before. The ASUS (at least this one) ships with the secondary GPT corrupted. The last partition (I think 5th) somehow extends INTO the secondary GPT. (Think of the secondary as a backup table in case the primary gets corrupted--a failsafe.) This corrupt secondary table makes the partition table unreadable or possibly unusable to Ubuntu (and moreover, to the underlying libparted and the parted utility.)  The installer just "determined" that the disk was unformatted so it kindly offered to just install Ubuntu to this blank disk (destroying all the existing partitions in the process.) Not so good.

I downloaded gdisk (from Universe) as it seems to be designed from the ground up for GPT tables and it was able to read the partition table and show me the partitions. These matched up with what /proc/partitions was showing me (which seemed to be right all along.) It also matched up with what I was seeing in Windows 7. ASUS ships with a C drive, a D drive, and a recovery drive along with the normal EFI system partition (ESP) and a Microsoft Reserved Partition (MSR). So the layout looked something like this:


Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          411647   200.0 MiB   EF00  EFI system partition
   2          411648          673791   128.0 MiB   0C01  Microsoft reserved part
   3          673792       339511295   161.6 GiB   0700  Basic data partition
   4       339511296       925575167   279.5 GiB   0700  Basic data partition
   5       925575168       976773167   24.4 GiB    2700  Basic data partition


Where 3 is C (OS) drive, 4 is D (DATA) drive, and 5 is the ASUS Recovery partition. It is partition 5 that seemed to be the source of the error:


Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.


To resolve this issue, I simply deleted partition 4 and recreated it from the same start point but smaller and ending sooner. Then I dd'd partition 5 to another disk, deleted it and recreated it (same size) but now it ended before the end of the disk. I then restored it via dd.  (The partition Warning! went away as soon as 5 was deleted and did not reappear when it was recreated at a new start sector.)

I failed to grab a snapshot of the final partition table entries but I basically shortened 4 by a couple GiB (and didn't try to "nail" it to exactly 33 blocks shorter.)

Once the GPT table had a functioning secondary GPT, the Ubuntu installer was able to find it without problems. I just used gdisk to make the D partition into a Linux format partition (8300). (There was nothing on the D drive.) The installer did create a GRUB entry for the Win 7 but that doesn't really work. However, using ESC, I can select the Windows partition from the UEFI boot menu and it dual boots just fine.  After the installation was done, I upgraded from the Precise install release bits to the latest bits (including newer kernel) and the grub update worked fine as well--so it seems to be a rock solid dual boot machine now.

Holler if this helps you or if you know more about why ASUS formats the disk this way--there could be an underlying reasons. Oh, and one more thing, I actually did make the Win 7 recovery disks PRIOR to doing any Ubuntu at all and I've not tried to do anything since with the recovery partition.

You can reach me via the comments below or email me at asus DOT dowdberry AT medberry DOT net.

And some final words: Ubuntu Live Installer makes an awesome detective kit and this Ivy Bridge notebook truly rocks.