If you run Ubuntu and you installed Windows later, then know what I’m talking about. Windows just wrote over the MBR record. Windows doesn’t play nice at all. You no longer have access to your Ubuntu distribution.
I’ve read tons of documentation how to recover Grub2, but this is the simplest and the one that worked for me. So, to recover Grub2 after a Windows install, just perform the following:
Boot from a Ubuntu Live CD.
Preferably the same release, but it doesn’t have to be as long as you have access to a Linux Terminal or the Bash shell.
# sudo fdisk -l
That’s the letter L by the way. This should tell you where your Linux distribution is located. Mine is sda1. You may to look for the one with the Linux partition. Mine was set to ext4.
# sudo mount /dev/sda1 /mnt
There shouldn’t be any errors if the partition is mounted properly. If you have experienced an error, you probably did something wrong like mounting a different partition or a partition that doesn’t exist.
# sudo grub-install --root-directory=/mnt/ /dev/sda
Restore Grub2 to the MBR.
# sudo shutdown -r now
There is probably a more graceful way of rebooting, but this one works as well.
# sudo update-grub
Update the Grub menu after the reboot.
That was easy. Practically it’s just one command that really did the trick. There is no typing and editing involved. Like I said, the simplest way to recover Grub2 after a Windows install.
If you enjoyed this article, please share it with others using the social buttons below. If you like to be updated when a new article is published, please subscribe via email, RSS or follow me on Twitter: @ulyssesonline.
There’s actually an easier method. Use Super Grub 2 to fix the MBR. It’s available standalone or on the PMagic disk. This doesn’t always work, but you can use the grub-install method in that case.
Steve, I’m not familiar with Parted Magic. Excellent idea about booting from a USB stick. I could have booted from a USB drive to perform Grub2 recovery.
PMagic is the do everything disk. You can boot it off of CD or USB stick. It also has a disk mounter, so you don’t even have to remember how to mount disks. It has many other utilities for repairing broken systems. I have mine on a 512M stick and have used it to revive my system all the time. ( I like to experiment and “fix” systems so my system seems to be down a lot
) Super Grub is also a great utility, but it is focused primarily on fixing the MBR of both Windoz and Linux disks. It can at least allow you to boot up on a bootable partition so you can repair it.
Thanks for the tip about PMagic. Sounds like a great tool. I’ll look into it. In the meantime, I’m trying to figure how to partition my 1TB drive. 150gb already went to Windoze
the rest to Ubuntu at the moment. I might install Fedora and possibly another distro worth checking. I like Mint, but to me it’s just the same as Ubuntu, just different color.
Since you have lots of room on the 1TB, you definitely should use some of that space for images of your partitions that should be backed up like your /home. Several good utilities are there for this like fwbackups and redo backup. Both are
very easy to use.
Mint is more like Debian than Ubuntu and seems to be more usable out of the box as far as multimedia goes. I would also recommend OpenSuse. Except for Yast, this distro is very smooth and is incredibly secure.
If you have never done multiboot installs, it’s good to know that the installers have a step where you can tell it not to install a boot loader. Tell it not to install, but after you finish and it is ready to reboot, reboot instead to the partition that you normally have grub in and do a update-grub and then reboot into your newly installed distro. It lessens the chance of you hosing your MBR.
OpenSuse is a great distro. I used to be a Mandrake (now Mandriva) user, then Fedora, Ubuntu, Mint and then back to Ubuntu. By the way, I just quickly viewed the screenshots of fwbackups. It looks like it’s easy to use. Thanks for the tip. The only problem with backing up to another partition in the same drive is you would lose the backup if you lose the whole drive. I thought about backing up to an external USB drive.
On backups I do both backing to a convenient partition and to an external hard drive. You can’t have enough backups. Usually when I totally mess up my system, the drive is good, but the driver is defective.
Hard drives are pretty dependable now.
Good point. Every time a new release comes out. I like to do a clean install. I should separate /home from root.
I use fwbackups to backup my /home and use the following command to send all my installed packages to one file where you can restore them later.
$ dpkg –get-selections > safefile
To undo the package save on the new drive install:
$ dpkg –set-selections < safefile
$ apt-get dselect-upgrade
You should be back up to where you were when you did the dist-upgrade.
Hi Steve,
I re-partitioned my drive the other day. It took several hours. I’m going to use the partition for backups. I noticed fwbackups in not in the Ubuntu repositories. I stumbled into several others maybe worth considering.
Go to the Ubuntu Software Center under the Applications menu. It’s there for Lucid Lynx.
For me it worked only after i put another “-” before the root-directory:
# sudo grub-install -–root-directory=/mnt/ /dev/sda
Hi Peta, Actually, in my original code, I had
--rootalso. The TinyMCE editor which WorPress uses converted those two dashes(--)into one long dash. I had to wrap code around my commands to display it properly, but thanks for pointing it out.hey all you can find the best solution of this problem over here:
http://goo.gl/HXsZv
Excellent! There are lots of solutions, but complicated, and none of them worked for me but this did Thanks!