Switch hard drives

Hello,
What I'm trying to do is switch my linux installation from an old hard drive to a new one.  I'm running Redhat 8.0, and using GRUB.

What I've done so far is partitioned the new hard drive, and mounted it.  I then copied everything over to the new hard drive using:
cp -ax / /new_disk

This is where Im stuck at.  I need to be able to remove the old hard drive, and have linux boot to the new one.  I am unsure on how to make GRUB do this.

Thanks for the help.
LVL 5
lwinkenbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lwinkenbAuthor Commented:
oh yeah,
My old drive and data is /dev/hda1
My new drive and data is /dev/hdc2 (first partition is swap)
0
haydes007Commented:
edit /etc/grub.conf and change what /dev/ the entry points to. Then all you need to to is reboot and grub should (hopefully) do its thing. The question I have is whether or not you can simply just cp the old installation to a new drive and expect it to boot like the old one did. I hope it works but I really don;t think it will. I will be interested to see if it does.
0
mglxxxCommented:
haydes007's approach won't quite work: if the old hd is
removed, there won't be any GRUB the system will be able
to boot from.

Here's what to do in addition to editing /etc/grub.conf
as specified by haydes007:

Create a grub boot floppy:
cd /usr/share/grub/i386-redhat
dd if=stage1 of=/dev/fd0 bs=512
dd if=stage2 of=/dev/fd0 bs=512 seek=1

Now shut down your machine and remove the old disk.
You could plug the new disk into the controller port
where the old one was. This way the new disk becomes
/dev/hda. I assume that you will do this.

Now boot your machine from the grub boot floppy. This
will put you at a grub prompt.
Your new root filesystem is /dev/hda2. In order to
tell grub about that do a
root (hd0,1)
Now make grub install an MBR on the new HD:
setup (hd0)

Tell grub to reboot the machine:
reboot

Remove the floppy from the drive.
The machine should now start from the new hd and
show the grub menu.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

lwinkenbAuthor Commented:
ok, I tried everything you said and I got this when trying to reboot from the new drive:
When it says "Mounting root filesystem" the next line reads
"Mount: error 2 mounting ext3"
pivotroot: pivot_root(/sysroot,/sysroot/initrd) failed: 2
umount /initrd/proc failed: 2
Kernel panic: No init found, Try passing init= option to kernel

Any ideas what the problem is?
0
mglxxxCommented:
This looks like a problem in your grub.conf.
Make sure that you
specified root=/dev/hda2 in the 'kernel' line.
Also /etc/fstab should be modified to reflect the
new root device, unless the root device is
specified using LABEL=/
0
lwinkenbAuthor Commented:
ok, when I added root=/dev/hda1 to the grub kernel line (I repartitioned the drive so that the linux installation came before the swap),
It gets past the kernel panic, but then it gives this during boot up:
Checking root filesystem
Couldn't find matching filesystem: LABEL=/
0
mglxxxCommented:
Modifying the /etc/fstab entry for the root file system
to start with /dev/hda1 instead of LABEL=/ should help.
Boot into 'rescue' mode from the installation CD in order
to do this.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lwinkenbAuthor Commented:
That did it, thanks a lot mqlxx.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.