Installing Windows7 after openSUSE-11.4

My wife installed Windows7 on a PC with openSUSE-11.4 already installed, managing to keep both openSUSE-11.4 and WinXP. This blog discusses what we did as part of this installation.

First, some detail on the hard drive content on my wife’s PC … it has two hard drives: one is a SATA drive and the second is an IDE drive. My wife already had on that PC:

  • Windows7 home trial version on 1st partition of SATA drive [where trial has expired so this is not used]
  • openSUSE-11.4 partitions on the extended/logical partitions of SATA drive
  • Windows XP on IDE drive 1st partition
  • NTFS data partition on IDE drive

The PC uses the openSUSE-11.4 legacy grub as the boot manager.

Her plan was to replace the existing Windows7 home on the SATA with a version of Windows7 professional that she recently purchased.

Backups

Before installing my wife ensured she had data backups. That took no time as she is very good at keeping backups on an external hard drive.

Then we booted to openSUSE-11.4 and I ran some programs to:

  1. backup the sata drive MBR before installing Windows7
  2. categorize her boot manager and partitioning setups so that we understood everything

First, I ran the follow command as a regular user to see what partitions she normally mounts in openSUSE-11.4


df -Th

which yielded:


Filesystem    Type    Size  Used Avail Use% Mounted on
rootfs      rootfs     25G  5.9G   18G  25% /
devtmpfs  devtmpfs    2.9G  268K  2.9G   1% /dev
tmpfs        tmpfs    3.0G  3.7M  2.9G   1% /dev/shm
/dev/sda6     ext4     25G  5.9G   18G  25% /
/dev/sda7     ext4    202G  119G   73G  63% /home
/dev/sdb1  fuseblk    196G   29G  167G  15% /windows/winXPide
/dev/sdb5  fuseblk    271G   79G  193G  29% /windows/data-ide
/dev/sda1  fuseblk    235G  103G  132G  44% /windows/E

Since I knew openSUSE was on the SATA drive, this showed that the sata drive was known as ‘sda’ and that partitions sda6 ( / ), sda7 ( /home ) were allocated to GNU/Linux. The sda1 ( /windows/E ) was her existing unused expired Windows7 home, and that was what she intended to replace. Her WindowsXP was on /sdb1 and she had a data partition (formatted as NTFS) on her /windows/data-ide (the formatting was not obvious with this view).

Then I ran the following command with root permissions to check all partitions:


fdisk -l

which yielded


Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x4f424a0d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63   491733584   245866761    7  HPFS/NTFS/exFAT
/dev/sda2   *   491739136   976773119   242516992    f  W95 Ext'd (LBA)
/dev/sda5       491741184   495941631     2100224   82  Linux swap / Solaris
/dev/sda6       495943680   548378623    26217472   83  Linux
/dev/sda7       548380672   976736255   214177792   83  Linux

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x000a95c3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63   409593239   204796588+   7  HPFS/NTFS/exFAT
/dev/sdb2       409593240   976768064   283587412+   f  W95 Ext'd (LBA)
/dev/sdb5       409593303   976766975   283586836+   7  HPFS/NTFS/exFAT

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0xe8e6ba83

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63   976768064   488384001    7  HPFS/NTFS/exFAT

The presence of sdc1 surprised me ! I took a look and my wife still had an external hard drive plugged in. When I commented on that, she noted she had forgotten to unplug it.

The fsdisk command was consistent with the assessment as to sda and sdb as to where the Windows7, openSUSE-GNU/Linux, Windows-XP, and IDE data partition were located. MOST important was the information that the active partition on sda (the SATA drive, where my wife intended to install Windows7 Pro) was sda2, the extended partition.

I also checked her openSUSE menu.lst (which I won’t repeat here) to see what it had for booting. There was nothing unusual there, other than perhaps the mapping for windowsXP, which I won’t go into (and will be clear from the findgrub command below).

Then as a final check into her grub information, as a regular user I ran a script from please_try_again’s ‘updategrub’ package, where that script is called ‘findgrub’ . One can find that updategrub script by a simple search.


findgrub

to which I was prompted for the root password and after entering that password I was presented with this:


Find Grub Version 3.5.1 - Written for openSUSE Forums

 - reading MBR on disk /dev/sda                       ...
 - searching partition /dev/sda1      (NTFS)          ... --> Windows7/Vista Loader found in /dev/sda1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can add the following entry to /boot/grub/menu.lst :

###Don't change this comment - YaST2 identifier: Original name: WindowsBootLoader###
title Windows on /dev/sda1
    rootnoverify (hd0,0)
    chainloader +1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 - reading bootsector  /dev/sda2   *  (Extended)      ... --> Legacy GRUB  found in /dev/sda2   => sda6   0x83 (openSUSE)
 - skipping partition  /dev/sda5      (swap)         
 - reading bootsector  /dev/sda6      (LINUX)         ...
 - reading bootsector  /dev/sda7      (LINUX)         ...

 - reading MBR on disk /dev/sdb                       ...
 - searching partition /dev/sdb1   *  (NTFS)          ... --> Windows NT/2K/XP Loader found in /dev/sdb1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can add the following entry to /boot/grub/menu.lst :

###Don't change this comment - YaST2 identifier: Original name: WindowsBootLoader###
title Windows on /dev/sdb1
    rootnoverify (hd1,0)
    map (hd1) (hd0)
    map (hd0) (hd1)
    chainloader +1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 - reading bootsector  /dev/sdb2      (Extended)      ...
 - searching partition /dev/sdb5      (NTFS)          ...

 - reading MBR on disk /dev/sdc                       ...
 - searching partition /dev/sdc1   *  (NTFS)          ... --> Windows7/Vista Loader found in /dev/sdc1                                

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can add the following entry to /boot/grub/menu.lst :

###Don't change this comment - YaST2 identifier: Original name: WindowsBootLoader###
title Windows on /dev/sdc1
    rootnoverify (hd?,0)
    map (hd?) (hd0)
    map (hd0) (hd?)
    chainloader +1                                                                                                                    
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Again, the external drive being plugged in (sdc1) can be ignored. This also illustates that sda2 is the active partition on the SATA drive, and illustrates that Legacy GRUB found in /dev/sda2 => sda6

**Backup MBR **

Next, while running openSUSE-11.4, I backed up the Master Boot Record (MBR) of both her sata (sda) and ide (sdb) drives just in case Windows7 were to over write them. to do that backup, I opened a terminal, typed ‘su’ to get root permissions, and then:

to backup ‘sda’ I typed:


dd if=/dev/sda of=MBR-sda-before-win7-440 bs=440 count=1

which created the file MBR-sda-before-win7-440.

and to backup ‘sdb’ I typed:


dd if=/dev/sdb of=MBR-sdb-before-win7-440 bs=440 count=1

which created the file MBR-sdb-before-win7-440.

This backed up the MBR boot information minus the partitioning information. Of note is this backup does NOT backup/record which partition is active.

Note it is INCREDIBLY important to get those command EXACT. GNU/Linux is full of stories/legends of GNU/Linux guru’s who messed up that command and broke their system boot. One needs absolute precision.

I copied the files MBR-sda-before-win7-440 and MBR-sdb-before-win7-440 to a USB stick. Note MBR-sdb-before-win7-440 was not needed but I was being conservative, in case of mixing up sda and sdb in a minute of blindness (I’ve done such a silly mistake before). Hence I had a copy of both MBRs.

… continued …

Install Windows7

Then my wife rebooted to BIOS, confirmed that the DVD reader was set as the initial boot device and that the SATA drive was the primary drive (and the IDE the secondary drive). Then she inserted the Windows7 Pro installation DVD and installed Windows7. She was VERY careful (this is important) to tell Windows7 Pro ONLY to install on sda1 (replacing the existing Windows7 home). Again, this is VERY important as she did not want to wipe out WindowsXP nor openSUSE.

After the Windows7 install was complete, the PC could only boot to Windows7 and could NOT boot to WindowsXP nor to GNU/Linux. My wife then asked that I restore the capability to boot to WindowsXP.

**Restore WinXP/openSUSE/Grub boot capability **

I booted to an openSUSE-12.1 KDE liveCD, and after boot I plugged in the USB stick with the backup MBR files MBR-sda-before-win7-440 and MBR-sdb-before-win7-440. I then backed up the windows7 MBR with the command:


dd if=/dev/sda of=MBR-sda-win7pro-440 bs=440 count=1

and I copied the file MBR-sda-win7pro-440 to the USB stick.

Next, I restored sda (only) with the command:


dd of=MBR-sda-before-win7-440 if=/dev/sda bs=440 count=1

Note it is INCREDIBLY important to get that command EXACT.

At that point after the successful MBR restoration, I made a mistake, and I rebooted the PC

Restore the active partition

To my surprise, the PC booted to MS-Windows7 Pro and did not boot the openSUSE-11.4 legacy grub boot manager. I puzzled for a few seconds, and then I realized I had seen this behaviour before. Most likely MS-Windows7 installer had changed the SATA active partition from sda2 to sda1.

So I rebooted, this time to the gparted liveCD and I ran ‘fdisk -l’ in a terminal session. Sure enough, sda1 now had the asterix next to it, marking it as the active partition. So I ran the partition manager in the gparted liveCD, and in its GUI I changed to boot flag from Windows7pro to the /sda2 (extended partition) on the sda (SATA) drive.

This made sda2 the active partition (which if one looks to my initial checks, was the way this PC was configured at the start).

I then restarted her PC, and the familiar grub boot manager came up and every thing worked Nominal, just as at the start. Overall, pretty painless.

**Footnote **

My wife is not happy with the Windows7 Pro version she received, and she is going to try to return it. She did not use the activation code. My guess is she won’t succeed, but we will see. My wife claims she asked for a German version of Windows7pro, and she ended up with a Deutch version. So all her menu’s are in German and not English. This could be 72 euros down our drain into the pockets of the Microsoft share holders …

Oh well, … such is a day in the life of the oldcpu household.

I was wrong, and she did succeed.

Since she did not use the activation code, and since she immediately returned the Windows7 Deutsche DVD, the shop refunded her money. So she then re-ordered a Windows7 Pro version, this time exchanging emails first with the supplier who confirmed the OEM version she purchased this time was English.

Again, before she installed this version of windows7, I backed up the MBR on her PC’s sata drive with the command:


dd if=/dev/sda of=sda-wifes-pc-MBR-before-windows7 bs=440 count=1

and I placed the file ‘sda-wifes-pc-MBR-before-windows7’ on a USB stick.

She then installed windows7, which in addition to overwriting the MBR on sda , changed the active partition from sda2 to sda1. I should note thou, that Win7 ethernet did NOT work initially (until she installed custom drivers from the manufacturer’s motherboard dvd, and win& graphics quality was poor until she also updated the graphic driver and tuned the resolution there). At that point her PC could only boot windows7 pro (this time it was in English and she was happy - and she registered it with Microsoft).

Then this morning she asked me to restore the MBR to the old version so she could triboot windows7, winXP, and openSUSE-11.4 GNU/Linux.

So I booted to a parted-magic liveCD, and with the gparted application changed the active (boot) partition flag back to its original place before the win7 pro install, … ie from sda1 to sda2. And I inserted the USB stick (that had the backed up ‘sda-wifes-pc-MBR-before-windows7’ file, and I opened a terminal, changed to the directory where the USB stick was mounted, and sent the command:


dd if=sda-wifes-pc-MBR-before-windows7 of=/dev/sda bs=440 count=1

Then I unmounted the USB stick, my wife rebooted her PC, and grub was back, and she was able to boot to WinXP, Win7, or openSUSE-11.4.

As before, ABSOLUTE accuracy is ESSENTIAL in this simple and fast method, else one can really mess up the MBR on their PC. In this case, all is well. :slight_smile:

My wife installed Windows7 Service Pack1 on her Desktop PC.

In the process of doing this, I discovered I was a bit silly in my above blog entry with the ‘dd’ examples. That will be obvious to anyone who looks at the findgrub output in one of my above posts.

It turns out that openSUSE (during its install some time back) did not have Grub on the MBR, but rather had it on /dev/sda2 (where the extended partition is located). Windows7 MBR was in fact still on the MBR. That in fact meant my ‘dd’ command examples above were not necessary, as there was no MBR settings needed to restore. In fact, with the DD commands I was simply re-writing a Windows7 MBR back on top of a Windows7 MBR, and it was the changing of the ‘active partition’ that was doing all the work.

I discovered that mistake in understanding of mine when my wife reported the Windows7 Service Pack1 installs were failing. A look at the windows7 Service Pack installer (SP1) error message told us that Windows7 Service Pack1 required Windows7 to be the active partition for the Service Pack update to work. Since /dev/sda2 (extended partition) was active, my wife could not install SP1.

Now before installing SP1, I not only backed up the MBR (again) but I also ran the script ‘findgrub’ again (where findgrub comes with ‘updategrub’ packaged application/script) and noted there that Windows7 was on the /dev/sda1 and Legacy grub only no /dev/sda2. And finally the meaning of that sunk in to my rather thick skull.

So my wife and I booted to Parted Magic liveCD and flagged /dev/sda1 as the ‘boot’ partition (ie the active partition) and my wife booted to Windows7 with no MBR restoration needed, and she installed Service Pack1. … not with out some problems thou. ServicePack1 kept failing on her, and she had to send Microsoft an email to obtain support. They did provide support, and gave her advice to disable all startup apps (such as Adobe and Google) and download a SP1 version to her hard drive, from which she installed. After probably over > 8 hours struggling with Windows7, she finally got ServicePack1 to install.

Then she called me this morning asking that I restore the legacy Grub boot manager. I did that by booting to Parted Magic live Cd, and :

  • made yet ANOTHER backup copy of her MBR ( yes - call me paranoid and you are probably right), and
  • changed the boot partition from /dev/sda1 (her windows7 partition) to /dev/sda2 (the extended partition which had legacy grub on it)

and rebooted and she had her Grub boot manager back, and was able to select Windows7, or WindowsXP or openSUSE GNU/Linux.

Anyway, my wife’s a happy camper, despite my knowledge on this being less than crystal clear, and having a happy wife is very important. :slight_smile:

I installed Windows7 on a PC keeping openSUSE-12.1 and replacing a trial version of Windows7 that had long since expired (and was not useable). This was my Dell Studio 1537 laptop and the boot manager part of the Install was pretty painless.

This Dell Studio 1537 has a Core2 duo P8400 cpu , 4GB RAM and integrated Radeon HD3450 graphics.

My wife purchased Windows7 Pro (English) for me as a birthday present ( lol ! - but she likes MS-Windows so for her its a good present to give … ) . This was was a Dell OEM windows7 version, and she purportedly obtained it for a good price over the Internet.

Before installing Windows7 I booted to openSUSE and very carefully backed up the Master Boot record with the ‘dd’ command with root permissions


dd if=/dev/sda of=mbr-sda-dellstudio1537-before-windows7-440 bs=440 count=1

and I copied the file “mbr-sda-dellstudio1537-before-windows7-440” that was created to a USB memory stick. I also ran ‘fdisk -l’ to see what was on the hard drive before the install:


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   164616191    82307072    7  HPFS/NTFS/exFAT
/dev/sda4   *   164618055   488392064   161887005    f  W95 Ext'd (LBA)
/dev/sda5       164618118   168827084     2104483+  82  Linux swap / Solaris
/dev/sda6       168827148   210772799    20972826   83  Linux
/dev/sda7       210772863   488392064   138809601   83  Linux

and I also ran findgrub (please_try_again’s script) to check out the MBR information prior to the MS-Windows install:


Find Grub Version 3.6 - Written for openSUSE Forums

 - reading MBR on disk /dev/sda                       ...
 - searching partition /dev/sda1      (NTFS)          ... --> Windows7/Vista Loader found in /dev/sda1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can add the following entry to /boot/grub/menu.lst :

###Don't change this comment - YaST2 identifier: Original name: WindowsBootLoader###
title Windows on /dev/sda1
    rootnoverify (hd0,0)
    chainloader +1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 - reading bootsector  /dev/sda4   *  (Extended)      ... --> Legacy GRUB  found in /dev/sda4   => sda6   0x83 (openSUSE)
 - skipping partition  /dev/sda5      (swap)         
 - reading bootsector  /dev/sda6      (LINUX)         ...
 - reading bootsector  /dev/sda7      (LINUX)         ...

and I noted that the active (boot) partition was /dev/sda4 and also that the MBR still appeared to have the MS-Windows boot loader on it, which I thought to myself should make this easy. My recollection was windows7 prefers to have its partition the active partition, and since I planned to put MS-Windows on partition /dev/sda1, I needed to make THAT the active partition.

So I rebooted the PC to a “Parted Magic” liveCD and used the program gparted on it to change the active (boot) partition from /dev/sda4 to /dev/sda1. I also reformatted the /dev/sda1 to NTFS as I did not want to use any of the ‘trial Windows7’ product. Then I rebooted, this time booting to the Windows7 installation DVD.

I was careful in Windows7 to tell it to install ONLY on /dev/sda1, and the Windows7 installation was pretty uneventful, other than annoying with its VERY slow install and its multiple reboots and its ‘pushing’ of MS-Explorer browser. After its installation was complete (a number of hours later, after many many many windows7 updates) I booted to the same Parted Magic liveCD and I backed up the windows7 MBR, ‘just in case’, with the command:


dd if=/dev/sda of=mbr-sda-dellstudio1537-with-windows7-440 bs=440 count=1

and I copied the file “mbr-sda-dellstudio1537-with-windows7-440” to a USB memory stick. Then I ran gparted and changed the active (boot) partition from /dev/sda1 to /dev/sda4 but I did not touch the MBR, even though I ‘could’ have restored it (with the “mbr-sda-dellstudio1537-before-windows7-440” file).

And I then I rebooted with no CD in the drive.

As expected, the boot went to /dev/sda4 and Grub (from openSUSE-12.1) came up, and I was able to successfully boot to the new (now legally registered) windows7 or to openSUSE.

After the install was complete I booted to openSUSE-12.1 and ran ‘findgrub’ and it was identical which is what I expected:


Find Grub Version 3.6 - Written for openSUSE Forums

 - reading MBR on disk /dev/sda                       ...
 - searching partition /dev/sda1      (NTFS)          ... --> Windows7/Vista Loader found in /dev/sda1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can add the following entry to /boot/grub/menu.lst :

###Don't change this comment - YaST2 identifier: Original name: WindowsBootLoader###
title Windows on /dev/sda1
    rootnoverify (hd0,0)
    chainloader +1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 - reading bootsector  /dev/sda4   *  (Extended)      ... --> Legacy GRUB  found in /dev/sda4   => sda6   0x83 (openSUSE)
 - skipping partition  /dev/sda5      (swap)         
 - reading bootsector  /dev/sda6      (LINUX)         ...
 - reading bootsector  /dev/sda7      (LINUX)         ...

Overall, pretty darn painless keeping my dual boot and openSUSE-12.1.