Help!!! Grub is gone after vista install. How get grub back?

Heelp!!

I had opensuse 11.0 installed and was very pleased about it. But since I need windows for school now and then, I installed Windows Vista. I’m having bad feelings about it already since I lost grub and thus can not boot into opensuse anymore. Noooooo!

I knew this was going to happen, but back in suse 10.2 and 10.3 you could just throw in the installer cd, click install and instead of selecting new install you could click “repair existing system”. From there you could simply reinstall the bootloader. Now with the new 11.0, the live cd doesn’t have this option so I do not now how to get grub back. Please help! All solutions will do, I do not mind losing vista, but I really want my opensuse back!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Download CD1 (or DVD1) of opensuse 11 and there should be a ‘Restore’ or
‘Repair’ option that will help you with Grub. In the future never
install windows after Linux as it always trashes the system this way.

Good luck.

suskewiet wrote:
> Heelp!!
>
> I had opensuse 11.0 installed and was very pleased about it. But since
> I need windows for school now and then, I installed Windows Vista. I’m
> having bad feelings about it already since I lost grub and thus can not
> boot into opensuse anymore. Noooooo!
>
> I knew this was going to happen, but back in suse 10.2 and 10.3 you
> could just throw in the installer cd, click install and instead of
> selecting new install you could click “repair existing system”. From
> there you could simply reinstall the bootloader. Now with the new 11.0,
> the live cd doesn’t have this option so I do not now how to get grub
> back. Please help! All solutions will do, I do not mind losing vista,
> but I really want my opensuse back!
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIpIP93s42bA80+9kRArOCAJ9Z2TYscwBfge2ZPSQoS5gQXjGH/QCfbbrz
+PeztyPRYXQCBI1O6Lj/j0o=
=ruuX
-----END PGP SIGNATURE-----

That option is just not on the live CDs… It’s always been (and hopefully will always be) there on the install CDs/DVDs… Or you can look into using GRUB from the command line :slight_smile:

You can do what you need to with the live-CD. There is a very simple solution, but AND THIS IS CRITICAL this particular solution ONLY works if SuSE and Vista are on the same disk AND SuSE is on a “primary” partition. That is likely, it is also likely that you installed Vista on another primary. That is, neither SuSE nor Vista is installed on a “logical” partition; correct? If so, proceed. If not, post back your fdisk -l indicating what is installed where, and we’ll give you a different solution.

When Vista installed, it did not change the MBR because boot code was already there. Even if it did, it won’t matter. What matters is that Vista set the “bootable flag” on its primary, making that partition the “active” partition. The MBR code is simply looking for the active partition, and then handing-off to the boot sector in that partition. So the solution requires (1) installing grub in the boot sector of the openSUSE partition and (2) disabling the bootable flag on the Vista partition and (3) enabling the bootable flag on the openSUSE partition.

First, you need to know which partition openSUSE is installed on, in grub numbering which begins with a zero. So partition 1 equals grub 0, and so on. Boot into the live-CD, open a terminal window, su to root, and run grub. You’ll go into the grub shell. Do this, where “x” is the partition number in grub speak:

root (hd0,x)   
setup (hd0,x) (hd0,x)
quit

That told grub where its boot loader files are located (root), and told it to intall itself in the boot sector of that same partition. Be sure to “quit”. Then do:

cfdisk /dev/sda

Cfdisk is an alternative fdisk which works in ncurses mode. You will see a column named “bootable” (or “boot flag”, don’t remember the exact wording). There will be an asterisk next to the Vista partition. On the bottom of the screen are functions keys, you use the tab key to move between. The first is for the bootable flag; it toggles the flag on/off for the highlighted partition. Highlight (arrow keys) the Vista partition and toggle off the flag, then highlight the SuSE partition and toggle it on. Then tab over to the save key, hit enter to save the changes.

Reboot the system. You should now go into the openSUSE boot menu. You will need to add a chainloader stanza to boot Vista.

If by chance neither openSUSE nor Vista boots, boot again the live-CD, get back into cfdisk, and toggle the Vista partition boot flag back on, toggle the openSUSE flag off. You will then re-boot back into Vista.

Thanks for the replies!

I do have windows and susy installed on the same disk but I am not sure whether they are installed in a primary partition. fdisk -l:

Device Boot Start End Blocks Id System
/dev/sda1 * 1 18154 145820672 7 HPFS/NTFS
/dev/sda2 18155 30595 99932332+ c W95 FAT32 (LBA)
/dev/sda3 30596 38913 66814335 f W95Ext’d(LBA)
/dev/sda5 30596 30857 2104483+ 82 Linux swap / Solaris
/dev/sda6 30858 33468 20972826 83 Linux
/dev/sda7 33469 38913 43736931 83 Linux

What worries me is the “extended” type of sda4 in yast-partition. This doesn’t sound very primary to me but I am not sure about this. How can I know for sure if all partitions are primary?

I meant sda3 has extended type, sda4 doesn’t exist;-)

There can only be 4 primaries. There can be less, but no more. One of those can be an extended, inside which are the logical partitions. Usually the 4th primary is used as the extended, but any of the 4 can be. The first logical is always number 5 in the table, regardless of which primary was used as the extended. That’s why you have no #4; #3 was used as the extended. Vista is on the first primary, and it is the active “bootable” partition (note the asterisk). openSUSE is probably on the 5th partition, number 6 in the table, and it is a logical. IIRC correctly, generic MBR boot code cannot chain within the extended down its logicals, it can only go as far as the 4 primaries (and the extended can never be the “active” partition because it is not an actual physical partition, it is a container). So, as I posted previously, the simple method used by Windows with the bootable flag, will not work in this case.

What is required instead is to install grub stage1 to the MBR with a pointer to the location of grub stage2 (the loader), which in your case is on partition #6. Boot the CD, get into the terminal, su to root. None of the partitions are mounted, and AFAIK don’t need to be for this; grub can internally mount and read linux file systems. So first, do:

cat /boot/grub/device.map

You should see a line with:

(hd0)   /dev/sda 

Then run the grub shell, just the command “grub”. You will then get a different prompt. I’m not 100% positive how grub numbers the partitions when a number (your #4) is skipped. So ask grub where it is located. Do:

find /boot/grub/stage2

You should get something back like: (hd0,5). Then give the command “root” followed by what grub just returned, in this example, the (hd0,5). Thus:

root (hd0,5)

Grub should then return a message “Filesystem type is ext2fs”. That means it has found and mounted the linux partition. Then do this, with the (hd0,5) being whatever you used above on the root line:

setup --stage2=/boot/grub/stage2 (hd0) (hd0,5)

This tells grub to install itself in the MBR of /dev/sda and to point to its loader at /boot/grub/stage2 in partition #6. Then do:

quit

This is important; grub must do cleanup to finish its work.

Now, you need to mount the openSUSE partition and, if necessary, modify the grub menu.lst file. So:


mount -t ext3 /dev/sda6 /mnt
cd /mnt/boot/grub
gedit menu.lst

Now check the boot stanza. The root line should point to (hd0,5), or whatever you used above in the grub shell. On the kernel line it should have “/boot/vmlinuz-xxxxx” (whatever the filename is) followed by “root=/dev/sda6”. The initrd line should simply be “initrd /boot/initrd”. Save that. Then reboot the system. You will have to add a stanza to menu.lst to boot Vista, thus:

title Windows Vista
rootnoverify (hd0,0)
chainloader +1

Give it a try. Be precise! Good luck.

Well I have some good news and some bad news. The good news is that grub is back and I can launch opensuse succesfully. The bad news is suse can’t mount my windows partitions anymore. This is a big problem for the fat partition since that partition has all my data. Here is some of the bootlog:

Boot logging started on /dev/tty1(/dev/console) at Fri Aug 15 01:36:39 2008

Creating device nodes with udev
Trying manual resume from /dev/sda5
Invoking userspace resume from /dev/sda5
resume: libgcrypt version: 1.4.0
Trying manual resume from /dev/sda5
Invoking in-kernel resume from /dev/sda5
Waiting for device /dev/disk/by-id/scsi-SATA_Maxtor_6V320F0_V60SJM5G-part6 to appear: ok
fsck 1.40.8 (13-Mar-2008)
[/sbin/fsck.ext3 (1) – /] fsck.ext3 -a -C0 /dev/disk/by-id/scsi-SATA_Maxtor_6V320F0_V60SJM5G-part6
/dev/disk/by-id/scsi-SATA_Maxtor_6V320F0_V60SJM5G-part6: clean, 202915/1313280 files, 1465178/5242880 blocks
fsck succeeded. Mounting root device read-write.
Mounting root /dev/disk/by-id/scsi-SATA_Maxtor_6V320F0_V60SJM5G-part6

Boot logging started on /dev/tty1(/dev/console (deleted)) at Fri Aug 15 03:36:44 2008

done
Starting udevd: done
Loading required kernel modules
doneActivating swap-devices in /etc/fstab…
donemount: according to mtab, /dev/sda6 is already mounted on /

Setting up the hardware clockdone
Activating device mapper…
done
Waiting for /dev/disk/by-id/scsi-SATA_Maxtor_6V320F0_V60SJM5G-part4 . no more events
Checking file systems…
fsck 1.40.8 (13-Mar-2008)
/dev/disk/by-id/scsi-SATA_Maxtor_6V320F0_V60SJM5G-part7: clean, 57914/2736128 files, 2883821/10934232 blocks
donedone
Mounting local file systems…
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/sda7 on /home type ext3 (rw,acl,user_xattr)
$LogFile indicates unclean shutdown (0, 0)
Failed to mount ‘/dev/sda1’: operation not supported
Mount is denied because NTFS is marked to be in use. Choose one action:

Choice 1: If you have Windows then disconnect the external devices by
clicking on the ‘Safely Remove Hardware’ icon in the Windows
taskbar then shutdown Windows cleanly.

Choice 2: If you don’t have Windows then you can use the ‘force’ option for
your own responsibility. For example type on the command line:

        mount -t ntfs-3g /dev/sda1 /windows/C -o force

Or add the option to the relevant row in the /etc/fstab file:

        /dev/sda1 /windows/C ntfs-3g force 0 0

NTFS signature is missing.
Failed to mount ‘/dev/sda2’: invalid argument
The device ‘/dev/sda2’ doesn’t have a valid NTFS.
Maybe you selected the wrong device? Or the whole disk instead of a
partition (e.g. /dev/hda, not /dev/hda1)? Or the other way around?
mount: special device /dev/disk/by-id/scsi-SATA_Maxtor_6V320F0_V60SJM5G-part4 does not exist

In your first post you indicated you installed Vista after you installed openSUSE, yes? But I notice Vista is on the 1st partition and your vfat is on the 2nd. Did you create these partitions in advance? If so, with what? Or with Vista? What I’m getting at is that Vista partitions differently than any other prev version of Windows (isn’t that a neat little secret, though?), and that has caused problems.

What does your fstab look like?

And, have you run chkdisk from Windows against both of those partitions?

Glad you got your booting back the way you wanted.

> In your first post you indicated you installed Vista after you installed
> openSUSE, yes? But I notice Vista is on the 1st partition and your vfat
> is on the 2nd. Did you create these partitions in advance?

is it possible (my GUESS):

  • he had a computer with Vista on it…

  • he installed openSUSE and never ever watched the screen during boot while it
    defaulted to boot SUSE (not watching, he didn’t notice the ability to SELECT
    SUSE or Vista), so he installed blah blah…

just a guess: he didn’t need help…he just needed to boot to Vista when he
wanted to…


DenverD (Linux Counter 282315) via NNTP crafted by Thunderbird 2.0.0.14 in KDE
3.5.7 under SUSE Linux 10.3 2.6.22.18-0.2-default #1 SMP i686 athlon

Thanks for the help mingus725, changing my fstab solved the issues!

Oh and for Denver: Nice guess but not correct:). Here’s the history:

First installed windows xp, afterwards installed opensuse. Then xp grow to slow and bloated so I needed to format. Thus I decided it was time to give vista a try so I installed that instead of xp. Then grub was gone…

I’m am now trying to install xp as well, thus triple booting. Hope it will work!

Crap!

After installing xp I did the grub trick again and everything seemed fine. I could boot suse and windows partitions are mounted, including the new xp partition. But then I tried to boot xp (which didn’t installed completely, after first reboot it tells bootloader gets corrupted) and it just doesn’t boot. Worse vista doesn’t boot anymore too, the only os booting is linux.

This is what I see after booting vista in grub:

rootnoverify (hd0,0)
chainloader (hd0,0)+1

and for xp:

rootnoverify (hd0,1)
chainloader (hd0,1)+1
bootmgr is missing
press ctrl-alt-del to restart

this is my new fdisk -l:

Device boot start end blocks ID System
/dev/sda1 * 1 7834 62918572 7 HPFS/NTFS
Partition 1 doesn’t end at cilinderboundary.
/dev/sda2 7834 13055 41943040 7 HPFS/NTFS
Partition 2 doesn’t end at cilinderboundary.
/dev/sda3 18155 30595 99932332+ c W95 FAT32 (LBA)
/dev/sda4 30596 38913 66814335 f W95 Ext’d. (LBA)
/dev/sda5 30596 30857 2104483+ 82 Linux swap
/dev/sda6 30858 33468 20972826 83 Linux
/dev/sda7 33469 38913 43736931 83 Linux

Ok I’m confused right now. I deleteted both xp and vista partitions again, then reinstalled xp on first primary partition. And still I’m not able to boot xp! What’s going on here? I’m not forced to install vista bootloader because I installed vista once am I? This m$ sh$t is starting to annoy me.

First, take a read at this site Multibooters - Dual/Multi Booting With Vista

If you are going to be working with partitions and re-installations and boot managers, it’s critical you understand how the XP and Vista boot process differs, and - especially - how the partitioning is different and the problems that can arise from that. So at the above site read the explanation of multi-boot (it’s the clearest I’ve seen to date), the Vista bootmgr/bcd, and Vista partitioning. Follow his links to the MS kb’s that describe some of the issues. Note his advice to pre-partition with XP. Also, if you install Vista, you are going to need to install XP first, and you are going to be forced to let Vista take over the Windows booting process.

The error msg you got “bootmgr is missing” will be clear after reading the above. In short, there is a small piece of code in the Windows “system volume”, which is whatever primary partition is marked “active”, i.e., the bootable flag in the partition table is set. In XP, that code will call ntldr. In Vista, that code will call bootmgr. So your error indicates that the boot sector code in the active partition is the Vista code and it cannot find the Vista bootmgr. Furthermore, depending on how the partitions were created, that could also be throwing off or confusing the chain, although I think in that case you would probably get a diff error message. I’m pretty sure after you’ve read the above you’ll have a good idea how to approach what you want to get done. Note the fdisk msg “doesn’t end on a cylinder boundary” - that may be an important clue (again, ref above).

And repeat after me, "Steve Ballmer is my friend, Steve Ballmer is my friend, Steve . . . " :sarcastic:

Thanks for the link, very interesting. I didn’t read it entirely yet but here is what I think went wrong:

I followed a tutorial where it was adviced to use vista’s partitioning tool to create a new partition for the xp install. Your link tells me this is strongly discouraged and can cause that cilinder boundary thing. I still am not 10% sure though on how to do a triple boot. Here are my thoughts:

  1. I don’t want to reinstall linux by any means, since I spent too much time customizing it. So the linux partitions stay put.

  2. I need to install windows starting with the oldest version. This means first install xp. (hopefully it will work now after deleting the vista created partition).

  3. After xp I install vista. First make sure the partition where I want it to install is the active one so all files are put in the vista partition and no files are stored in xp partition. I assume I can use cfdisk for this? Then I need to install vista from within xp so vista doesn’t take over the c: drive.

  4. Then I’m a bit confused about this bootmanager thing. Appearantly windows should have it but I have never seen one. What I actually would want is no windows bootmanager but just grub from where I can select xp, vista and opensuse. Is this possible because after a quick look I didn’t find any information on this in the link you sent. Googling didn’t help much neither.

Ok I finally got the triple boot working. The only downside is I first have to select windows from grub, then windows bootloader shows up, then select windows version. Setting both xp and vista in grub doesn’t seem to work.

I do found some contradiction in the article about multi boot with vista. First he says that it is better to install vista from xp, this way vista doesn’t take over the c: but uses the next label like d:

Later he tells it is better to not let vista interfere with older windows partitions. For this you should make the vista partition the active one. Ok to me, but then he adds that this only works if you boot from dvd, not installing from within xp. Boing?! Seems you have to choose which I found kindof lame. Indeed I installed from xp and vista placed some boot stuff in the xp partition…

Thanx for the help everyone!

Thanks for the link, very interesting. I didn’t read it entirely yet . . .

I would do so before proceeding. This is complex, and one mistake can create a lot of difficulty. I encourage you to understand the process and its mechanics, and the associated issues, first.

I followed a tutorial where it was adviced to use vista’s partitioning tool to create a new partition for the xp install. Your link tells me this is strongly discouraged and can cause that cilinder boundary thing.

Yes, there is conflicting advice. If you haven’t already, read the MS kb’s. There appear to be scenarios where if you go at it from the XP side or the Vista side, either way you can get into trouble. There is a link to another site where a guy analyzed the problem MS limits to only logical partitions, and makes the case that it could be more severe than MS is indicating. My view is that MS itself is still figuring some of this out; they were so far behind the eight-ball to get Vista to market, it already had so many associated problem - this stuff has been bubbling up after release. What does seem to be valid though is the advice to have XP make the partitions, because Vista can accomodate the XP rules, whereas XP cannot accomodate Vista.

  1. I need to install windows starting with the oldest version. This means first install xp. (hopefully it will work now after deleting the vista created partition).

IMO you should delete all the Windows partitions, and then have XP create the partition for itself and then create the Vista partition using all the remaining unallocated space. You can do this within the XP installer.

  1. After xp I install vista. First make sure the partition where I want it to install is the active one so all files are put in the vista partition and no files are stored in xp partition. I assume I can use cfdisk for this? Then I need to install vista from within xp so vista doesn’t take over the c: drive.

No, this is not going to work. You need to install XP on its C drive, the first partition. Then install Vista on what will be XP’s D partition. Windows stores “drive” (actually, partition) letters in its registry plus in the disk signature of the matching partition in the MBR table. Vista will see that partition is assigned D, and will use that. I’m not sure what you are doing with that FAT partition, but probably XP will use whatever drive letter is in its disk signature and assign another letter to the Vista partition. It doesn’t really matter. Vista will use the letter that XP assigns.

Then Vista will create the BCD in a folder named “boot” in the C root directory. It will install its boot sector in the XP partition, and mark the XP partition as active. XP will have put its bootstrap in the MBR; you cannot prevent this. Vista will leave that there. At boot, the Vista boot sector in the XP partition will start the Vista bootmgr program with a menu to select Vista or XP. If XP, Vista will call ntldr, if Vista, it will call winloader in the Vista Windows directory.

Once this is all done, go back to the instructions above and reinstall grub in the MBR as before. You cannot change the bootable flag on the SuSE partition because it is on a logical, so you must use the method in my post #7. Change your menu.lst entry for Windows from “Windows Vista” to “Windows Menu” because when you chainload you will get the Vista bootmgr’s menu, from there choosing Vista or XP.

  1. Then I’m a bit confused about this bootmanager thing. Appearantly windows should have it but I have never seen one. What I actually would want is no windows bootmanager but just grub from where I can select xp, vista and opensuse. Is this possible because after a quick look I didn’t find any information on this in the link you sent. Googling didn’t help much neither.

As explained just above, my post #7 will get you back the grub loader. The XP and Vista bootloaders are there, trust me. The website I linked explains each link in the boot chain in XP vs Vista, and how the process flows when both are on the machine. This is what will happen after you chainload from SuSE to the Windows boot sector.

You apparently were writing about when I was, and did essentially what I posted. And, no, you can’t individually boot XP and Vista from SuSE, as I explain above - you must chainload to the single boot sector and loader (bootmgr) which handles both. That is just how it works with XP/Vista on the same machine, period. Glad it’s all straightened out for you.

I too had quite a bit of trouble dual booting vista and suse, I found a much easier solution is to run VMWare in Linux and have a Windows VM… Mind you it can be slow at times if you don’t have a dual core processor with the virtualization flag. Also, you can have as many VMs as you need(just don’t run them all at once), so running Vista and XP is a snap.

To find out if you CPU supports it:

egrep '(vmx|svm)' /proc/cpuinfo

If you plan to use it, make sure you turn on “full virtualization” in your BIOS(if your CPU supports it). But depending on how much you use windows, you may find it runs fine even if your hardware doesn’t support it. One more important thing to note is that you can’t really use 3D… Although the new beta version of VMWare (6.5) is supposed to have better 3D support.

For transferring files between your host(Suse) and VM(Windows), I recommend WinSCP.

Hope this helps!!