I recently had the pleasure of finally upgrading my Hard Disks from IDE to SATA.
For those who don’t know what SATA is or why I would want to upgrade to it go HERE before continuing.
Well on my system I have Fedora Core 4 and Windows XP setup in a dual boot configuration where Fedora Core 4 is on the Primary master 150 GB IDE drive and Windows XP is on the Primary slave 40 GB IDE drive. Now my problem was I didn’t feel like reinstalling both operating systems and all my applications all over again so what I decided to do was to try and clone my drives exactly as the were onto the 2 new SATA drives (300 GB and 250 GB respectively). And here’s what I did.
The first thing was to make sure SATA drivers were installed on both operating systems. So I booted into both and sure enough both had SATA drivers already installed.
From there I powered down my PC and plugged in both SATA drives ( in addition to the IDE drives)
and Inserted my hand Knoppix DVD (you can get Knoppix HERE )
and booted the computer.
Once it was booted I opened a terminal window. Now what we’re going to do here is mimic the partitions of the old IDE drives on the new larger SATA drives. Now the IDE drives will usually be labeled as follows.
IDE1 (primary master) /dev/hda
IDE2 (primary slave) /dev/hdb
So to get the current partitions info what we want to type is
# sudo fdisk -l /dev/hda
the output will look similar to the following
Disk /dev/hda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 5 40131 83 Linux
/dev/hda2 6 68 506047+ 82 Linux swap / Solaris
/dev/hda3 69 9964 79489620 83 Linux
so what we want to do is mimic this on the new drives to do this we type
# sudo fdisk /dev/sda
then press n to create a new partitions
you will then be prompted to choose a primary or extended partition. we want primary so press p
then you’ll be prompted for the partition number so hit 1
You are now prompted for the starting block. So using our example this would be 1
then you’re prompted for the last or end block. So again referring to our example above we would use 5
next you want to make sure the partition type matches so press t then type in the number in the Id column in our example this would be 83.
Please note that if this is a Linux drive you may have to switch some partitions around if your swap partition is last. You want your data (or root partitions to be last). It’s fine to move the swap and data partitions around as long as their size stays consistent.
After you’ve finished setting your partitions you have to set one as active (or bootable) to do this press a then the partition you want to make bootable. (usually 1)
Now you want to write your changes so press p to review them then if they are correct press w
Cheers you now have a shiny new drive ready to receive your data.
Now this is the most time consuming part.
We are going to use dd to copy the data from the old partitions to the new partitions.
First my windows drive.
We have /dev/hdb1 as the donor drive and /dev/sdb1 as the recipient so we use the following.
# dd if=/dev/hdb1 of=/dev/sdb1
Note this will take a LONG time (I left it overnight)
After this is done you have to copy over the MBR as follows
# dd if=/dev/hdb of=/dev/sdb bs=512 count=1
Your windows drive is now bootable.
Now we’re going to do the same thing for the Linux drive (minus the MBR stuff)
so do the following dd commands in order (this puts the longest one last)
# dd if=/dev/hda1 of=/dev/sda1
# dd if=/dev/hda2 of=/dev/sda2
# dd if=/dev/hda3 of=/dev/sda3
Once all the copying is done we need to make Linux bootable.
So assuming we are now booted in to knoppix you can do this with the following instructions
at a terminal type
# fdisk -l
# mkdir /mnt/clone
# mount -o rw /dev/sda3 /mnt/clone
# chroot /mnt/clone
You are now in your Linux environment
make sure to mount your boot partition if you have one
# mount /dev/sda1 /boot
# mv /boot/grub/stage1 /boot/grub/stage1.old
# mv /boot/grub/stage2 /boot/grub/stage2.old
# mv /boot/grub/device.map /boot/grub/device.map.old
# grub-install /dev/sda
END GRUB //
That’s it now you can shutdown remove the IDE drives and try and boot of the SATA drives.
At this point you should get your GRUB or LiLo screen and be able to boot into your respective OS
But we still have one problem the partitions are still the same size as before so we see no benefit from the larger drives.
Well time to boot back up with Knoppix.
Altering partitions and filesystems can cause data loss do this at your own risk
One booted up open QtParted
We can use this to resize the Windows NTFS partition
Once you’ve done that commit the changes and we should be good.
For the Linux partition you need to resize the partition and then resize the filesystem
To resize the partition you do the following
Open a terminal
# fdisk /dev/sda
type p to print the current partitions
type d to delete a partition (In my case partition 3)
now type n to create a new partition. (Note that the partition must start in the same place as the old one or you will corrupt and lose data)
Usually if you accept all the defaults it will create a partition to fill the rest of the drive.
Type p again to confirm the changes are correct then type w to write them and q to quit fdisk.
Now we need to resize the filesystem
to do this we use resize2fs with the following syntax
# resize2fs /dev/sda3
This resizes the sda3 partitions filesystem to fill the partition.
Now you’re done!
Hopefully this has been useful to some of you. If you’re lazy like me and don’t want to go through the pain in the ass of reinstalling 2 Operating Systems just to upgrade your drives this is nothing short of a necessity.
Cheers and Good Luck