linux - how to dual boot Redhat and ubuntu on using different partitions

16
2013-10
  • glapo

    I want to dual boot my laptop using RedHat and Ubuntu in different partitions. My hardisk contains the following partitions:

    /boot ==> redhat boot partition 300MB
    /SWAP ===> 8GB
    / ===> UBUNTU ROOT
    / ===> RedHat Root.
    /Sharing ==> to be shared between the two linux os.
    

    I installed RedHat first without the grub option, followed by Ubuntu with the grub installed in "/dev/sda" (MBR). My problem is that I have not been able to boot the RedHat, I have tried all tools available to configure the grub but I have failed. I updated legacy grub to Grub2 in Ubuntu.

    below is the grub entry for ubuntu===>

    #BEGIN /etc/grub.d/10_linux
    menuentry 'Ubuntu, with Linux 2.6.32-38-generic' --class ubuntu --class gnu-linux --class gnu --class os {
        recordfail
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 0275f7b6-ff36-42a2-9d89-03195b9de12a
        linux   /boot/vmlinuz-2.6.32-38-generic root=UUID=0275f7b6-ff36-42a2-9d89-03195b9de12a ro   quiet splash
        initrd  /boot/initrd.img-2.6.32-38-generic
    }
    menuentry 'Ubuntu, with Linux 2.6.32-38-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
        recordfail
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 0275f7b6-ff36-42a2-9d89-03195b9de12a
        echo    'Loading Linux 2.6.32-38-generic ...'
        linux   /boot/vmlinuz-2.6.32-38-generic root=UUID=0275f7b6-ff36-42a2-9d89-03195b9de12a ro single 
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initrd.img-2.6.32-38-generic
    }
    ### END /etc/grub.d/10_linux ###
    
    ### BEGIN /etc/grub.d/20_memtest86+ ###
    menuentry "Memory test (memtest86+)" {
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 0275f7b6-ff36-42a2-9d89-03195b9de12a
        linux16 /boot/memtest86+.bin
    }
    menuentry "Memory test (memtest86+, serial console 115200)" {
        insmod ext2
        set root='(hd0,1)'
        search --no-floppy --fs-uuid --set 0275f7b6-ff36-42a2-9d89-03195b9de12a
        linux16 /boot/memtest86+.bin console=ttyS0,115200n8
    }
    ### END /etc/grub.d/20_memtest86+ ###
    
    ### BEGIN /etc/grub.d/30_os-prober ###
    ### END /etc/grub.d/30_os-prober ###
    
    ### BEGIN /etc/grub.d/40_custom ###
    # This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    #RedHat Menu by pato
    menuentry 'RedHat Enterprise 5.4' {
        set root='(hd0,4)'
        linux   /boot/vmlinuz-2.6.18-164.el5 root=/dev/sda4
        initrd  /boot/initrd-2.6.18-164.el5.img
    }
    ### END /etc/grub.d/40_custom ###
    =====================end of ubuntu Grub.=================
    

    Please help by a step by step guide to install the two linux operating systems and configure grub for dualboot.

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    Having problems with Grub2 booting Ubuntu from my External Hard Drive
  • cesar

    I installed Ubuntu on my external hard drive but it won't boot on my laptop. What do I do?

    I did some reading and traced the source of the problem to Grub2. Apparently, Grub2 doesn't use the device's UUID, and uses the linux directory instead (/dev/sdf2). This means that whenever I plug my E-HDD into a system that has a different number of drives connected to it, I won't be able to boot without editing the boot command. I don't understand it too well but that's what I got from what I read.

    Is there any way to fix this?

    Here's my grub config (trimmed to show example kernel entry). I have no idea why it's not using UUID. I didn't tweak it once...

    ### BEGIN /etc/grub.d/10_linux ###
    menuentry "Ubuntu, Linux 2.6.31-20-generic" {
            recordfail=1
            if [ -n ${have_grubenv} ]; then save_env recordfail; fi
        set quiet=1
        linux   /boot/vmlinuz-2.6.31-20-generic root=/dev/sdc2 ro   quiet splash
        initrd  /boot/initrd.img-2.6.31-20-generic
    }
    menuentry "Ubuntu, Linux 2.6.31-20-generic (recovery mode)" {
            recordfail=1
            if [ -n ${have_grubenv} ]; then save_env recordfail; fi
        linux   /boot/vmlinuz-2.6.31-20-generic root=/dev/sdc2 ro single 
        initrd  /boot/initrd.img-2.6.31-20-generic
    }
    

  • Related Answers
  • cesar

    The problem was that my device.map was not configured properly which led to grub using the ubuntu names, e.g. sdf2, rather than the UUIDs of the hard drive. the fix was to update device.map and then update grub2. It is done by running 'drivemap', i think, then update-grub. I'm not too sure on the command to update device.map because i did this about a week ago, but yeah. This is just in case anyone runs into my problem.

  • quack quixote

    OK, you're right that that's not grabbing UUIDs, which strikes me as odd.

    Here's how a kernel entry should look (this is from my Ubuntu 9.10 VM, slightly tweaked but this should be fairly stock):

    menuentry "Ubuntu, Linux 2.6.31-20-generic" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
        set quiet=1
        insmod ext2
        set root=(hd0,1)
        search --no-floppy --fs-uuid --set b22c7fe9-4354-40bf-b9bf-87a469289f6e
        linux /boot/vmlinuz-2.6.31-20-generic root=UUID=b22c7fe9-4354-40bf-b9bf-87a469289f6e ro
        initrd        /boot/initrd.img-2.6.31-20-generic
    }
    

    The /boot/grub/grub.cfg file is generated when something runs update-grub from the scripts in /etc/grub.d and variables in file /etc/default/grub.


    • Now, there is a variable in the default file, GRUB_DISABLE_LINUX_UUID, that if set to true will give a root=/dev/sdXY value to the linux kernel line (instead of a root=UUID=... value). I don't think that's your problem, but check your /etc/default/grub file to make sure. You should see these lines (the # at the beginning of the line means it's commented out):

      # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
      #GRUB_DISABLE_LINUX_UUID=true
      

      If you see GRUB_DISABLE_LINUX_UUID without the # at the beginning, insert it, save the file, and run sudo update-grub to regenerate grub.cfg. Then check grub.cfg again to see if it looks right.


    • If the defaults file looks OK, next check your drive's UUIDs themselves. It's possible that the drive UUIDs aren't set correctly, or aren't getting detected correctly. uDev has the job of creating symlinks in the device tree for disk UUIDs; check them:

      $ ls -l /dev/disk/by-uuid
      total 0
      lrwxrwxrwx 1 root root 10 2010-04-18 04:15 b22c7fe9-4354-40bf-b9bf-87a469289f6e -> ../../sda1
      lrwxrwxrwx 1 root root 10 2010-04-18 04:15 e1c64ac1-186d-4c15-8833-6072ac6421df -> ../../sda5
      

      If this doesn't show you a partition you're expecting to see, you might need to check the filesystem directly with tune2fs (manpage) (replace /dev/sda1 with the right device name):

      $ sudo tune2fs -l /dev/sda1 | grep UUID
      Filesystem UUID:          b22c7fe9-4354-40bf-b9bf-87a469289f6e
      

      If this is missing, you can recreate it with:

      $ sudo tune2fs -U random /dev/sda1
      

      Now re-check the tune2fs -l output, and then check /dev/disks/by-uuid again. You may need to reboot before uDev picks up the changes. The update-grub scripts should now pick up the UUID, so re-run it and check the new grub.cfg to see if it looks right.


    • If none of these are panning out, you may need to dig a little deeper. Let's check our assumptions:
      • How is your boot drive partitioned? (fdisk -l)
      • How is your boot drive formatted? (ext2/3/4? FAT32? NTFS?)
      • Did you install via Wubi?