Recently, a computer upgrade required an operating system transfer from an old computer to a new system. The old drive was a 1.4 GB Samsung and it would easily fit on the new 4 GB Maxtor drive. After hooking up the new drive as a slave disk, booting Knoppix seemed like the easiest way to get Linux running on this PC. Once booted, the new disk is called /dev/hdb and the original disk is /dev/hda. Be very careful with these instructions, if your configuration is different the devices will also be different.

To transfer the data, it is first necessary to replicate the primary partition. This is done by asking the old drive for the size of the partition in sectors:

# fdisk -l -u /dev/sda

Disk /dev/hda: 1024 MB, xxxxxxxxxx bytes
255 heads, 63 sectors/track, xxxx cylinders, total xxxxx sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *          63      208844      104391   b   FAT32

Your new disk should have a partition that ends at 208844 and that is FAT32. Create a new partition on /dev/hdb that is the same type and ends at the same location. You do not need to format this with the filesystem, use dd to clone the data:

# dd if=/dev/hda1 of=/dev/hdb1 bs=1024 

There will be very little feedback while dd is running, this utility will copy the contents of the old partition to your new partition. When this is complete, you will also need to clone the MBR (Master Boot Record) so that the new drive boots the same way. This can be done like so:

# dd if=/dev/hda of=/dev/hdb bs=446 count=1

That’s it, your new disk has the contents of your original drive and should be bootable. You may want to expand the old filesystem which can be done using the parted utility; however, if it is an NFTS partition it’s probably not recommended.

Turn off the computer and unplug the old drive. Retarget the new disk from slave to master and reboot, you should now be running the computer from your new drive with your old operating system. If you have also upgraded your PC hardware in the process, be prepared with your original Windows media.

Categories: Technology