I have done this before several times with Ubuntu and Debian without problem on different computers. Up front I should say that resizing partitions creates a risk of data loss (mostly in the case of system failure). First I will cover the simpler case of dual-booting. The procedure I have used:
- Install Windows (from your question, this is already handled).
- Boot into live OS.
sudo apt-get install gparted if it is not already installed.
sudo gparted to run it. Resize a partition.
- Use gparted to make a partition with the empty space. Don't put a filesystem on it.
- Run Ubuntu setup, use empty partition that you created when asked. If you follow the default options for the bootloader, then it will install GRUB with both Ubuntu and Windows available. Every recent version of Ubuntu and Debian I've used will autodetect Windows 7 and add it.
About extented partitions:
I have run into a similar issue on the main desktop I use now. When I installed, it created a separate partition for swap space. And Windows uses a separate partition for its boot manager ("System Reserved"). That means all four primary partitions were used. I also wanted a data partition. The solution I used (and actually am still using):
I left the Linux install, swap space, and Windows "System Reserved" partition as primary. I know the System Reserved needs to be primary, but I left the others just to avoid needless copying. I know the large Windows partition can be a logical one on the extended partition, no problem.
If you have a fourth primary partition, you will need to delete it before you create an extended one. In my case, I used the dd command piped into gzip to copy an image of my Windows partition onto an external drive, then I deleted the partition, created an extended partition, then created partitions inside of the extended one for Windows and the storage partition.
IIRC, when you boot Windows the bootloader will not immediately find the Windows partition (since you moved it), but if you use the automatic boot recovery, it should find it. If you don't change the partition of System Reserved or the Linux boot partition, everything should be fine.