I've seen a bunch of requests on how to use a live-CD system to access a non-functioning Wubi installation as if it were in its actual running environment but I haven't seen any answers. I worked this out to fix a friend's sick installation. Apologies in advance if this has already been posted, and my google skills failed to find it.

So the situation is generally that during a kernel upgrade or something on the WUBI system, the grub configuration doesn't correctly remade for the new kernel. If this were a regular system, you would boot a live-CD, mount the linux system, chroot to the system root and run update-grub to correct the grub configuration. Many rescue disks have essentially automated the whole procedure. The problem is that on a WUBI system, the grub utilities have been modified so that they know about loop mounted root and how to tell grub to boot it, but they only do that if they think they are running inside a Wubi system. Just mounting the Wubi root disk image file will not provide enough of the Wubi environment so update-grub will work correctly. Here is how to do it so that the environment is just like a correctly function running system.

I am generally going to be talking from the point of Wubi Ubuntu >= 12.04 installed on a Windows 7 machine. For XP and possibly Vista, the location of the Wubi files will be different.

Since you will be running commands within the Wubi system, you need to boot an Ubuntu desktop CD of the same architecture (32 or 64 bit) as the Wubi install. Boot the live desktop system. And open at least a one terminal prompt window. This could either be in the graphic window or on a virtual console (Ctrl-Alt-F1-6. Then type these commands:

You'll need to be root for all these commands.

Code:
sudo -i
cd /
Now create the mount points for the Windows disk and the Wubi system:

Code:
mkdir /host
mkdir /wubi
On a typical Windows 7 machine, the C: disk is the second partition, so that is where the Wubi system files reside and we mount it now.

Code:
ntfs-3g /dev/sda2 /host
Now mount the Wubi root disk:

Code:
mount -o loop /host/ubuntu/disks/root.disk /wubi
Now bind mounts of essential kernel based filesystems from the running live-CD system into what will come the Wubi environment:

Code:
mount --bind /dev /wubi/dev
mount --bind /dev/pts /wubi/dev/pts
mount --bind /proc /wubi/proc
mount --bind /sys /wubi/sys
Now here's the essential thing: the Windows disk has to be mounted on the Wubi file system and and the file that contains the the root file system image has to accessible with the same name that the running loop device has for it, so give this command:

Code:
mount --bind /host /wubi/host
At this point, you can just chroot to the Wubi system and execute commands.
Code:
chroot /wubi
To check whether the grub utilities think you are in a Wubi environment, do
Code:
/usr/share/lupin-support/grub-mkimage --test
echo $?
If things are correct, it should print "0".

To fix a messed up grub ocnfiguration, you would do
Code:
update-grub
Other things that might go wrong are that the kernel is not installed correctly or the initramfs image is not made or something like that. Within this chrooted environment, you have the full power to use dpkg and apt-get, so you can just reinstall the kernel. For example, figure out what kernels you have:
Code:
dpkg -l | grep linux-image
Locate your latest kernel, suppose it is 3.8.0-34-generic. Then you reinstall it with
Code:
apt-get install --reinstall linux-image-3.8.0-34-generic
If errors occur during any of these commands, you can locate and correct whatever issue is causing the problem. If you want to have than one window operating in the Wubi, you can just open a new Terminal window and give the command
Code:
sudo chroot /wubi
And if you want to edit a file in the Wubi system you can just open the file which will be located under /wubi with a nice visual editor from the live-CD environment.
,
After you are finished, it is a good idea to unmount things in reverse order before you reboot. Exit the chrooted shell, then
Code:
umount /wubi/host
umount /wubi/sys
umount /wubi/proc
umount /wubi/dev/pts
umount /wubi/dev
At this point, you would umount /wubi, except if you are in the graphical desktop, the desktop is keeping that mount busy, so just reboot.