Processus de boot à partir d'un disque dur

Résolu/Fermé
Cosm8 Messages postés 107 Date d'inscription mardi 15 janvier 2013 Statut Membre Dernière intervention 19 mai 2014 - Modifié par Cosm8 le 2/07/2013 à 12:10
Cosm8 Messages postés 107 Date d'inscription mardi 15 janvier 2013 Statut Membre Dernière intervention 19 mai 2014 - 3 juil. 2013 à 14:06
Bonjour,
Y a des choses que je ne comprend pas.
On me dit que lors du boot le BIOS va consulter le MBR du disque et voir si le nombre magique 55AA existe puis lance les 446 premiers octets.
Alors Quand il y a plusieurs systèmes installés sur différentes partitions avec des bootloader différents. Lequel se trouve dans le MBR (celui de linux ou celui de Windows par exemple) ?

A voir également:

2 réponses

MrYAU31 Messages postés 3808 Date d'inscription samedi 23 février 2013 Statut Membre Dernière intervention 8 juillet 2017 1 613
2 juil. 2013 à 12:13
Bonjour,

C'est celui du Bootloader ;-)
1
Cosm8 Messages postés 107 Date d'inscription mardi 15 janvier 2013 Statut Membre Dernière intervention 19 mai 2014 5
2 juil. 2013 à 12:37
Je ne comprends pas très bien.
Tu peut être plus précis
0
MrYAU31 Messages postés 3808 Date d'inscription samedi 23 février 2013 Statut Membre Dernière intervention 8 juillet 2017 1 613
2 juil. 2013 à 12:53
Alors Quand il y a plusieurs systèmes installés sur différentes partitions avec des bootloader différents. Lequel se trouve dans le MBR (celui de linux ou celui de Windows par exemple) ?

Ce n'est plus un des OS qui se trouvent dans le MBR mais le bootloader qui te permettra de choisir ton OS.
0
Cosm8 Messages postés 107 Date d'inscription mardi 15 janvier 2013 Statut Membre Dernière intervention 19 mai 2014 5
2 juil. 2013 à 12:58
Ah!
Et d'ou vient ce bootloader ?
0
MrYAU31 Messages postés 3808 Date d'inscription samedi 23 février 2013 Statut Membre Dernière intervention 8 juillet 2017 1 613
2 juil. 2013 à 13:01
Sur les OS récents, quand tu installes un second OS, il va détecter la présence d'un premier. Il te proposera alors d'écraser l'OS existant ou de créer un multi-boot. Si tu choisis le multi-boot, c'est lui qui se charge de l'installer.

Mais tu as toujours la possibilité d'en installer manuellement.
0
Cosm8 Messages postés 107 Date d'inscription mardi 15 janvier 2013 Statut Membre Dernière intervention 19 mai 2014 5
2 juil. 2013 à 13:14
Merci,
1) Je connais Grub, Lilo, ... pour Linux
Mais Windows permet il le multiboot du type Windows/Linux ?
2) Si un OS monopolise le MBR, comment peut on booter l'autre système
0
scaravenger Messages postés 2685 Date d'inscription mercredi 28 mai 2008 Statut Membre Dernière intervention 30 janvier 2015 617
2 juil. 2013 à 14:13
Les 440 premiers octets du MBR contiennent le code exécutable de l'OS qui sera lancé.
0
Cosm8 Messages postés 107 Date d'inscription mardi 15 janvier 2013 Statut Membre Dernière intervention 19 mai 2014 5
2 juil. 2013 à 15:08
Un "programme-lien" vers l'executable plutôt ;-)
0
MrYAU31 Messages postés 3808 Date d'inscription samedi 23 février 2013 Statut Membre Dernière intervention 8 juillet 2017 1 613
Modifié par MrYAU31 le 2/07/2013 à 18:53
Non... C'est juste une adresse mémoire.

le micrologiciel BIOS charge les 512 premiers octets de ce disque, ces 512 octets constituant le MBR. À partir des informations du MBR, il détermine l'emplacement du chargeur d'amorçage.
0
Cosm8 Messages postés 107 Date d'inscription mardi 15 janvier 2013 Statut Membre Dernière intervention 19 mai 2014 5
3 juil. 2013 à 14:06
Pourtant j'ai bien visualiser un exemple de MBR. C'est un "mini-mini-programme " que l'on peut interpréter comme de l'assembleur.
Absolute Sector 0 (Cylinder 0, Head 0, Sector 1)

        0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
 0000  FA 33 C0 8E D0 BC 00 7C 8B F4 50 07 50 1F FB FC  .3.....|..P.P... 
 0010  BF 00 06 B9 00 01 F2 A5 EA 1D 06 00 00 BE BE 07  ................ 
 0020  B3 04 80 3C 80 74 0E 80 3C 00 75 1C 83 C6 10 FE  ...<.t..<.u..... 
 0030  CB 75 EF CD 18 8B 14 8B 4C 02 8B EE 83 C6 10 FE  .u......L....... 
 0040  CB 74 1A 80 3C 00 74 F4 BE 8B 06 AC 3C 00 74 0B  .t..<.t.....<.t.
 0050  56 BB 07 00 B4 0E CD 10 5E EB F0 EB FE BF 05 00  V.......^.......
 0060  BB 00 7C B8 01 02 57 CD 13 5F 73 0C 33 C0 CD 13  ..|...W.._s.3...
 0070  4F 75 ED BE A3 06 EB D3 BE C2 06 BF FE 7D 81 3D  Ou...........}.=
 0080  55 AA 75 C7 8B F5 EA 00 7C 00 00 49 6E 76 61 6C  U.u.....|..Inval
 0090  69 64 20 70 61 72 74 69 74 69 6F 6E 20 74 61 62  id partition tab
 00A0  6C 65 00 45 72 72 6F 72 20 6C 6F 61 64 69 6E 67  le.Error loading
 00B0  20 6F 70 65 72 61 74 69 6E 67 20 73 79 73 74 65   operating syste
 00C0  6D 00 4D 69 73 73 69 6E 67 20 6F 70 65 72 61 74  m.Missing operat
 00D0  69 6E 67 20 73 79 73 74 65 6D 00 00 00 00 00 00  ing system......
 00E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 00F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0100  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0110  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0120  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0130  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0140  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0150  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0160  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0170  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0180  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 0190  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 01A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
 01B0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 01  ................
 01C0  01 00 0B 7F BF FD 3F 00 00 00 C1 40 5E 00 00 00  ......?....@^... 
 01D0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 
 01E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................ 
 01F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA  ..............U. 
        0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F


ET l'Assembly Code

7C00 FA            CLI                  ; Disable maskable Interrupts
7C01 33C0          XOR	AX,AX           ; Zero out both the Accumulator and
7C03 8ED0          MOV	SS,AX           ;    the Stack Segment register.
7C05 BC007C        MOV	SP,7C00	        ; Set Stack Pointer to 0000:7C00
7C08 8BF4          MOV	SI,SP           ; Source Index: Copy from here...
7C0A 50            PUSH	AX
7C0B 07            POP	ES              ; Zero-out Extra Segment
7C0C 50            PUSH	AX
7C0D 1F            POP	DS              ; Zero-out  Data Segment
7C0E FB            STI                  ; Enable Interrupts again

7C0F FC            CLD                  ; Clear Direction Flag (df=0).
7C10 BF0006        MOV	DI,0600         ; Destination Index: New copy of
                                        ;  code will begin at 0000:0600
7C13 B90001        MOV	CX,0100         ; Copy 256 Words (512 bytes)
                                        ;    (100 hex = 256 decimal)
7C16 F2 (*)        REP (*)              ; REPeat the following MOVSW
                                        ; instruction for 'CX' times(*).
7C17 A5            MOVSW                ;  Copy two bytes at a time.

7C18 EA1D060000    JMP	0000:061D       ; Jump to new copy of code...


; Since the preceding routine copies itself and all of the following
; code to 0000:0600 and then jumps to 0000:061D before continuing to
; run, the following addresses have been changed to reflect the
; code's actual location in memory at the time of execution.


; This next bit of code tries to find an entry in the partition table
; that indicates at least one of them is ACTIVE (i.e., bootable). The
; first byte of a partition entry is used as the indicator: If it's
; an 80h, yes; if 00 then no it's not bootable. If none of the four
; possible partitions is active, then an error message is displayed.

061D BEBE07        MOV	SI,07BE           ; Location of first entry
                                          ; in the partition table
                                          ; (see Sample Table below).
0620 B304          MOV	BL,04             ; Maximum of 4 Table Entries.
0622 803C80        CMP	BYTE PTR [SI],80  ; Is this one bootable (80h)?
0625 740E          JE	0635              ; Yes, so jump to next test!
0627 803C00        CMP	BYTE PTR [SI],00  ;  No; is it a 00? If not, it's
062A 751C          JNE	0648              ;   an Invalid partition table.
062C 83C610        ADD	SI,+10            ; Check next entry for 80h ...
                                          ; (10h = 16 bytes per entry)
062F FECB          DEC	BL                ; Subtract 1 from Entry Counter.
0631 75EF          JNZ	0622              ; Have all entries been tested?
0633 CD18          INT  18                ; Yes, and NONE of them were
                                          ;    bootable, so start...
                                          ; ROM-BASIC (only available on
                                          ; some IBM machines!) Many BIOS
                                          ; simply display "PRESS A
                                          ; KEY TO REBOOT" when an
                                          ; Interrupt 18h is executed.


; We found an Active partition, so all the other entries are checked
; for being non-bootable (first byte = 0x00), or there's an error!
; (Only one entry in the Partition Table can be marked as 'Active.')

; Before doing so, we load the Head, Drive, Cylinder and Sector data
; into DX and CX for use by the DOS Interrupt 13 commands later.

0635 8B14          MOV	DX,[SI]           ; Drive  -> DL /   Head -> DH
                                          ; For the standard MBR code,
          ; DL will always be 80h; which means ONLY the first drive can
          ; be bootable! [ This part of the code is often changed by MBR
          ; replacements to boot from another (second, etc.) drive! ]

0637 8B4C02        MOV	CX,[SI+02]        ; Sector -> CL / Cylinder -> CH

063A 8BEE          MOV	BP,SI             ; Save offset of Active Entry
                                          ;  pass to Volume Boot Sector.
063C 83C610        ADD	SI,+10            ; Do next Table Entry
063F FECB          DEC	BL                ; Is this the last entry?
0641 741A          JZ	065D              ; All Entries look OK, so...
                                          ; -> Jump to Boot-routine!
0643 803C00        CMP	BYTE PTR [SI],00  ; Non-bootable entry (00h)?
0646 74F4          JE	063C              ; Yes, so check next entry.


; If there was an error, then this next routine displays the message that
; SI points to.  After printing the ASCII-Z string (null terminated), the
; program 'locks up' by going into an infinite loop (at 065B):

0648 BE8B06        MOV	SI,068B       ; -> "Invalid partition table"

064B AC            LODSB              ; Load byte at [SI] into AL ...
                                      ;   and increment the SI value.
064C 3C00          CMP	AL,00         ; Is it a zero-byte yet ?
064E 740B          JE	065B          ; If yes, were done.  If not ...
0650 56            PUSH	SI            ;  Store string pointer on stack.
0651 BB0700        MOV	BX,0007       ; Use Function 0E (Write Text) of
0654 B40E          MOV	AH,0E         ;  DOS Interrupt 10 to send the
0656 CD10          INT	10            ;  character in AL to the screen.
0658 5E            POP	SI
0659 EBF0          JMP	064B

065B EBFE          JMP  065B          ; Infinite Loop.  You must
                                      ;    power-down or Reboot!


; Now we can load the first sector of the Active Partition (on most drives,
; this would be Absolute Sector 63 for the first or only partition of your
; Hard Drive. Absolute Sectors 2 thru 62 are normally empty, unless you've
; installed a large MBR replacement, disk translation software for a very
; large HD or some kind of multi-OS or security/encryption boot code).
;
; The first two words of the partition entry are the drive/head
; and the sector/cylinder numbers of the first partition sector.
; This data is in the format required by the INT 13 call below.

065D BF0500        MOV	DI,0005       ; Retry 5 times (if necessary)...
0660 BB007C        MOV	BX,7C00       ; Load OS Boot Sector to 0000:7C00
0663 B80102        MOV	AX,0201       ; Function 02h. Read 1 sector.
0666 57            PUSH	DI
0667 CD13          INT  13            ;   Note: This old INT 13 Read
                                      ; is limited to 1024 cylinders.
0669 5F            POP	DI
066A 730C          JNC	0678          ; Carry Flag set? If no, jump!
066C 33C0          XOR	AX,AX         ; Yes, so we had an error! Must
066E CD13          INT  13            ; ...reset drive (Function 00h)
0670 4F            DEC	DI            ; Decrement counter (if > 0)
0671 75ED          JNZ	0660          ;   and try again...

0673 BEA306        MOV	SI,06A3       ; Or, declare: "Error loading
0676 EBD3          JMP	064B          ; operating system" and hang!

; The section of code above is often changed by MBR replacements that will
; tell you if it ever takes more than ONCE to try loading the OS Boot code!
; Surely you'd want to know this wouldn't you?!
;    This old code was obviously made in the days when hard drives, memory
; chips and the boot process itself may have been quite unreliable.


; Once a boot sector for the Active Partition has been loaded into memory,
; it must be checked to see if it is valid. This is accomplished by simply
; checking the last word of the sector; it must be the hex number 0xAA55.

0678 BEC206        MOV	SI,06C2         ; -> "Missing operating system"
                                        ; Set up SI, in case we have an
                                        ; error in the Boot Sector read.
067B BFFE7D        MOV	DI,7DFE         ; Point to the last Word of Boot
                                        ; Sector. It should be AA55 Hex.

067E 813D55AA      CMP	WORD PTR [DI],AA55 ; Is it? ('Signature' Check.)
0682 75C7          JNE	064B               ; If not, display Error Message
                                           ;         and 'lock-up' system.

0684 8BF5          MOV	SI,BP	        ;   SI=BP ->  Both are equal to...
                                        ; offset of Active Partition Entry
                                        ; which is used by OS Boot code.
0686 EA007C0000    JMP	0000:7C00       ;   Jump to OS Boot Sector code
                                        ;       and continue booting-up
0