Results 1 to 6 of 6

Thread: [GRUB issue] How to move GRUB from one partition to another

  1. #1

    Default [GRUB issue] How to move GRUB from one partition to another

    I have had a crash disk on /dev/sdc5, this is not the biggest problem I have but I have to replace the disk because it is really dead (6th CRC error in less than six monthes, it has more than 4 years, I'm fed up with reformatting zero datas each six monthes).

    My biggest problem is that I have a really particular configuration and I wanna be sure that the disk to be replaced is the good one.

    I got three hard disks.
    2 maxtors on racks
    1 internal SATA samsung

    When I installed suse 10.3 on my computer I put the root partition on the sata drive. And I have windows XP on one of the two maxtors.

    As I want to change one of the two maxtors that is clearly defective, I first removed physically the hard disk from its bay, thinking that "this is just one hard disk less and suse will boot without it".

    I was wrong: it didn't...

    I then thought that it wasn't the samsung where suse was installed that booted the computer.

    I put back the rack in its bay and rebooted to linux, without any problem --> it indicated that the system was booting on this disk.

    I realized that if it was the case I had to determine which disk has to be removed and particularly check that the bootable partition wasn't on this disk...

    I planned to install GRUB on the SAMSUNG (where suse is installed) and then try by removing each disk to determine which one is the one to be changed to a new.

    Here is the fdisk -l result

    Disk /dev/sda: 320.0 GB, 320072933376 bytes
    255 heads, 63 sectors/track, 38913 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x000aeb1f

    Device Boot Start End Blocks Id System
    /dev/sda1 1 262 2104483+ 82 Linux swap / Solaris
    /dev/sda2 263 1568 10490445 83 Linux
    /dev/sda3 1569 2874 10490445 83 Linux
    /dev/sda4 2875 38913 289483267+ c W95 FAT32 (LBA)

    Disk /dev/sdb: 163.9 GB, 163928604672 bytes
    255 heads, 63 sectors/track, 19929 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xaa7aaa7a

    Device Boot Start End Blocks Id System
    /dev/sdb1 * 1 498 4000153+ b W95 FAT32
    /dev/sdb2 499 18922 147990780 f W95 Ext'd (LBA)
    /dev/sdb5 499 1494 8000338+ b W95 FAT32
    /dev/sdb6 1495 18922 139990378+ b W95 FAT32

    Disk /dev/sdc: 163.9 GB, 163928604672 bytes
    255 heads, 63 sectors/track, 19929 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x5d2a26c8

    Device Boot Start End Blocks Id System
    /dev/sdc2 * 2 19929 160071660 f W95 Ext'd (LBA)
    /dev/sdc5 2 19929 160071628+ b W95 FAT32
    It seems that GRUB was installed in /dev/sdc2 or /dev/sdb1, but I got no way to verify it, and I don't want to toggle the boot flag because I'm not sure to be able to boot to linux after this operation.
    Because there is no boot flag on /dev/sda I'm sure that GRUB won't be installed on the SAMSUNG.

    Here is an extract of the menu.lst file
    title openSUSE 10.3
    root (hd2,1)
    kernel /boot/vmlinuz-2.6.22.5-31-default root=/dev/disk/by-id/scsi-SATA_SAMSUNG_HD321KJS0MQJ9DQ217
    875-part2 vga=0x31a resume=/dev/sda1 showopts
    initrd /boot/initrd-2.6.22.5-31-default

    ###Don't change this comment - YaST2 identifier: Original name: windows###
    title Windows
    rootnoverify (hd2,1)
    chainloader (hd0,0)+1

    ###Don't change this comment - YaST2 identifier: Original name: failsafe-2.6.22.5-31-default###
    title Failsafe -- openSUSE 10.3
    root (hd2,1)
    kernel /boot/vmlinuz-2.6.22.5-31-default root=/dev/disk/by-id/scsi-SATA_SAMSUNG_HD321KJS0MQJ9DQ217
    875-part2 vga=normal showopts ide=nodma apm=off acpi=off noresume nosmp noapic maxcpus=0 edd=off 3
    initrd /boot/initrd-2.6.22.5-31-default
    I didn't remember when the suse installation program asked me where I wanted to put the GRUB...

    I first thought to isolate grub by disabling one of the two maxtors by the bios, to see what is happening. The tests indicated that I needed BOTH to boot with GRUB (???)

    If I disable the first disk --> no boot sector found

    If I disable the second disk --> grub indicated an error and won't boot.
    It indicated something interesting it seems that GRUB is installed on /dev/sdb1 (surely the primary master).

    Questions:

    How can I remove GRUB from /dev/sdb1 and install it on /dev/sda2 that would let me boot without one of the two maxtors to help me determine which disk has to fly out to the basket...

    Is there a way to know the exact partition where GRUB is installed ??
    I tried grub-install '(hd2)'
    There is an extract of the device.map file

    (hd2) /dev/sda
    (hd1) /dev/sdc
    (hd0) /dev/sdb
    so I need to install it on hd2...
    but once the two maxtors disabled (to be sure the system boots on the samsung) I got a no boot sector error at boot...

    this is the actual fdisk -l informations after have done the necessary (as far I could go)

    Disk /dev/sda: 320.0 GB, 320072933376 bytes
    255 heads, 63 sectors/track, 38913 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x000aeb1f

    Device Boot Start End Blocks Id System
    /dev/sda1 1 262 2104483+ 82 Linux swap / Solaris
    /dev/sda2 * 263 1568 10490445 83 Linux
    /dev/sda3 1569 2874 10490445 83 Linux
    /dev/sda4 2875 38913 289483267+ c W95 FAT32 (LBA)

    Disk /dev/sdb: 163.9 GB, 163928604672 bytes
    255 heads, 63 sectors/track, 19929 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xaa7aaa7a

    Device Boot Start End Blocks Id System
    /dev/sdb1 * 1 498 4000153+ b W95 FAT32
    /dev/sdb2 499 18922 147990780 f W95 Ext'd (LBA)
    /dev/sdb5 499 1494 8000338+ b W95 FAT32
    /dev/sdb6 1495 18922 139990378+ b W95 FAT32

    Disk /dev/sdc: 163.9 GB, 163928604672 bytes
    255 heads, 63 sectors/track, 19929 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x5d2a26c8

    Device Boot Start End Blocks Id System
    /dev/sdc2 * 2 19929 160071660 f W95 Ext'd (LBA)
    /dev/sdc5 2 19929 160071628+ b W95 FAT32
    How can I make it ? I really have no idea, and need to replace the defective disk...

    Thank you to help me, in advance
    Dimitri

  2. #2
    Join Date
    Jun 2008
    Location
    The English Lake District. UK - GMT/BST
    Posts
    37,035
    Blog Entries
    16

    Default Re: [GRUB issue] How to move GRUB from one partition to anot

    You didn't tell us what version of suse you are using.

    Boot in to suse

    Yast - system - bootloader

    You can do it from there

    Your grub will actually be on the MBR of sdb
    and it will need to go to the MBR of sda

    when you propose a new configuration - read carefully! It sounds like you know your drives and partitions, so that's a help.

    Your HD sda with the new grub will need to be first HD to boot in BIOS
    My openSUSE 13.1 KDE Box
    My Articles
    Was I any help? If yes: Click the star below

  3. #3

    Default Re: [GRUB issue] How to move GRUB from one partition to anot

    I think I understood something...

    When in the bios I significated that the system must boot to IDE0 (master) it worked and booted normally (the second disk was in the bay).

    As I removed the second hard disk with the same settings I got a GRUB error (21) at stage1.5.

    As my device map indicates THREE devices and that GRUB found TWO, it may explain the issue.

    hd2 may become hd1 and there is no way to boot on linux.

    Extract from GNU GRUB Manual 0.97
    21 : Selected disk does not exist
    This error is returned if the device part of a device- or full file name refers to a disk or BIOS device that is not present or not recognized by the BIOS in the system.
    So now I'm sure that the XP system is located on the MASTER disk, /dev/sdb1 contains the GRUB and that I will have to wait for the new second disk to be present in the bay to boot linux otherwise I will be exposed to such disappointing behaviour...

    I learnt that there is a way in linux to specify that each disk will get ALWAYS the same identifier, but I forgot the name of the file to configure and I'm not sure that it works with non-usb (local) hard disks, I heard that this is very helpfull with permanently connected USB devices... if you could tell me how I could definitively set the name of a device at the device.map level or how put GRUB on hd0,1 (the first disk second partition, the first as swap) it may fix future problems, because in this case whatever the number of the disks present in the BIOS, the bootable device will always be hd0 !!

    Thank you anyway, hope this experience will help the others in the same situation

    Jah guides, protects and works !!

  4. #4

    Default Re: [GRUB issue] How to move GRUB from one partition to anot

    Thank you very much caf4926 !!

    I was writing the second post while you were sending yours.

    Yes I tried yast/bootloader but it seems it didn't work as expected, nothing has changed in the /boot/grub folder... and I still boot on /dev/sdb1...

    Is there a command to check where GRUB is installed ?
    Is there a command to move the MBR from /dev/sdb1 to /dev/sda2 ?

    dd may work in this case or may be dangerous to be used ?
    I think about dd if=/dev/sdb1 of=/dev/sda2 count=1 bs=1024 (I don't know the exact size of the MBR for grub, I heard about 446 bytes)

    Thank you...
    Dimitri

  5. #5
    Join Date
    Jun 2008
    Location
    The English Lake District. UK - GMT/BST
    Posts
    37,035
    Blog Entries
    16

    Default Re: [GRUB issue] How to move GRUB from one partition to anot

    My openSUSE 13.1 KDE Box
    My Articles
    Was I any help? If yes: Click the star below

  6. #6
    Join Date
    Jun 2008
    Location
    Atlanta, Georgia, USA
    Posts
    2,422

    Default Re: [GRUB issue] How to move GRUB from one partition to anot

    I think there are a few points that need to be clarified:

    Grub can be installed to the MBR of any drive you wish. In openSUSE 11.x (unlike earlier versions), YaST will only install to the MBR of the current boot drive, but from the grub shell it can be installed to any drive's MBR. If that drive is configured for boot, the bios will execute grub stage1 from its MBR.

    When grub stage1 is installed in the MBR, there is a pointer embedded in the code which tells stage1 on which drive/partition to find its stage2 loader program. Ordinarily the kernel and initrd will be in the same directory, although it is possible for those files to be located elsewhere.

    When YaST installs grub, it creates a scriptlet which is fed to the grub shell; it is located at /etc/grub.conf. In that file you can determine on which drive grub was installed to, whether it was installed to the drive's MBR or to a PBR (Partition Boot Record), and what the pointer is (that is, where this stage1 should find its stage2). It is also possible to inspect any MBR or PBR to determine if grub is installed there. For example:

    Code:
    dd if=/dev/sda of=sdambr bs=512 count=1
    xxd sdambr
    will extract and report in hex/ascii the contents of the sda MBR. The word "GRUB" will be clearly seen. Similarly, this:

    Code:
    dd if=/dev/sdb2 of=sdb2pbr bs=512 count=1
    xxd sdb2pbr
    will extract and report the contents of the PBR in the second partition of the second disk; again, "GRUB" is shown. The Windows MBR code does not identify itself as such as does grub, but does contain the phrase "Invalid partition table * Error loading operating system * Missing operating system". The Windows PBR code will always display both the file system type (FAT32 or NTFS) and the name of the boot loader (ntldr for W2K/XP or bootmgr for Vista).

    The MBR "boot" or "active" flag is not ever used by grub. As explained above, grub uses a pointer to find its stage2 loader. The active flag is used by so-called "generic" master boot code, including what is installed by Windows. That code transfers control to program code installed in the PBR, whatever it might be. With Windows XP, it will be code which finds and executes ntldr. It is possible to install grub to the PBR, in which case the generic MBR code - or Windows code - will execute grub. As with the MBR installation, grub in the PBR holds a pointer for where to find its stage2 (while with Windows that must be on the same partition, with grub it can point to any drive/partition, just as grub in the MBR can). YaST has an option to install generic master boot code rather than grub; again, if this code is installed, and grub is installed to a PBR and that partition is marked active, the boot sequence will operate as does Windows (including the limitation to booting only from a "primary" partition).

    The bios does not pass the boot disk drive sequence, so grub must guess, or be told by the user, what the drive sequence is. (Windows does not need this because it must always boot from the first configured drive; it does not have grub's flexibility.) The purpose of /boot/grub/device.map is to give grub the boot sequence translated into grub's numbering scheme (hd0, hd1, etc.) Device.map is used only when grub is installed, and is also used to determine the drive/partition for the pointer. If drives are added/removed/re-arranged, device.map may be wrong or the pointer may be wrong, requiring grub to be re-installed.

    The grub stage1 installed in an MBR can be transferred to another disk, but it will probably not work because the pointer will probably be wrong. It is better to simply install grub to the other disk. The Windows boot code or the generic code can be transferred. The code is in the first 440 bytes of the first 512-byte sector on the disk; bytes 441-446 are used for the disk signature. Generally it is best to use all 446 bytes; however, some Windows programs do put intelligence in the disk signature, making it non-portable. (The dd command you posted above is definitely wrong; it is copying the PBR not the MBR and it moves 2 sectors not just 1 - you would lose the sda2 partition with that code.)

    That covers the basics off the top of my head. Be careful to know what you are doing or you could end up with an unbootable system. Good luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •