Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Switch hard drives

Posted on 2003-03-25
Medium Priority
Last Modified: 2013-12-15
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.
Question by:lwinkenb
  • 4
  • 3

Author Comment

ID: 8201492
oh yeah,
My old drive and data is /dev/hda1
My new drive and data is /dev/hdc2 (first partition is swap)

Expert Comment

ID: 8203550
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.

Expert Comment

ID: 8204514
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:

Remove the floppy from the drive.
The machine should now start from the new hd and
show the grub menu.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 8205102
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?

Expert Comment

ID: 8208570
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=/

Author Comment

ID: 8208724
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=/

Accepted Solution

mglxxx earned 1000 total points
ID: 8208899
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.

Author Comment

ID: 8214486
That did it, thanks a lot mqlxx.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question