Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
What is the procedure for moving the Master Boot Record from one hard drive to another, and booting from that second? I suspect that my Windows partition, sda1, has given ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Location
    Fairbanks, Alaska
    Posts
    25

    How to install MBR to new hard disk?


    What is the procedure for moving the Master Boot Record from one hard drive to another, and booting from that second?

    I suspect that my Windows partition, sda1, has given up the ghost in some way. (When it starts to analyze my partitions, Gparted gets absolutely stuck on sda. The computer continues to sound like something is trying to read a hard drive after closing Gparted, until shutdown. Also, Windows will no longer boot, though I'm confident that the GRUB options should get it there: it says (if I remember correctly) that the config.sys file is missing or corrupt, and I should fix it with the Windows install disk.)

    This is fine; I haven't used Windows at home in over a year and the drive can be wiped as far as I'm concerned. BUT -- sda contains the Master Boot Record.

    I know that I could make sdb the master drive and sda a slave (or just remove it), but where would the MBR go?

    There must be a regular procedure for installing a MBR on a drive without one. What is it? If it's already documented, can somebody refer me, please?

  2. #2
    Linux User
    Join Date
    May 2009
    Location
    Big River, Sask, Canada
    Posts
    342
    Don't quote me on this, but I believe that when the disk is partitioned you have the option to create a small /boot partition, that would be the MBR.
    Registered Linux User #420832

  3. #3
    Linux Newbie
    Join Date
    Sep 2004
    Location
    UK
    Posts
    161
    MBR lives in the first 446 bytes of the first sector on a harddisk.

    Getting it form a good machine using linux (rescue disk?)

    dd if=/dev/sda of=mbr.bin bs=446 count=1

    Writing it on another machine using linux (rescue disk?)

    dd if=mbr.bin of=/dev/sda bs=446 count=1

    Just need to have a place to save it to (usb stick?), and sda might be hda sepending on distribution (most newer distributions use sdx for disks rather than hdx).
    In a world without walls and fences, who needs Windows and Gates?

  4. #4
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    3,040
    Quote Originally Posted by Paul Adasiak View Post
    There must be a regular procedure for installing a MBR on a drive without one.
    Quote Originally Posted by blinky View Post
    MBR lives in the first 446 bytes of the first sector on a harddisk.
    Copying MBR contents from one drive to another is unlikely to fix the problem. Can you post the output of
    Code:
    fdisk -l
    the -l has a small L not a one ... we can then see disk partition structure.

  5. #5
    Just Joined!
    Join Date
    Jul 2007
    Location
    Fairbanks, Alaska
    Posts
    25
    Output of fdisk-l is:
    Code:
    Disk /dev/sda: 81.9 GB, 81964302336 bytes
    255 heads, 63 sectors/track, 9964 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xf9fbf9fb
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1        9963    80027766    7  HPFS/NTFS
    
    Disk /dev/sdb: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x00003db5
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            9599        9729     1052257+  82  Linux swap / Solaris
    /dev/sdb2            3072        9598    52428127+  83  Linux
    /dev/sdb3               1        1044     8385898+  83  Linux
    /dev/sdb4            1045        2089     8393962+  83  Linux
    
    Partition table entries are not in disk order
    
    Disk /dev/sdc: 160.0 GB, 160041885184 bytes
    255 heads, 63 sectors/track, 19457 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xdecf6712
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1               1        9728    78140128+   b  W95 FAT32
    /dev/sdc2            9729       19457    78148192+  83  Linux
    /dev/sda is (or has been) my Windows partition, /dev/sdb my Linux partition, and /dev/sdc the external backup drive.

  6. #6
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    3,040
    It's up to you what you want to do with the Windows partition and hard drive. If you have Windows data already backed up then you can just remove the Windows partition and create a partition for data etc. This should not stop the system booting as grub code in the MBR is not affected by changes to partition layout.

    You could install grub to the MBR of sdb and then swap boot order ... but first we need to check which partition Linux is booting from.
    Can you post the output of
    Code:
    mount
    cat /boot/grub/menu.lst
    cat /etc/fstab
    if you want to change the boot order and install grub to your Linux disk MBR.

  7. #7
    Just Joined!
    Join Date
    Jul 2007
    Location
    Fairbanks, Alaska
    Posts
    25
    Quote Originally Posted by Jonathan183 View Post
    It's up to you what you want to do with the Windows partition and hard drive. If you have Windows data already backed up then you can just remove the Windows partition and create a partition for data etc. This should not stop the system booting as grub code in the MBR is not affected by changes to partition layout.
    Problem is, gparted (and presumably other non-graphical partition managers, though I haven't tried) can't read the Windows partition. Not just can't read the Windows data -- I don't care about that anymore and would rather wipe the drive clean -- but it gets stuck while "Searching /dev/sda partitions". This makes me suspect that the drive is physically corrupted, so I don't want to continue trusting it to host the MBR.

    If anyone suspects that the drive isn't really corrupted, and can suggest a fix, I'm happy to entertain that.

    You could install grub to the MBR of sdb and then swap boot order ... but first we need to check which partition Linux is booting from.
    Can you post the output of
    Code:
    mount
    cat /boot/grub/menu.lst
    cat /etc/fstab
    if you want to change the boot order and install grub to your Linux disk MBR.
    Output of
    Code:
    mount
    is:
    Code:
     /dev/sdb3 on / type ext3 (rw,relatime,errors=remount-ro)
    tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
    proc on /proc type proc (rw,noexec,nosuid,nodev)
    sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
    varrun on /var/run type tmpfs (rw,nosuid,mode=0755)
    varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
    udev on /dev type tmpfs (rw,mode=0755)
    tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
    devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
    fusectl on /sys/fs/fuse/connections type fusectl (rw)
    lrm on /lib/modules/2.6.28-11-generic/volatile type tmpfs (rw,mode=755)
    /dev/sdb2 on /home type ext3 (rw,relatime)
    securityfs on /sys/kernel/security type securityfs (rw)
    binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
    Output of
    Code:
    cat /boot/grub/menu.lst
    -- minus the commented-out parts -- is:
    Code:
    title           Kubuntu 9.04, kernel 2.6.28-11-generic (on /dev/sdb3) 
    root            (hd1,2)                                               
    kernel          /boot/vmlinuz-2.6.28-11-generic root=UUID=f6ef59cd-c6ed-401a-9dde-eedb1a118d6a ro quiet splash                              
    initrd          /boot/initrd.img-2.6.28-11-generic                    
    savedefault                                                           
    boot                                                                  
    
    title           Linux Mint 6, kernel 2.6.27-11-generic (on /dev/sdb4)
    root            (hd1,3)                                              
    kernel          /boot/vmlinuz-2.6.27-11-generic root=/dev/sdb4 ro quiet splash                                                              
    initrd          /boot/initrd.img-2.6.27-11-generic                    
    quiet                                                                 
    
    title           Microsoft Windows XP Home Edition (on /dev/sda1)
    root            (hd0,0)                                         
    makeactive                                                      
    chainloader     +1                                              
    
    ### END DEBIAN AUTOMAGIC KERNELS LIST
    
    # This is a divider, added to separate the menu items below from the Debian                                                                 
    # ones.                                                               
    title           Other boot options:                                   
    root                                                                  
    
    
    # This entry automatically added by the Debian installer for an existing                                                                    
    # linux installation on /dev/sdb3.                                    
    title           Kubuntu 9.04, kernel 2.6.28-11-generic (recovery mode) (on /dev/sdb3)                                                       
    root            (hd1,2)                                               
    kernel          /boot/vmlinuz-2.6.28-11-generic root=UUID=f6ef59cd-c6ed-401a-9dde-eedb1a118d6a ro single                                    
    initrd          /boot/initrd.img-2.6.28-11-generic                    
    savedefault                                                           
    boot                                                                  
    
    
    # This entry automatically added by the Debian installer for an existing                                                                    
    # linux installation on /dev/sdb3.                                    
    title           Kubuntu 9.04, memtest86+ (on /dev/sdb3)               
    root            (hd1,2)                                               
    kernel          /boot/memtest86+.bin                                  
    savedefault                                                           
    boot                                                                  
    
    
    title           Linux Mint 6, kernel 2.6.27-11-generic (recovery mode)
    root            (hd1,3)                                               
    kernel          /boot/vmlinuz-2.6.27-11-generic root=/dev/sdb4 ro single                                                                    
    initrd          /boot/initrd.img-2.6.27-11-generic                    
    
    title           Linux Mint 6, kernel 2.6.27-7-generic
    root            (hd1,3)                              
    kernel          /boot/vmlinuz-2.6.27-7-generic root=/dev/sdb4 ro quiet splash                                                               
    initrd          /boot/initrd.img-2.6.27-7-generic                     
    quiet                                                                 
    
    title           Linux Mint 6, kernel 2.6.27-7-generic (recovery mode)
    root            (hd1,3)                                              
    kernel          /boot/vmlinuz-2.6.27-7-generic root=/dev/sdb4 ro single                                                                     
    initrd          /boot/initrd.img-2.6.27-7-generic                     
    
    title           Linux Mint 6, memtest86+
    root            (hd1,3)                 
    kernel          /boot/memtest86+.bin    
    quiet
    And the output of cat
    Code:
    /etc/fstab
    is:
    Code:
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    proc            /proc           proc    defaults        0       0
    # /dev/sdb3
    UUID=f6ef59cd-c6ed-401a-9dde-eedb1a118d6a /               ext3    relatime,errors=remount-ro 0       1
    # /dev/sdb2
    UUID=56f7b1d5-49b4-4702-a2a3-7a778b7adcea /home           ext3    relatime        0       2
    # /dev/sdc2
    # UUID=59009464-ce5c-4bb6-8451-8f7f7f6a4cdc /media/linuxbackup ext3 relatime,noauto,users        0       2
    # /dev/sdc1
    # UUID=487D-9FF8  /media/winbackup vfat    utf8,umask=007,gid=46,noauto,users 0       1
    # /dev/sdb1
    UUID=54dc2e62-98ac-4089-b05a-a17499a4a6b0 none            swap    sw            0       0
    /dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0    0
    /dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0   0
    Swapping the boot order, as you suggested, is what I have in mind. Or just pulling sda altogether and having it wiped and disposed of. (Though, again, if somebody knows of a neat fix, I may not need to go through the trouble.) Right now, the inability to access and change partitions is preventing me from installing a new distro.

  8. #8
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    3,040
    I would check the drive with something like ubcd before throwing it away. Anyway ... if you can change boot order we can make the relevant changes and if you decide you want to use the drive you can do.

    I assume you have a live CD to boot from incase you get into trouble ... if not get one now - if you installed kubuntu from a live CD that will do.

    OK steps are ...
    install grub to MBR of sdb
    Code:
    sudo grub
    root (hd1,2)
    setup (hd1)
    quit
    modify grub menu.lst file so it will work when drive order is changed.
    Code:
     sudo nano /boot/grub/menu.lst
    and add ... (modified entries below - change (hd1 to (hd0 and sdb to sda)
    Code:
    title           Kubuntu 9.04, kernel 2.6.28-11-generic (on /dev/sda3) 
    root            (hd0,2)                                               
    kernel          /boot/vmlinuz-2.6.28-11-generic root=UUID=f6ef59cd-c6ed-401a-9dde-eedb1a118d6a ro quiet splash                              
    initrd          /boot/initrd.img-2.6.28-11-generic                    
    savedefault                                                           
    boot                                                                  
    
    title           Linux Mint 6, kernel 2.6.27-11-generic (on /dev/sda4)
    root            (hd0,3)                                              
    kernel          /boot/vmlinuz-2.6.27-11-generic root=/dev/sdb4 ro quiet splash                                                              
    initrd          /boot/initrd.img-2.6.27-11-generic                    
    quiet                                                                 
    
    #title           Microsoft Windows XP Home Edition (on /dev/sda1)
    #root            (hd0,0)                                         
    #makeactive                                                      
    #chainloader     +1                                              
    
    ### END DEBIAN AUTOMAGIC KERNELS LIST
    
    # This is a divider, added to separate the menu items below from the Debian                                                                 
    # ones.                                                               
    title           Other boot options:                                   
    root                                                                  
    
    
    # This entry automatically added by the Debian installer for an existing                                                                    
    # linux installation on /dev/sdb3.                                    
    title           Kubuntu 9.04, kernel 2.6.28-11-generic (recovery mode) (on /dev/sda3)                                                       
    root            (hd0,2)                                               
    kernel          /boot/vmlinuz-2.6.28-11-generic root=UUID=f6ef59cd-c6ed-401a-9dde-eedb1a118d6a ro single                                    
    initrd          /boot/initrd.img-2.6.28-11-generic                    
    savedefault                                                           
    boot
    I don't think you need to change fstab because it already contains uuid references (which don't change) but it may be worth updating comments from sdb to sda ... use
    Code:
    sudo nano /etc/fstab


    That should fix kubuntu ... there is one other modification I suggest you do while in kubuntu - add the following to the menu.lst
    Code:
    title Linux Mint on sda4
    root (hd0,3)
    configfile /boot/grub/menu.lst
    this will then allow display of Mint grub menu.

    After that shutdown the system, change the hard drive boot order and restart kubuntu.

    After checking kubuntu works we need to modify the Mint grub menu so it will also function correctly ... to do this shutdown kubuntu, and start Mint using the original menu entry ... does Mint work? if it does then post the output of
    Code:
    cat /boot/grub/menu.lst
    this time can you post the full file contents.

    Ed: I suggest you use the kubuntu and Mint grub menus ... the reason for this is when kernel updates occur the distro grub menu.lst file will automatically be updated. If you don't use the grub menus then you will need to manually update the menu entry to make it access the latest kernel.

  9. #9
    Linux Newbie
    Join Date
    May 2009
    Posts
    128
    I didn't understand what for you want to copy the MBR to the other Harddisk.
    You can reinstall Grub and it will automatically install to MBR.
    If you take the one Harddisk away that doesn't work fine it will go to the other one left.


    You can also try to format the first one and give another OS on it and Grub or another bootloader should do everything you need.

  10. #10
    Just Joined!
    Join Date
    Jul 2007
    Location
    Fairbanks, Alaska
    Posts
    25
    Quote Originally Posted by computerophil View Post
    I didn't understand what for you want to copy the MBR to the other Harddisk.
    You can reinstall Grub and it will automatically install to MBR.
    If you take the one Harddisk away that doesn't work fine it will go to the other one left.
    Sorry for expressing myself badly. I don't care about copying the MBR to my second hard drive; I just want to make sure that the second hard drive has one. That is, assuming that the first hard drive is well and truly damaged and needs nothing more than to be removed and (possibly) destroyed.

Page 1 of 2 1 2 LastLast

Posting Permissions

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