Tuesday, December 28, 2010

A Simple Fix For My Broken WUBI

I updated my Wubi Ubuntu 10.04 install a couple of days ago ... and it broke.  That was really annoying. It was also, from my perspective, a bit of a kick in the bum for Ubuntu WUBI.  It breaks kinda easy it seems, and from the number of posts I’ve read, it’s not the first time.  Over the last couple of days I’ve spent a considerable amount of time trolling newsgroups trying to find a fix that suits my specific situation, without a whole lot of luck.  Until today.  Today I discovered an absolutely brain-dead fix to the whole problem that, if you’re set up for it, takes about 5 minutes to take care of.


Wubi, which stands for Windows-based Ubuntu Installer, is a convenient and easy way to try another operating system without the hassle of partitioning or other issues that sometimes occur when attempting to run more than one operating system.
Wikipedia

Wubi uses a virtual disk mounted within the host system (Windows), allowing users to access the full functionality of Ubuntu after the computer starts and the operating system has been chosen from the available menu.
Wubi Guide

Wubi was never intended as anything other than a means to try a Linux operating system and, as such, it is usually recommended to install Ubuntu to a dedicated partition on the hard-drive.
Agostino Russo (Wubi developer)
There are bits and pieces of how to fix this all over the web.  Every one is a slight, but completely understandable, variation of the last.  One guy decided to gather it all together in one thread for others to bump-up and/or reference whenever someone new come stumbling along tired from trying to figure it out themselves.  The big fix is located at the Wubi Megathread for all to follow.  Problem is, it didn’t work for me and finding the solution took a very very long time.
The gist of the “repair” is as follows ... From a terminal on a running Ubuntu OS (Applications > Accessories > Terminal), run the following commands:
  1. sudo mkdir /media/win
  2. sudo mount /dev/sda1 /media/win
  3. sudo mount -o loop /media/win/ubuntu/disks/root.disk /mnt
  4. sudo cp /mnt/boot/grub/grub.cfg /mnt/boot/grub/grub.cfg.copy
  5. sudo chmod +w /mnt/boot/grub/grub.cfg gksu gedit /mnt/boot/grub/grub.cfg
  6. Remove all lines prior to the first menuentry of /boot/grub/grub.cfg.
which, to me, reads ... [sudo] super/substitute user do:
  1. made a folder “/media/win” to mount a drive on,
  2. mount the drive “/dev/sda1” on the “/media/win” folder we just created,
  3. now that we can access it through mounting the drive ... 
    mount the image “/media/win/ubuntu/disks/root.disk” on the “/mnt “ folder,
    yea ... they skipped the create a folder “/mnt” to work on :)
  4. create a back-up copy of the “grub.cfg” file found at “/mnt/boot/grub/”,
  5. make “grub.cfg” editable and open it for editing,
  6. Remove all lines prior to the first menuentry of /boot/grub/grub.cfg.
The tough bit is in the second step and the tough part of it is figuring out which drive your WUBI is installed on.  That drive is represented by the “sda1” part of “/dev/sda1”.  You see, the “a1” part of it is actually “drive and partition”.  The drives on your machine are numbered sdaX, sdbX, sdcX ... and the partitions are sda1..?   You could be mounting “/dev/sdc4” ... who knows eh?  Well, they have an answer for that, there is a script you can run that will provide you with all the gory details and more - see Wubi Megathread for directions.  Let’s add another twist ... I’m running a RAID0That, they don’t have directions for ... ANYWHERE that I’ve managed to find in the last three days.  There must be a way to plug the appropriate partition off a raid drive into the “/dev/sdXY” structure but I’ll be damned if I can find it.  Wait though – you don’t really need to.
The GUI To The Rescue
Menu
I know I’ve browsed around on the Ubuntu file system before and I know it treats my RAID0 as a single drive.  Most of my experience though is on the WUBI and that’s what I’m trying to fix.  So, time to create a boot USB drive and do some playing around.  When the Ubuntu OS loads, it recognizes all my drives and it recognizes them, according to me, exactly the way it should.  After booting from the USB Drive, the middle [of three] menu items, the one called “Places”, is populated near the bottom with all of the drives that the OS found on the machine.  This, is where the easy fix comes from ...
Open the “Places” menu, slide the mouse down to one of the drives the OS has found and hover over it.  After a second or two a “tool-tip” pops up “Mount X” – X being whatever the drive was named.
As can be seen from the image to the right, the OS finds three “drives” and names them;
1) DelUtility
2) RECOVERY and
3) OS
I put the term “drives” in quotes simply because there are the three partitions on my twin 500GB drives that make up the single 1TB RAID0 drive.  Truth of the matter is, at this juncture I simply don’t care what it “is” as long as I can access it because I know my WUBI is in there somewhere.  Turns out it’s easy ... click on OS.  That’s all there is to it.  Yep, get your face out of the terminal box and click on an OS GUI element and, for a newbie like me, all that goofy “mount /dev/sd whatever” crap fades to black  :)
When you click on one of the drive/partition items found in the places menu the drive/partition gets mounted and [in Ubuntu 10.10 which is what I was using] immediately opens in the Nautilus file browser to the correct location.  Before you close it to get it out of the way, search through and find the “root.disk” file we need. Right click on it, select properties and copy the path to the file – you’ll need it.  It also shows up on your desktop as you can see in the image below.
To The Task At Hand
From a terminal on the running USB Ubuntu OS (Applications > Accessories > Terminal), making sure that you substitute the correct path data in the “sudo mount –o loop” command, run the following commands:
Screenshot-2
After running the second command you will notice another drive/partition show up on the desktop [this is a good thing] and [again, in Ubuntu 10.10 which is what I was using] immediately opens in the Nautilus file browser to the correct location.  You can close Nautilus, it is of no further use to us.  The file we are going to edit is owned by “root” and only by pretending to be “root” can we edit it.
The third and final command opens the existing “grub.cfg” in gedit and you have full editing power.  If you prefer to make a back-up before editing it’s easily done using gedit –but- you can do it in the terminal too if that’s what you gotta do.
OK, So I Lied ...
I had the WUBI running last night having, out of total frustration with the lack of a working procedure for my specific instance, given up and used System Restore in Windows 7.  Worked like a hot damn ... Windows 7 is the best Windows – EVER.
I even tried “every” known tool/utility that will open “root.disk” on Windows. Fun ... oh yea.
To those that would recommend I change and move to a dedicated partition … please don’t.  I like things just the way they are.  I don’t have to learn how to or care about partitioning and if I get tired of Ubuntu it’s really easy to get rid of.  The BIGGEST part though is ... Ubuntu is no longer the exclusive realm of the “elite hackers using a close to the core OS”!  Your grandmother is going to be using Ubuntu soon, you better pay more attention to the WUBI, because it’s going to be the install of choice.
Hope this all works for you ... it worked for me :)

Thanks for stopping by,
-- Dave

1 comment:

  1. I use Wubi for ubuntu.
    Last year (May) I tried to install via the install disk and chose the wrong partition :(
    Thank god I had a backup from ~2 days before :)

    ReplyDelete