Friday, September 28, 2012

Thinkpad T420s - cool if you know some tricks :)

This will be just a short post to add a few ideas about how modern Thinkpad notebooks are booting into Win7 and how you can best add a Linux boot to that.

There is a huge lot of valuable information at ThinkWiki - but that information is kind of dated and might not be able to provide now enough clarity for people without a huge previous experience with Thinkpad notebooks.

The first idea that is not well explained upfront is that the Master Boot Record / Partition Table in T420s notebooks (and probably other similar models with Windows 7) is some sort of a "proprietary boot manager for IBM/Lenovo" which I will call BMGR for the rest of this post - if you are more familiar with Linux think of it as a completely different kind of GRUB (or LILO, or EXTLINUX). It is a far different program than any of the Linux boot managers - for instance all those above use a text-file configuration somewhere in one of the partitions, while BMGR is using some kind of a binary configuration / extension located in the first 8 (in some instances it might have been even 16) sectors of the disk - so the MBR + 7 (or 15) sectors (512-bytes standard sectors). The bottom line is that you do not have there a dumb small/standard DOS boot-sector, but something a little bigger.

In the original partition table the modern Thinkpads now have at least 3 NTFS partitions - one "System" partition (where the actual Win7 boot loader is located, partition that I believe might be normally hidden or named S:), the standard Windows_OS partition (where the system is located, but which is called by Microsoft "Boot" = C: ) and another NTFS-formatted partition (Lenovo_Recovery) which I believe appears as drive Q in Windows and where you have the original installation / recovery image from which your Win7 can be reinstalled "from clean" - those are contained in some WIM files and can be written currently on 1 CD + 3 DVD writable disks - which is something that you should absolutely certainly do as the very first thing after you get your Thinkpad! Since I am a little paranoid I also made a second copy of that - the original program only lets you write one, but of course it can not stop you from later making a duplicate of that disk:)

So why are all this relevant? Well, mainly since now BMGR can do some extra tricks - if you press the blueish ThinkVantage button before the Windows loader starts you will be taken to a separate "Restore and Recovery mode" - a Windows RE (Recovery Environment), which is an extension of the older Windows PE (Preinstallation Environment) in which you have programs that can let you do minor repairs or even a backup / restore (including a full restore to the original "clean configuration"). All that stuff is basically booted from the first partition (SYSTEM, S:) but to restore things to original configuration it will use two very large files from Q: (Lenovo_Recovery). And if you also get a new version of the Rescue and Recovery program you can also do some specific recovery from inside that mode!

Another trick is that on the small SYSTEM partition you have another small WinRE boot target, which can be automatically started if Windows fails to boot normally - in that environment you have the pretty standard "System Recovery" for Windows 7, but since this one (unlike most default Win7 installations) is also in the separate SYSTEM partition (which is very, very rarely written to) chances are that it could come handy more than once (for a CHKDSK or even when a very bad driver is installed and Windows no longer starts).

The problem is that the installation of the Windows-based part of 'ThinkVantage Rescue and Recovery" (v4.5, which is not small and on my computer was not preinstalled) REQUIRES the presence of BMGR - and if BMGR was replaced with something else (for instance GRUB) that R&R installation will fail! So as a bottom line on this one - if you really want R&R - install that one very early!(the program is OK if you do not have something better, but IMHO it looks somehow slow since it does not seem to take full advantage of NTFS "tricks" like shadow copy and restore points).

And that gets us to the multiple-boot Linux problem - in case you still want all the above features you can not let GRUB/LILO/EXTLINUX go and overwrite the MBR (which is the normal thing to do when you have a "dumb boot sector" there) - in case you already installed for instance GRUB you can restore the old Lenovo BMGR (with a little work, maybe I will do a separate post about that), but IMHO the ideal configuration is one where you place GRUB in the boot sector of the Linux partition and you just add a second entry to the normal Win7 boot menu with BCD or EasyBCD (you can call that entry Linux or Grub) - I actually added with BCD an entry for Grub4DOS and then I chained that one to the GRUB2 from my Mint13 installation - which I have to say that was installed pretty well and I got Compiz working just fine!

But more about that kind of stuff in a later post :)