How can re-use Ubuntu which was installed via Wubi on Windows 7?
For some reason I can't install Ubuntu from CD or USB, so that I had to installed Ubuntu via Wubi. But I install Ubuntu into partition 'D' and partition of Win 7 is 'C'. If I re-install win 7, how can I use pre-installed Ubuntu ?
Don't uninstall Wubi - it will delete the virtual disk and completely remove your entire Ubuntu install. To safeguard this copy D:\ubuntu\disks\root.disk (and any other virtual disks) completely out of the D:\ubuntu directory.
You have a couple of options:
1.Reinstall Windows 7 and leave D: completely untouched. Then you'll have to use bcdedit or easyBCD to add back an entry for D:\ubuntu\winboot\wubildr.mbr and also copy the D:\ubuntu\winboot\wubildr file to C:\
2. Move the *.disk outside of the D:\ubuntu folder before deleting D:\ubuntu. Reinstall Windows 7 and also reinstall the same release of Ubuntu with Wubi again. Then before rebooting to complete the install, copy back the *.disk files back into the D:\ubuntu\disks folder. This works without any tweaking provided your partition numbering hasn't been altered (i.e. you haven't split C: or resized D: etc) In that case, you'll need to manually tweak the grub menu entry to boot. That's a bit more painful but not too bad if you have someone helping.
However, since you have a dedicated D: partition for Ubuntu, you could just migrate your Wubi install to it. Most likely you had a bad burn on the CD and a bad ISO on the USB if you couldn't install from CD/USB before.
Edit: A bit more info to explain how a Wubi install boots
Wubi installs to the virtual disk - root.disk - and this is a fully contained bootable Ubuntu OS. But it needs to be jump started. So the windows bootloader calls wubildr.mbr (grub4dos) and this finds and transfers control to the first wubildr it finds in the root of any partition (C:\wubildr). Wubildr contains enough of grub2 to locate the root.disk - on any partition provided it is in the /ubuntu/disks/ directory. So that's why adding wubildr.mbr to the windows bootloader, and copying wubildr to C:\ works.
Wubildr will loopmount the root.disk and find it's /boot/grub/grub.cfg and present this as the grub menu. This is where the catch comes in. Up to this point, it doesn't matter which partition or drive anything has been on. The grub.cfg contains explicit drive/partition info and the UUID of the partition as well. If you've copied a root.disk from one partition to another it won't boot. If, as in your case, drive D: was unmodified, it will work fine. If e.g. you moved it to C: you'd need to make some changes.
e.g. if D: is /dev/sda2 and C: is /dev/sda1, then you'd hit 'e' on the first entry of the grub menu and change:
set root=(hd0,2)
becomes set root=(hd0,1)
Delete the line - search --no-floppy xxx (as this overrides the previous set root command using the old UUID)
linux /boot/vmlinuz-xxxx root=/dev/sda2 ...
becomes linux /boot/vmlinuz-xxx root=/dev/sda1 ...
This is a one-time override - hit CTRL+x to boot, and make sure you run sudo update-grub
after booting to fix the grub.cfg menu so it works the next time.
PS there may be some variations. (hd0,2) could be (hd0, msdos2) or (/dev/sda, msdos2) depending on the version of Grub. Also root=/dev/sda2 may be root=UUID=xxxxx