Yes, this can be done.
Yes, you can use it for a dual-boot windows system, provided you make Windows the first partition, and it's a primary partition (not an extended inside a logical). My instructions here do not cover this situation, which requires you have some experience dealing with dual booting. If you're after a dual-boot windows/linux setup, don't follow any advice below this point.
I'll go one better: with only a few exceptions, you should be able to migrate your entire laptop live, provided you use an external drive with enough capacity.
Warning! This proceedure is EXTREMELY DANGEROUS! It assumes you have intimate knowledge of the partitioning process, you have a separate /boot partition, and you know a botched attempt can leave you with a brain-damaged installation THAT WON'T BOOT! YOU HAVE BEEN WARNED!
- /boot located on a separate partition. If you have a combined root filesystem (everyting is stuffed into / ) then this won't work.
- The ability to boot from a USB hard drive.
- an external drive large enough to hold all of the data and programs on your existing system. Be sure to run a "du /" and wait for the end result, to get a real feel for the kind of space you'll need.
General Procedure (forgive me for lack of a few commands, I'm writing this very quickly):
- Attach the external drive and locate its device name. Let's pretend that you see it as /dev/sdb.
Create a two partitions on your external drive. In our example, this will show up as /dev/sdb1 and /dev/sdb2.
Format the first partition as ext2 or ext3, and labeled "boot". Format the second partition on the external drive as type "Linux LVM".
Get the newly minted LVM volume recognized by the system using
pvscan ; vgscan
Carve off a large-enough chunk of the external LVM volume to hold the entire laptop's hard drive. If in doubt, just use all of the space available.
Format your LVM-based volume as ext3 or whatever filesystem tickles your fancy.
For each non-special file system mount, create a directory on your external disk and copy (with attributes) all of your files in each mount to that disk. Ignore copies of mountpoints like /proc, etc. as these are "special".
- create the special mountpoints by hand, so that they exist on your external drive. Do not populate them, just make sure the names and permissions match.
- (Very carefully) use your bootloader to install a boot image on your external drive, into the /boot partition. This process is a bit complex so I'll leave it to you to find the info elsewhere. It's also dangerous if you botch it - you could end up trying to overwrite your bootloader on your laptop drive. Be careful.
- Reboot your laptop. When it is going through the POST, be sure to specify the external drive as your boot drive. At this point in time, you should have a (more-or-less) near-replica of your laptop's drive. (to the other admins out there: yes, I know, the log files and others are not in a 100% copied state, but that's not the emphasis here...it's on getting the data and tools moved over...)
- Once you can boot from the external drive, you can then use it to wipe your laptop drive. At this point, you're "living out of" your external drive. Keep this in mind.
- Then use a partition editor - gparted or whatever - to delete the original laptop partitions (bye-bye data...), then mark your newly-minted area as "LVM". Go through the process of getting your LVM volume recognized, partitioned, formatted, etc.
- Using LVM's mirroring process, mirror your live system (which is currently on the external drive) back to the laptop drive. Take a lunch break (or two) for this as it will take time.
- Remount the live filesystem, moving the / filesystem from the external drive to your laptop LVM volume.
- Re-run your bootloader installation process. This is critical as the current ramdisk will not have the right settings and will not know you've moved things around. Failing to do this will result in an unbootable system and a visit to a rescue disk. If all else fails, you can boot from your external drive again (nothing lost...)
- Reboot the laptop without the external drive attached, and specifying the laptop's internal drive instead. It should boot fine. Note anything that feels or looks hurt or broken (there shouldn't be anything), and fix it.
- Sit back and enjoy a beverage for a job well done.