Moving a Fedora Installation
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 andmkfs
to format the partitions toEXT3
. It is important to remember to create aSWAP
partition!.Note: Most people will only have 1 or 2 partitions: the main
/
and/home
.Note: It is much easier to use a LiveCD with a graphical tool (gparted or Knoppix) to create the partitions.
-
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.
Edit grub:
# 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=/
to:
kernel /boot/vmlinuz-2.6.16-1.2080_FC5 ro root=/dev/hda7
Edit fstab:
# 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).
Changed from:
LABEL=/ / ext3 defaults 1 1
/dev/hda13 swap swap defaults 0 0
LABEL=/home /home ext3 defaults 1 2
to:
/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).
Posted in: FC5, Fedora, Linux, Setup,
4 Comments:
Manny on October 13, 2006 - 12:12 PM
Mauriat,
Thanks for your response to my problem. I have been out of town and thus away from the computer until yesterday. Also my email has changed mgml@earthlink.net. To answer your suggestion, yes I did try reinstalling grub. Even more, I tried lbooting directly from a diskette with the same results.
Will continue to experiment.
Thanks,
MannyMark on August 23, 2006 - 04:16 PM
I assume this is the same under FC5. You need to delete /etc/blkid.tab - this file has the device names of the labels cached. If you delete this file, Linux will accept the new names for the labels. If you don’t… Linux will find the old labels at the old devices and you’ve basically done nothing. This is especially true if your drives show up on different controllers and are still connected. (e.g. cciss or ida)
Mauriat on September 7, 2006 - 04:16 PM
Manny: Did you try re-installing grub to the destination partition and then chainloading from your source partition?
Manny on September 7, 2006 - 03:15 PM
I have tried to move a FC5 installation from one partition to another in the same disk. In all attempts both partitions were mounted and a separete FC5 installed in a third partition or Knoppix was used to perform the copy. I have tried dd, cp, cpio, rsync, etc. Grub configuration and fstab were adjusted for the new partition. In all cases. exept with dd, booting failed with the message: “Error 13: Invalid or unsupported executable format.” With dd the OS boots, but boots to the source partition; which makes sense since dd copies the partition’s super block.
Do you have any sugestions as to how make this work?
Thanks
Manny