My old video PC started acting up – it was losing BIOS settings randomly. So I’ve replaced the motherboard, installed Windows XP, software, … Everything worked fine but the ancient IDE disk from Maxtor turned out to be very noisy. So I’ve ordered an SSD – the cheapest and hence the smallest I could get. Just enough to install the OS: all videos and music are located on a Samba server. When the new disk arrived, I decided to copy Windows XP partition to the new disk – installing XP again is no fun.
Starting state and notation:
- Maxtor 160GB disk with 80GB NTFS boot partition – I’ll call it HD
- OSZ 32GB disk – I’ll call it SSD
- Windows XP PC – I’ll call it XP
- Ubuntu PC – I’ll call it Ubuntu
Here is what I did. It is not a step-by-step instruction, just a description of what actually worked (I tried other options). Use at your own risk.
Connected SSD and HD to my Ubuntu, the disks were labeled as:
sdg – SSD (destination)
sdf – HD (source)
Check these labels every time you connect a disk to Ubuntu.
Since I already “played” with the SSD, I needed to clean-up the config area. The command below will delete all partitions, MBR, EVERYTHING. Be very careful not to use it on a wrong drive:
sudo dd if=/dev/zero of=/dev/sdg count=1024
Plug SSD into XP. Go to the Disk Manager, initialize the disk, create full-disk NTFS partition (32GB), mark this partition as active. Try to boot XP from this disk – it should produce an error “NTLDR not found” It means that MBR is OK and the partition is bootable.
We need to shrink 80GB partition on HD – SSD is only 32GB. New size will be 24GB:
sudo ntfsresize -s 24G /dev/sdf1
At this point we have a 24GB NTFS volume on a 80GB partition. Yes, NTFS volumes can be smaller than the partition they are in.
Plug HD into XP and boot from it. The system will check the disk before booting.
Plug SSD and HD into Ubuntu. Clone the 24GB NTFS volume from HD to the 32GB partition on SSD. Flag -O means overwrite existing file (disk partition in our case):
sudo ntfsclone -O /dev/sdg1 /dev/sdf1
Run this command to find the exact size of the partition on SSD:
sudo ntfsresize -i /dev/sdg1
The output should look like this:
ntfsresize v2012.1.15AR.1 (libntfs-3g) Device name : /dev/sdg1 NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 23999996416 bytes (24000 MB) Current device size: 32012757504 bytes (32013 MB) Checking filesystem consistency ... 100.00 percent completed Accounting clusters ... Space in use : 12343 MB (51.4%) Collecting resizing constraints ... You might resize at 12342161408 bytes or 12343 MB (freeing 11657 MB). Please make a test run using both the -n and -s options before real resizing!
We need to resize NTFS volume to fill the partition. In the info above we see that the device size is 32012757504 bytes, so we set new volume size to 32012757 kilobytes:
sudo ntfsresize --size 32012757k /dev/sdg1
This is it. Plug SSD into XP. The system will check the disk on first boot.
If new partition is bigger than the old one there is no need to shrink the old NTFS volume. Just clone and resize.
Excellent tutorial! I would use http://www.sysresccd.org instead of an Ubuntu box.
Thanks for the comment – using sysresccd you can do it on a single Windows computer (and often it’s the only option), but that would require lengthy boots when switching disks between Linux and Windows. Having a Linux box with hot-pluggable HDs speeds things up.