Thursday, November 1, 2012

Getting Back Ubuntu after Installing Windows 8

So you installed Windows 8 on your system which had a Windows 7 and Ubuntu dual boot working nicely. And now Windows 8 is running well, but you can no longer boot into Ubuntu - the boot menu is missing.

Well, I did. I wrote about it too. I remember going through this every time I installed Windows. I always ended up searching "boot repair ubuntu" on google.

Boot repair according ubuntu.com's Recovering Ubuntu After Installing Windows can be done in the following ways

1. Boot from a Ubuntu Live CD -> Install & run boot-repair -> Click on Recommended Repair and you are done.
2. Use the terminal (after logging into Ubuntu using the Live CD) and run

sudo grub-install /dev/XXX

where XXX is the name of the disk eg sda or sdb. You can find this out by running the following in a terminal window

sudo fdisk -l

3. Using the Alternate CD to get into Rescue Mode, which then lets you run the commands given in point two above.


Ubuntu Live CD does not work on some systems:

The problem with boot-repair is that, on some systems, Ubuntu Live CD does not work. In that case you cannot use the usual way of using the Live CD to boot into a usable desktop and the running boot-repair.


No Alternate CD from Ubuntu 12.10 onwards:

Last time around, I used a 2 gb mmc with the Ubuntu Alternate 11.10  image on it, but since Ubuntu is no longer providing an alternate installation CD, I was at a loss.

Ubuntu Minimal CD:

Ubuntu Minimal CD still exists and provides a way to install Ubuntu from a text based installer by downloading required packages from the web during the installation. The File size is a miniscule 28MB and can be written to a USB drive using Unetbootin or  YUMI amongst others.

Cutting to the chase, I booted into Windows 8, downloaded YUMI then downloaded Ubuntu 12.10 Minimal CD which is only 28 MB in size.

Using YUMI to create a Bootable USB with the Ubuntu Minimal CD iso

1. Select the USB drive letter corresponding to your USB drive. (Be very careful. Incorrect drive letter will cause data loss.)
2. Select "Try an Unlisted ISO" option
3. Browse to the location of the Ubuntu Minimal CD iso.
4. Click create.

After creation of the usb disk, reboot and boot using the USB drive as your boot device.To do this, press the appropriate key to select boot device, when your computer restarts. In my case, I pressed F12 on boot, which gave me an option to boot from the USB drive.

Getting back GRUB:

Select the ISO option under YUMI's grub menu and then select the Ubuntu Minimal CD option.

Ubuntu Minimal CD uses the same text based installer, that the Alternate CD used. On boot, select the "Rescue a broken system" option.

Setup will continue like a routine Ubuntu installation, but with the words Rescue Mode written on the left top side.

After selecting Language, Keyboard, Location, PC name, Time, Network Settings and other options, you will be asked to select "Device to use as root file system"

"Device to use as root file system"
Depending upon the complexity of your partitions and number of hard drives, you will see a different set of device names. I saw the following


/dev/sda1

/dev/sda2

/dev/sda3

/dev/sda4

/dev/sda5

/dev/sda6

/dev/sdb1


You have to select the Ubuntu partition from the list. Knowing which device corresponds to which partition is difficult from this list. So switch to Command Line Mode, by pressing Ctrl+Alt+F2 or F3 or F4 etc Then type in the following command at the command line

blkid

You will see a list with device names with ID and TYPE. The Type will indicate what type of file system is being used by the partition. For eg. Windows will be labelled as FAT or NTFS and Ubuntu partitions will be labelled as ext3 or ext4 depending on what format you had used.

Now switch back to the installation with Ctrl+Alt+F1 (Graphical Installations are at Ctrl+Alt+F7) and continue the setup by choosing the appropriate device. Mine was on /dev/sda5

Reinstall GRUB

In the next screen select "Reinstall GRUB" option

After that you will be prompted to Install the GRUB to a location. This is usually the first hard drive's Master Boot Record (MBR). In my case this was /dev/sda. So I typed that in.

The next screen gives you an option to Reboot the system.

If everything was right, you should be back to your old dual boot setup, with access to both Ubuntu and Windows 8.

tl;dr

1. Get Ubuntu Minimal CD
2. Get YUMI and create bootable USB with the minimal iso
3. Boot using the USB drive and enter Rescue Mode
4. Select appropriate root partition - Your Ubuntu partition
5. Select Reinstall Grub to appropriate location - (MBR of first hard disk commonly)
6. Reboot!

Also, for most sytems in point 1, you can use the Ubuntu desktop iso to create a live cd.

Sources:
1. Ubuntu Minmal CD
2. How to Rescue a Broken System
3. YUMI
4. Proposal to drop Ubuntu Alternate CD





No comments:

Post a Comment