With the recent purchase of a new harddrive I did not want to re-install every operating system on my previous drive. Since I dual boot with Windows, I first attempted to copy Windows. I tried multiple solutions and Norton Ghost met my requirements however a problem in 48bit LBA (Logical Block Addressing) in Windows 2000 caused too many problems. In the end I re-installed Windows. (Note: Linux does not have this problem). After Windows, I continued to my Fedora Core 5 installation.
Linux can be just “copied” and should work. I decided to test that out!
- First I made sure that through the Windows installation I left the required space on the new harddrive for Linux.
- I booted with FC5 CD 1 and selected linux rescue. This should provide enough tools. It gives a prompt to mount an existing Fedora installation. However I selected “Skip”.
- I created all the partitions I wanted for the new harddrive (see the previous post for my layout). I used fdisk to partition and mkfs to format the partitions to EXT3. It is important to remember to create a SWAP partition!.
- After the partitions were created, I had to copy – which takes the longest time. I needed to mount both old and new partitions to copy. My new 300GB drive is /dev/hda and previous 120GB drive will be /dev/hdb (mounted read-only). It is important to note the proper partition numbers for each drive!
# cd /mnt # mkdir fc5.old # mkdir fc5.new # mount -t ext3 -o ro /dev/hdb10 fc5.old # mount -t ext3 -o rw /dev/hda7 fc5.new # cp -a /mnt/fc5.old /mnt/fc5.new
I had to repeat the copying step for each additional partition I copied (i.e. /home)
- Next I had to edit (using nano) the grub booting setup (/boot/grub/grub.conf) and the filesystem mounting information (/etc/fstab). (See update note below.) This was the trickiest part.
# nano /mnt/fc5.new/boot/grub/grub.conf
Grub requires the root and kernel lines to be modified:
Since /dev/hda7 is (hd0,6) I changed root (hd0,9) to root (hd0,6).
The kernel also requires a root= parameter which can take a label or device. Previously my root device was /. So the change I made was from:
kernel /boot/vmlinuz-2.6.16-1.2080_FC5 ro root=LABEL=/
kernel /boot/vmlinuz-2.6.16-1.2080_FC5 ro root=/dev/hda7
# nano /mnt/fc5.new/etc/fstab
The filesystem list (fstab) is similar to grub. I needed to make a change for 3 partitions: /, /home and SWAP. (Any NTFS or FAT32 partitions can also be listed here).
LABEL=/ / ext3 defaults 1 1 /dev/hda13 swap swap defaults 0 0 LABEL=/home /home ext3 defaults 1 2
/dev/hda7 / ext3 defaults 1 1 /dev/hda15 swap swap defaults 0 0 /dev/hda13 /home ext3 defaults 1 2
- The final step was to re-install grub so that the partition can actually boot. I have grub on the / partition (/dev/hda7) instead of the MBR (/dev/hda). To install grub I did the following:
# chroot /mnt/fc5.new/ # grub-install /dev/hda7
- I rebooted and I went to Windows and proceeded to install bootpart to use the NTLDR to boot grub as stated in my FC5 Install Guide. (However had I installed to the MBR, this wouldn’t be needed.) Once setup in Windows, rebooted again and booted into Fedora!
Now this took a little tinkering. I accidentally made some mistakes on partition sizes when formatting and accidentally set the wrong values in both grub and fstab. So I had to go back and forth a few times. Luckily I had the old harddrive with a perfect backup.
This was an interesting experience. It did save me the time to do a full re-install of Fedora and to install all the updates and additional configuration. This time it took a few hours to get correct, but next time I imagine I could do it in 30 minutes or so.
Hopefully someone else can learn from this.
Update: Step 5. above can be simplified if the e2label command properly is properly used. Example:
# e2label /dev/hda7 / # e2label /dev/hda13 /home
This should allow for the new drive to use the same labels as the old drive. However using the physical device partition numbers (/dev/hdX) is gauranteed to work, whereas sometimes labels can get confusing (or fail).