osx - How to bring back Ubuntu after Lion install using rEFIt

04
2013-08
  • Mark Ferree

    Upgraded to Lion this morning which went mostly smoothly, but when I tried to boot back into Ubuntu (I do most of my work in Linux) I was only able to get as far as the grub command mode.

    I spent a good portion of my morning following through guides for similar problems on Windows machines, booting from an Ubuntu install disk and re-installing grub, but I am still unable to boot into my Linux partition.

  • Answers
  • billc.cn

    During my upgrade, I noticed the installer tried to repartition my disk to make space for something.

    Maybe it has overwritten your grub stage 1.5, so now you cannot load configuration and drivers; or maybe it changed the relative position of your Linux partition. In these cases, you will probably see grub rescue mode which takes some guess work to resolve. If it's in normal mode, you can use the ls command to find the Linux partition and edit your boot entry accordingly.

    An easier way is to use the LiveCD to boot and re-install grub. However, I am not sure if it can install the EFI version of grub for you. You might have to use the MBR version in BootCamp instead.

  • Mark Ferree

    I ended up with a solution that was really simple and easy, but resulted in a little bit of data loss.

    I had given up on grub after many failed attempts at re-installing from the livecd and was resigned to just reformat the partition and re-install ubuntu, and noticed the option to re-install 11.04 on top of my current copy after starting the installer.

    I re-installed, and must have gotten a new copy of grub set up correctly during this step. Only side effect was most of my applications I had installed through the softwarecenter were missing, but when I re-installed them settings were still there.

    After 20 or 30 minutes of re-installing applications rEFIt and both OS installs are working the same way they were before the Lion install.


  • Related Question

    multi boot - Ubuntu 9.10: grub2 installed on the wrong partition, no booting... (MacBook)
  • trolle3000

    I recently installed Ubuntu 9.10 on my macbook, hoping to create a dual boot system... I use rEFIt to boot.

    Installation went great, up until insatllation of grub. Trying to create a dual boot system, I have a handful of partitions, and Ubuntu didn't ask where to put grub; it just choose a partition and put it there.

    In the past, Debian worked well with grub and Debian in the same partition. (Debian, macbook and drivers is a high-maintenance trilogy, though...)

    This is what Partition Inspector says:

    *** Report for internal hard disk ***
    
    Current GPT partition table:
     #      Start LBA      End LBA  Type
     1             40       409639  EFI System (FAT)
     2         409640    332556807  Mac OS X HFS+
     3      332820480    391414229  EFI System (FAT)
     4      391414230    440242355  Basic Data
     5      440242356    476678383  Basic Data
     6      476678384    488397134  Linux Swap
    
    Current MBR partition table:
     # A    Start LBA      End LBA  Type
     1              1       409639  ee  EFI Protective
     2 *       409640    332556807  af  Mac OS X HFS+
     3      332820480    391414229  83  Linux
     4      391414230    440242355  83  Linux
    
    MBR contents:
     Boot Code: Unknown, but bootable
    
    Partition at LBA 40:
     Boot Code: None (Non-system disk message)
     File System: FAT32
     Listed in GPT as partition 1, type EFI System (FAT)
    
    Partition at LBA 409640:
     Boot Code: None
     File System: HFS Extended (HFS+)
     Listed in GPT as partition 2, type Mac OS X HFS+
     Listed in MBR as partition 2, type af  Mac OS X HFS+, active
    
    Partition at LBA 332820480:
     Boot Code: None
     File System: ext3
     Listed in GPT as partition 3, type EFI System (FAT)
     Listed in MBR as partition 3, type 83  Linux
    
    Partition at LBA 391414230:
     Boot Code: None
     File System: ext3
     Listed in GPT as partition 4, type Basic Data
     Listed in MBR as partition 4, type 83  Linux
    
    Partition at LBA 440242356:
     Boot Code: None (Non-system disk message)
     File System: FAT32
     Listed in GPT as partition 5, type Basic Data
    
    Partition at LBA 476678384:
     Boot Code: None
     File System: Unknown
     Listed in GPT as partition 6, type Linux Swap
    

    I'm pretty sure grub was put in GPT #3. I want it to be in GPT #4, where Ubuntu is. How do I move it, ie. do the old uninstall/install?

    LiveUSB? LiveCD? What do I write in Terminal...?

    Cheers!


  • Related Answers
  • quack quixote

    There's a good Grub 2 Guide on Ubuntu Forums; this is what I used during my recent Grub2 adventure. Here's another good Grub2 guide, and Ubuntu's Grub2 wiki page.

    1. You "uninstall" Grub from a partition by overwriting the boot code it wrote into the boot sector of that partition. Ideally, you'd have a backup of what was there before Grub was installed to it. I don't believe Grub creates this backup for you, so if you want something particular there (other than Grub), you'll need another tool to provide it.

      If you want, you can completely uninstall the Grub package, then reinstall (I doubt this is necessary). To do this from a LiveCD system you'll need to chroot into the system you're trying to fix.

      # chroot (assumes you've mounted the partition to fix to /mnt)
      sudo mount --bind /dev /mnt/dev
      sudo chroot /mnt
      
      
      # backup!
      cp /etc/default/grub /etc/default/grub.old
      cp -R /etc/grub.d /etc/grub.d.old
      cp -R /boot/grub /boot/grub.old
      
      
      # purge
      apt-get purge grub2 grub-pc
      
      
      # reinstall
      apt-get install grub2 grub-pc
      
      
      # grub install -- make sure /dev/sda is the right drive!!
      grub-install /dev/sda4
      update-grub
      


      If everything went well, you can exit your chroot, unmount your filesystems (/mnt/dev first), and reboot.

    2. If all you need to do is install Grub to the correct partition, all you really need to do is boot into a LiveCD/LiveUSB, mount your system partition, check that your system's /boot/grub is correctly set, and run grub-setup. If you need to reconfigure the Grub menu or perform other steps, use a chroot procedure as described earlier.

      Let's assume you've booted the LiveCD and mounted your system drive to /mnt. Check that /mnt/boot/grub exists, and contains the proper files (a bunch of *.mod files, a few .img files, and grub.cfg). If so, run this (not from chroot):

      # install grub to partition boot sector on sda4
      #    this assumes the partition table you show is on /dev/sda
      #    make sure path & device are correct !!!
      sudo grub-setup -d /mnt/boot/grub /dev/sda4
      


      (Source: Re-install GRUB 2 from a Live CD without chroot)