This is pretty easy to do. I like to boot a live Linux CD in order to avoid backing up some files that are created at system startup. My method can either back up a system to an intermediate drive or you can use it to copy the existing system directly onto the replacement disk drive. Either way I would use a live Linux CD to do the work.
Some people would use Clonezilla. I haven't tried it yet but it sounds promising. I will show you my method.
This method only explicitly details copying one partition. Copying multiple partitions uses the same principles which can be applied to copying as many partitions as exist on the original disk.
I don't know what level of detail you require so I will start with general steps. I may use this opportunity to create my first LQ blog entry to describe this process in detail. Anyway, here we go!
On a desktop machine you can directly connect the replacement disk drive to a cable attached to the motherboard's disk controller. A notebook/laptop computer would require the use of an adapter to make the replacement SATA disk drive available through a USB port.
If copying directly to the replacement disk drive do this:
1) Connect the replacement disk drive to the computer.
2) Boot the System Rescue CD. (
http://www.sysresccd.org/)
3) Use cfdisk to create the partitions on the replacement disk drive.
4) Use dd to copy the boot code of the MBR on the original disk to the MBR of the replacement disk. (440 bytes!)
Code:
dd if=/dev/sda of=/dev/sdb bs=440 count=1 conv=notrunc,noerror
5) Use mkswap to format the swap partition on the replacement disk. (If you have a swap partition)
6) Use mkfs to create the root file system on the replacement disk.
7) Mount the replacement disk's root file system on /mnt/backup
8) Mount the original disk's root file system on /mnt/windows
9) Change directory to /mnt/windows
10) Use tar to copy all of the files from your current directory to the /mnt/backup directory.
Code:
tar c . | tar --directory=/mnt/backup -xvp
11) Remove the original disk. Connect the replacement disk to the correct cable connector or whatever so that the motherboard BIOS will automatically boot from it.