Moving Linux to a new hard disk

In this example, I move my existing Red Hat Linux 8.0 partitions to a new 120 GB hard disk. Here are the steps I used to move the data to the new disk:

1. Connect the new hard disk as the IDE Primary Slave. You may have to change the jumper settings on the IDE Primary Master when you connect a Primary Slave.

2. Boot a Red Hat Linux installation CD into Rescue Mode by typing linux rescue.

3. Use fdisk to create partitions on the new hard disk.

My old hard disk had the following file systems:

/dev/hda1    /boot    100 Megabytes
/dev/hda2    swap     512 Megabytes
/dev/hda3    /        Remainder of disk space

My new hard disk appears to Linux as /dev/hdf. I used fdisk to partition the new hard disk similar to that of the old hard disk.

4. Create the ext3 and swap file systems on the new hard disk.

mkfs.ext3 /dev/hdf1
mkfs.ext3 /dev/hdf3
mkswap /dev/hdf2

5. Mount the /boot and / (root) slices from both disks.

mkdir /old/boot
mkdir /old/root
mount /dev/hda1 /old/boot
mount /dev/hda3 /old/root

mkdir /new/boot
mkdir /new/root
mount /dev/hdf1 /new/boot
mount /dev/hdf3 /new/root

6. Copy the file systems from the old disk to the new disk.

cd /old/boot
tar cvf - . | tar xvf - -C /new/boot
cd /old/root
tar cvf - . | tar xvf - -C /new/root

7. Red Hat Linux uses file system labels in /etc/fstab. You will either have to edit the new /etc/fstab or (what I chose) use the e2label command to create file system labels on the new hard disk partitions.

e2label /dev/hdf1 /boot
e2label /dev/hdf3 /

8. Edit the lilo boot loader configuration on the new hard disk. If you are experienced with the grub boot loader, you may want to use it instead of lilo.

umount /dev/hdf1
chroot /new/root
mount /dev/hdf1 /boot

vi /etc/lilo.conf


boot = /dev/hda
delay = 40
vga = normal
root = /dev/hda3
image = /boot/vmlinuz-2.4.18-14
        label = Linux

Run lilo -v to make the changes take effect.

9. Reboot your system.

Back to

Last modified: 01/16/2003