38

I am attempting to install Ubuntu on a box which was previously running Windows 7.

I have also experienced the dreaded "Unable to install GRUB" error.

I am not attempting to dual boot. I have previously run a Windows boot disk and removed all existing partitions.

If I run the Ubuntu 12.04 install CD and click install after the config screens, I get the error Executing 'grub-install /dev/sda' failed. This is a fatal error.
(It is the same error as this question: Unable to install GRUB)

All the questions I've read while looking for a solution are related to dual boot. I'm not interested in dual boot, I'm after a clean out the box Ubuntu install. How can I achieve this?

(For my sanity, please use very simple instructions when responding. I don't claim to have any talent either for linux or as a sysadmin)


Additional details copied from comments dated: 2012-05-29 ~15:19Z

After booting from the CD, clicking Try Ubuntu, and then sudo fdisk /dev/sda I get
fdisk: unable to seek on /dev/sda: Invalid argument

sudo fdisk /dev/sdb gives

Device contains neither a valid DOS partiion table, nor Sun, SGI or OSF disklabel. 
Building a new DOS disklabel with disk identifier 0x15228d1d. 
Changes will remain in memory only until you decide to write them. 
After that of course, the previous content won't be recoverable. 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite). 
Command (m for help):

I should add the Live CD desktop is graphically bad. I've got missing parts of programs and the terminal occasionally reflects to the bottom of the screen. But I can't imagine this is related.

6
  • What is the error that you are receiving? May 29, 2012 at 13:08
  • @harisibrahimkv "Executing 'grub-install/dev/sda' This is a fatal error - the same error as in askubuntu.com/questions/62051/unable-to-install-grub however mine is not a dual boot and I am using the detail partitions
    – Liath
    May 29, 2012 at 13:13
  • You may be experiencing this bug bugs.launchpad.net/ubuntu/+source/grub-installer/+bug/976027 Jun 5, 2012 at 17:16
  • I am also facing similar problem when using first option on installation disk where it says, it will manage partition and isstall etc. It says, it is a fatal error. When I choose manual (last option) then it works correctly. I partitioned my harddisk using partition tool and then used CD by selecting manual selection. That way problem won't come. Jan 3, 2013 at 7:10
  • Please see this link. I had the same trouble you did and solved it. superuser.com/questions/1101648/… I really hope this helps.
    – user572391
    Jul 25, 2016 at 19:43

5 Answers 5

13

I had the same issue.

Solved it by first clicking on the 'Try Ubuntu' button and then on the 'Install Ubuntu' desktop shortcut.

4
  • Worked for me installing 16.04 from a usb stick onto SSD on /dev/sdb. Failed initially but worked after booting fully from stick in "try ubuntu" mode and using the desktop shortcut.
    – womp
    Jan 4, 2017 at 0:40
  • I'm curious, but why does this work? Anyone?
    – Aaron Esau
    Jan 12, 2017 at 0:26
  • 3
    I tried this approach and still got the same error. Apr 5, 2017 at 16:34
  • Worked for me - installing from USB created using Etcher Jul 24, 2017 at 7:54
11

I think it might have messed up your hard disk name. Do try reinstalling GRUB.

  1. Boot using a live CD of Ubuntu.

  2. Open a terminal and run the command

    sudo fdisk -l
    

    It lists the complete partition table of the hard disk. In there, identify which partition you have got your linux installed on. You can identify it using the drive size you had allocated for it and looking at the last column of the output which will be ‘extended’ for all of your linux partitions. The partition will most probably be something like /dev/sda5 or something. Remember this partition.

  3. Create a temporary folder in your home directory (Note: You can make the temporary folder anywhere you want. I’m using the home folder just for the sake of explanation). I’m calling it ‘temp’ for now. So that ‘temp’ folder’s path will be /home/ubuntu/temp.

  4. Mount your linux partition there. That is, assuming that you found your linux partition to be /dev/sda5, you mount that at the ‘temp’ folder by doing the following command

    sudo mount /dev/sda5 /home/ubuntu/temp
    
  5. If you want to check whether you have mounted the correct partition, go to your home folder and open temp. You will be in the / directory. In there you will find ‘home’, in which your home folder’s name will be there. Once you’ve confirmed you have mounted the correct partition, do step 6.

  6. You have to install grub by showing the system where to read the data from the hard disk at the beginning. Don’t worry, just run the following command

    sudo grub-install --root-directory=/home/ubuntu/temp /dev/sda
    

    The /dev/sda corresponds to your hard disk name. Replace it by whatever the command sudo fdisk -l command showed you.

  7. You’re done. You may restart your system.

10
  • Thanks for your help so far! I've booted from the CD and clicked "Try Ubuntu", then when doing the fdisk I get "fdisk: unable to seek on /dev/sda: Invalid argument"
    – Liath
    May 29, 2012 at 13:31
  • 1
    Try "sudo fdisk /dev/sda" or "sudo fdisk /dev/sdb". Also, did you have any external USB devices plugged in to your system while installing your Ubuntu? May 29, 2012 at 13:35
  • /dev/sda gives the same as above (unable to seek), /dev/sdb gives "Device contains neither a valid DOS partiion table, nor Sun, SGI or OSF disklabel. Building a new DOS disklabel with disk identifier 0x15228d1d. Changes will remain in memory only until you decide to write them. After that of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite). Command (m for help):"
    – Liath
    May 29, 2012 at 14:07
  • I should add the trial is graphically bad, I've got missing parts of programs and the terminal occasionally reflects to the bottom of the screen... can't imagine this is related though.
    – Liath
    May 29, 2012 at 14:08
  • 1
    I think I'm running out of options here. Do you have Gparted in your try-ubuntu? Then launch it and see what it says about your hard disk. May 29, 2012 at 14:50
3

My understanding from your comments to @harisibrahimkv are that when you run the command sudo fdisk /dev/sda in a terminal window, you get the message fdisk: unable to seek on /dev/sda: Invalid argument. I would not expect to see this and it makes me wonder if there is a problem with your computer's hard drive.

Would you please post more information about your hardware? You could do this by booting into Try Ubuntu with your install CD and then adding the output from the two commands below to your question.

sudo lshw -short
sudo lshw -class disk -class storage

Note:
You can select text in a terminal window using either the left mouse button or by pressing Alt+E while the terminal window is active and using the Select All entry in the terminal's Edit menu.

After selecting the text either the keyboard shortcut ShiftCtrl+C or the Copy entry in the terminal window's Edit menu will copy to the clipboard.

You can then add this to your question by using the LiveCD's Firefox browser to edit it and then pasting the command output into the question's edit window in the browser.

screenshot from FAQ showing edit link

Please do not use comments to add the output from the commands. Comments are not intended to be used that way.

If you are experiencing problems with graphics, then I suggest you first verify that your install media (CD) is OK. You can do this by running the Check disc for defects menu option from the Ubuntu CD Advanced Welcome Page Options.

To display this menu, press any key after booting your install CD and while the Ubuntu "small logo" Ubuntu Live CD/USB 'small logo' is displayed at the bottom of your screen.

If your install CD is valid, and therefore not the source of the graphics errors you are seeing, then you might want to try installing using the Ubuntu alternate install CD. The alternate install CD is not a "LiveCD". It performs a text based install which avoids potential problems with graphics drivers. It also contains some hardware drivers which are missing from the standard LiveCD.

You can get the alternate install CD ISO image from the Ubuntu 12.04 LTS releases page. If your hardware is old then you probably want to use the 32-bit version, ubuntu-12.04-alternate-i386.iso

3
  • I'd also be inclined to check the md5sum of the download you created the cd from - in fact I always check the hash - help.ubuntu.com/community/HowToMD5SUM and help.ubuntu.com/community/UbuntuHashes May 31, 2012 at 6:45
  • @forestpiskie I tend to suggest running Check disc for defects first both because the validity of the install media is what matters most and it is easier in that it only involves making a menu selection, not running another tool. But, yes, if the install media is bad, then the ISO image needs to be checked to determine if the problem was from an error creating the CD or from a bad ISO. May 31, 2012 at 6:58
  • @forestpiskie FWIW, the entire Check the CD section in the HowToMD5SUM help article strikes me as tedious and pointless. I can't imagine why anyone would want to use the approach outlined there rather than simply using Check disc for defects. It should probably be moved and just linked to. May 31, 2012 at 7:07
2

I had this same problem earlier today when trying to clean install from a USB drive. I burned the ISO to a disc and did a clean install from there and it worked fine. I know that doesn't really solve the problem but it might prove to be a quick fix if that's all you're after.

1

This may sound silly but if you had an mdadm array the partitions may have gotten messed up. Because of mdadm arrays running your partition table will be empty despite the install succeeding (the kernel itself knows the partitions but grub does not understand what to do naturally).

I know this because I broke to the shell and chrooted into /target and ran grub-install and it mentioned something about a missing disk (an fdisk -l /dev/sda showed an empty partition table!).

Reinstalling or recreating a correct partition table will allow the grub-install /dev/sda to succeed after.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .