The wikis are now using the new authentication system.
If you did not migrate your account yet, visit https://idp-portal-info.suse.com/

SDB:Tout sur GRUB

Aller à : navigation, rechercher
Language.png Cette page n'est pas encore traduite (ou pas complètement)

Cet article a besoin d'être traduit. Merci de participer au travail si vous en avez le temps et la compétence.
Si vous cherchez quelque chose à faire, regardez les autres Pages à traduire.



Gérer les installation de Grub

Si vous avez besoin d'aide sur GRUB ou sur le multi-amorçage avec Windows alors poursuivez la lecture de cette page. C'est un article assez long, mais prenez votre temps avec ce sujet difficile. Vous y apprendrez comment gérer / réparer un ordinateur qui utilise GRUB pour démarrer Linux ou Windows. Même si tout vous paraît perdu sur votre ordinateur et qu'il ne démarre plus, il est fort probable qu'il puisse être réparé.

Si vous disposez un ordinateur équipé de Windows et que vous désirez y installer openSuse, la première chose que vous devriez faire est de sauvegarder tout ce que vous ne pouvez vous permettre de perdre. Ensuite, défragmentez le disque C:. Avez-vous peur ? Vous devriez. Microsoft rend l'utilisation d'autre systèmes d'exploitation compliquée. Les images montrées sur cette page proviennent d'une installation sur une machine virtuelle. Les partitions sont donc petites comparées à ce à quoi vous pourriez vous attendre. Mais elles permettent d'illustrer clairement comment les disques durs sont partitionnés et comment on les manipule. Les fonctionnalités expliquées dans ce tutoriel comprennent :

  • Visualiser et gérer les partitions avec Parted Magic http://wiki.partedmagic.com/index.php/Downloads
  • Installation de Windows XP
  • Installation de Windows 7
  • Installation d'openSuse 11.1
  • Basculer le drapeau d'amorçage avec Parted Magic
  • Réparer le code de démarrage de Windows
  • Réparer GRUB avec un Live CD


Comprendre votre disque dur

Voici une image montrant un disque dur typique avec Windows (le vôtre sera certainement différent).

pic1v.png

Il se peut que votre PC équipé de Windows comporte 2 partitions, spécialement les PC de fabricants de matériels d'origine (OEM). Si vous disposez du CD/DVD d'installation de Windows, il est courant de n'avoir qu'une seule partition. Ce tutoriel prendra l'exemple de l'installation de XP sur deux partitions et de celle de Windows 7 sur une seule. Ne vous préoccupez pas de la taille des partitions, les exemples présentés sont issus d'une machine virtuelle et ne sont données qu'à titre d'illustration. Dans la réalité vos partitions seront beaucoup plus grosses.


pic2i.png

Notice the Boot Flag] is the same as the previous picture with just 1 important difference – The boot flag. Once windows is installed that flag will be present. Keep a mental note of that as it is important. Notice how Linux identifies partitions. In this case hda, or more likely sda. Partitions basically divide your Hard Drive in to sections (It's almost like you now have lots of Hard Drives, just smaller. This is a little over simplified but it's enough information for the layman.) Both partitions seen here are Primary, you can have a maximum of 4 Primary partitions on any one drive. Later we'll discuss how, with the use of an extended partition (which is itself a Primary Partition) you can have more than 4 partitions, they just won't all be Primary.

This: Windows_My_Computer is how Windows sees your Partitions. Even though Recovery D: is before XP Local Disk C: in the partition table. If you are a Windows user, stop thinking the Windows way about your Partitions. It is completely illogical and will confuse you in the installation process of Linux.

HD's are seen as sd or hd. Eg; sda1 or sdb1 or hda1

Take sda1: That's how it's seen from the desktop. But to Grub it is (hd0). (hd0,0) = the first partition of the first drive in the partition table.

The computer refers to the second partition of eg: sda as sda2, But to Grub = (hd0,1)

Installing openSUSE 11.1

Let us say then, that we are now preparing to install a Linux distribution and want grub to manage booting of both Linux and Windows. Given the above and if you allow an installation to proceed as I have done in the following picture (openSUSE 11.1), Linux will typically offer the following proposal: NOTE: Parted Magic refers to the partitions as hda, but openSUSE as sda. Just remember in this tutorial eg: sda1 and hda1 are one and the same.

"pic4.png"

If you are an experienced user ignore for a moment any feature of this proposal that you dislike or see as incorrect.

Notice in the section of the proposal 'Booting'. Grub is being placed in hda3 (The extended Partition).

pic5r.png

This is good because it leaves the Windows boot code intact. However, in a moment you will see that the boot flag we mentioned earlier will be moved from hda2 and be on hda3. Sometimes though the installer doesn't get it quite right. In this test case I ran whilst writing this tutorial, the installer did get grub installed correctly in hda3 and also successfully included a Windows option in the boot menu. Here is a picture of the partitions after openSUSE completed installation. Notice the 'Boot' flag we mentioned earlier is now on hda3.

pic6.png

All the space of hda3 and the logical partitions it contains is achieved by shrinking hda2. Yes an extended partition is really just a container for logical partitions which is what hda5 and hda6 are. Logical partitions permit the use of many partitions above and beyond the 4 Primary limit. It's worth mentioning again that BEFORE any installation of Linux takes place, you should de-fragment Windows.

A corresponding picture from Windows shows things a little differently with the boot flag on hda2.

pic7m.png

(Windows is not exactly correct is it.)

More about Grub installation - advanced users

This section also provides guidance that might be useful if grub does not boot properly.

We have already explained that in this example Grub had been placed in hda3 and the installer switched the boot flag over from hda2 to hda3. Which means, when the computer boots the first part it looks to is hda3 and as a consequence the Grub menu appears. Now, just to illustrate the advantage of Grub being installed this way, let me explain: Just for experiments sake – Or if you need to repair Grub: If you were to boot Parted Magic and change the boot flag back to hda2, when you reboot the machine Windows will boot, there will be no Grub Menu. Linux is still installed of course and you will be able to see the partitions in the Computer Management section of Windows. Switch the flag back to hda3 and either Grub Menu appears as before with the option to boot openSUSE or Windows. Or you need to repair grub like this:

If you have a Linux Live CD, boot from it and log in. Then open a console window and enter su and you will be at the command prompt with root powers and ready to proceed. If on the other hand you have the openSUSE install DVD, boot from it and on the first menu of options select the Rescue System option. That will start an elementary Linux Live operating system and bring you to the login prompt. Enter the username root and you will be at the command prompt with root powers and ready to proceed. Whichever way you started (the openSUSE install DVD or a Linux Live CD) when you are at the root command prompt, first you find the partition containing openSUSE's bootloader. Then you reinstall Grub with a pointer to that partition. First find the openSUSE installation:


You enter this ---------------- grub

Computer returns like this ---- grub>

You enter this ---------------- find /boot/grub/menu.lst

Computer returns like this ---- (hd0,5)

Here, (hd0,5) is Grub's pointer to my openSUSE installation. Your pointer will be different from my example (hd0,5). Substitute your values for my example (hd0,5). Now that you have the pointer, proceed like this:

You enter this ---------------- root (hd0,5)

Computer returns like this ---- Filesystem type is ext2fs, partition type 0x83

You enter this ---------------- setup (hd0)

You see several lines like this --- Checking if /boot/grub/stage1 exists ... yes Computer finally returns this-- Succeeded.......Done

You enter this ---------------- quit

You enter this ---------------- reboot


The computer should reboot and present you with the Grub boot menu, from which you can boot into openSUSE or Windows. pic8f.png

Multiple HD's and Grub

This scenario is most likely on a Desktop PC/Linux Box where it's not uncommon to have 2 or even 3 internal HD's. In fact there couldn't really be a more ideal set of circumstances than this, as it permits you the ability to dedicate the MBR of one of the drives to Grub. We have already touched on some slightly complex issues with Grub and we don't want to over complicate it here if we can help it. Writing about Grub is never simple because much more is involved: (Partitioning, Installation, Other Operating Systems.....). If you have 2 HD's and you intend to use a Windows OS, try and dedicate one of the drives to Windows or at the very least let Windows have the first part of the HD. Windows will install it's boot code to the MBR of that HD. Or if you have a Windows PC to which you add a new HD it's probably best to just leave the original HD alone and install everything else to the new HD/HD's. The key to this is in your BIOS. You need to adjust the BIOS so that the New HD is the first HD to boot. Install Linux, but in this case I would always recommend a customized installation, not taking any defaults, but manually partitioning the new HD, setting the mount points to your Windows drive and install Grub to the MBR of the new HD. It's possible the Linux installer will get the chainloader code wrong when it writes the menu for Windows in Grub. But don't panic, Windows is still bootable if necessary, by changing the BIOS settings to put the Windows HD back to first in boot order. But we don't want it this way, we want to use Grub, so we need to tweak the menu.lst file located usually at /boot/grub/menu.lst If there are 2 HD's it may need to something like this:

title WIN XP/Vista/7
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
chainloader +1

or

title WIN XP/Vista/7
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
chainloader (hd1,0)+1

The map function is used when the windows install was originally on a drive 1 and now it's been moved physivally to drive 2. Or an extra sata drive was added and drive 1 became drive 2 -- whatever. So in some cases and original drive 1 has a boot.ini for windows xp on it like this:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOW S
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect


Now here's the reason why you need the map function. The fragment "rdisk(0)partition(1)" means partition 1 of disk 0 But a change has been made since then so it's now really partition 1 of disk 1. So you use the map function to trick the operating system into seeing the physical drive 1 as a fictitious drive 0. And only then xp will boot.

So that's why you need the map function with 98/2000/xp, because of the fragment like rdisk(x)partition(y).

Now here's the rub. Vista uses a different bootloader which doesn't contain the fragment rdisk(x)partiton(y). So it neither uses nor needs a map function. It ignores it. It boots -- it works fine without it because the change of location doesn't matter to the new loader in vista.


If you really want to verify which is the bootloader partition, then find the partition that contains the bootloader files: In Windows 2000/XP they are ntldr, ntdetect.com and boot.ini. Vista's visible bootloader files are bootmgr and the directory boot. The map function is not required in Vista or Windows 7.

title Vista
rootnoverify (hd1,0)
chainloader (hd1,0)+1

or

title Vista
rootnoverify (hd1,0)
chainloader +1

Further detailed information can be found by typing: info grub in a konsole terminal. Or visiting: http://www.gnu.org/software/grub/manual/grub.html

You may also be interested in: http://www.supergrubdisk.org/

and: http://opensuse.swerdna.org/suseboot.html
http://opensuse.swerdna.org/susebootfive.html

More on Windows Vista and Windows 7

Certainly with Vista I know that if you write grub to the MBR, Vista will not install Service Packs. I'm not certain but even if the MBR is untouched and it's just the boot flag that is missing from the Vista partition, Vista may not install Service Packs. If you repair the Windows boot sector with the Windows CD/DVD or if grub isn't on the MBR, just switch the boot flag back in favour of Windows, then you should be able to install Service Packs. If you are missing a Windows Vista DVD Vista Repair DVD Once done, you can re-install Grub as explained earlier. Windows 7 seems to be following the traits of Vista in multi-boot environments. It had the bootmgr file. But I have been unable to test Service Pack installation in Windows 7.

I ran a test case install of Windows 7 and then let openSUSE installer do it's stuff. As I expected openSUSE managed it perfectly. It shrank Windows, created an extended partition from the acquired space and created 3 partitions inside the extended space. Here are a sequence of screens:

Finally

In preparing this tutorial I have actually tried and tested all these steps. Personally I always setup my partitioning manually and use the MBR for Grub. But this guide focuses on what the installer will do if you let it do it's thing! Consistently, users report issues as a result of a default install. I have tried to be a complete 'Numpty' and get the whole install 'Borked' – But, honestly, SUSE is very good at getting it right.


Credits: @swerdna (snippets included from his tutorials)

Supplemental information for advanced users

You may or may not be aware that it is possible to install Windows (XP, Vista, 7) in a Logical Partition. But you must have a suitable primary partition where Windows can place it's boot code. The following is a copy of a test case I ran for one of the other moderators:


I started by creating the partitions with Parted Magic.
500MB NTFS Primary
19.7GB Extended

  • 500MB swap
  • 5.8GB root ext3
  • 1.2B /home ext3
  • 12GB NTFS for Windows 7

I then used a WIN XP disc to format the prepared Windows 7 partition to NTFS again. (This might not be necessary, but in previous tests I have found Windows, whilst it will see the NTFS partitions created by Parted Magic, there is something it does not like and so refused to install).


Then booting Windows 7 I get to the point where it reads and lists the partitions. You will notice it's rather inadequate presentation: 1initiallpartitionsasse.png

The install proceeded and completed eventually arriving at the W7 Desktop.

Next I boot Parted Magic see:

2w7installedinlogical.png


Windows 7 is installed and the boot flag is on hda1 just as expected. I mounted hda1, open it in a file browser and see this W7 Bootcode:

w7bootcodeinhda1.png


Now I boot openSUSE 11.1 DVD and manage the partitions manually as seen in this picture:

3partitionssuseinstalle.png

I set a mount point for Windows 7. The reason for the manual setup: the openSUSE installer made a Pigs Ear of the proposal so I went manual. The final proposal, including the 'Booting' info is in this Picture:

4installbootingproposal.png

Notice that grub is shown in the proposal as going to hda2 (the extended partition) – I accept this and allow the install. The install and final config completes and we arrive at the openSUSE Desktop.


Post SUSE Install Parted View:

postsuseinstallpartitio.png


Reboot and from the unaltered menu which the openSUSE installer put in /boot/grub/menu.lst I select Windows and it works. The entry in menu.lst is:
rootnoverify (hd0,0)
chainloader +1


OK. So I'm thinking, what if grub were to MBR. So I manually do this, include a Windows entry in the menu the same as above. Reboot openSUSE is fine – Windows 7 is fine.


The conclusion then, is much the same as @swerdna (John) and I were finding with the tests we ran on XP. You can install Windows 7 in a logical partition – but you do need a suitable partition for Windows to place it's boot code. Windows 7 and Vista appear to be very similar in the way they install and manage booting, I can't be certain they are identical. I'm also not certain of one other aspect: When the MBR is not disturbed and grub is solely to the extended, whether Windows 7/Vista will allow service pack installs. But my suspicion is No. Because the boot flag is to extended. The way Windows now manages Service Pack installs it expects to find the boot flag on the Windows boot partition. An error occurs during the inevitable reboots that take place, which of course hands booting back to grub and whilst grub then loads Windows and the Service Pack resumes it errors out. In my tests I had no trouble restoring the MBR and Windows Boot Code, re-installing grub and changing boot flags. You can pretty much do what you like. My only concern is that this is all a little too complex for your average user. I have not pursued alternative booting methods that would better satisfy Windows limitations.

This article is transferred from: All About Grub.