This is actually a much more complicated scenario than it would seem at first, due to the annoying tendency that almost all BIOSs have of reordering how they present drives such that the drive you booted from is always the "first" drive, and that is also what some bootloaders (like the Microsoft's) expect (i.e. things won't work correctly if you try to chainload into Windows if it appears that the drive containing Windows is not the "first" as listed by the BIOS). You don't get this problem when booting from CD because CDs are treated separately from hard drives and don't change the order. There is also the fact that there may be more than one internal drive to choose from, so you should be able to select which of them you want to boot from in that case.
To add to this Ubuntu has a change to grub-mkconfig such that the GRUB_TIMEOUT setting in /etc/default/grub is ignored unless another OS is detected (with the idea being that if you don't have another OS, your computer should boot faster by not waiting on the grub menu unless you hold the shift key). The below solution handles all of these problems and I hope has enough comments that it's clear what's being done.
Run gksudo gedit /boot/grub/custom.cfg
and copy and paste the following into it :
# Set grub's timeout to 5 secons. By setting it here we are overriding any
# settings for the timeout in /etc/default/grub. This is to be sure that we get
# a five second timeout even if Ubuntu's grub-mkconfig thinks it's the only
# Operating System and disables showing of the menu.
timeout=5
insmod regexp
# Grab just the drive portion of $prefix, to determine what drive we booted
# from.
# The third parameter in the following command is a regular expression which
# says to capture just the "hdX" portion of a prefix like
# "(hd1,msdos5)/boot/grub". Note that the parentheses in the regular expression
# denote what needs to be captured (like in perl and most other regular
# expression engines), they're not the parentheses that denote a device in grub.
regexp --set=current_drive '(hd.)' "$prefix"
# Loop through all drives (but not partitions)
for drive in *; do
# If the drive is the same as the one we're booted from just continue on to
# the next without creating a menu entry for it.
if [ "$drive" = "(${current_drive})" ]; then
continue
fi
# Make a menu entry with the device name of the drive in the title
menuentry "Chainload $drive" "$drive" {
drive="$2"
root="$drive"
# Swap the drive currently designated as (hd0) with the drive we want to
# chainload. Thus the drive we are about to chainload will appear to be the
# first drive to the bootloader we chainload.
drivemap -s "(hd0)" "$drive"
chainloader +1
}
done
Then just save the file and you're done.
When you boot, if there are other drives available to be chainloaded into you will see menu entries for them (and if there aren't, you won't). The default menu entry will remain unchanged, which means that Ubuntu should boot by default and you will have a 5 second timeout before that happens. Since you're editing /boot/grub/custom.cfg rather than /etc/grub.d/40_custom you don't even need to run update-grub.
Best Answer
The most likely cause was that you installed GRUB in your Pendrive. To correct this situation you have to Install GRUB correctly in the Hard Disk. First you need intel to do this, you need to know what partition is your Ubuntu. For this we rely in
fdisk
.Using your pendrive in a live session, open the terminal, then type
sudo blkid
. You will get a output similar to this:Here you can see that my Hard Drive is in the
sda
and my pendrive issdg
. We are interested in sda. Now lest look at the descriptions of the partitions. We want the partitions that are ext4. In my case I have two ext4 partitions. This is because I have my/boot
separated, I will take note about that, but lets assume that you don't have/boot
separated for now and that your/
(root) issda1
. Now we will mount sda1.Tecnical note: This is the minimum. If you have a
/boot
partition (or any other) separated just mount it the same way, in my casesudo mount /dev/sda2 /mnt/boot
. Please take note that I used/mnt/boot
, you should change it if using other mount points.Now we will proceed to CHROOTING the partition:
Now we will proceed to install grub:
Done. Now reboot in your system without the pendrive.