LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   duplicating contents of a HD (https://www.linuxquestions.org/questions/linux-hardware-18/duplicating-contents-of-a-hd-69655/)

peterhf 07-02-2003 06:12 PM

duplicating contents of a HD
 
How do I copy a bootable hd to a second hd that will boot?

Thanks in advance for any help extended.

Peter -

KevinJ 07-02-2003 06:19 PM

boot the system to a linux rescue disk, like the RedHat install CD or maybe Tom's RTBT. Do not mount your good Linux install. Assuming your good Linux install is on /dev/hda and you want to copy to /dev/hdb ....

dd if=/dev/hda of=/dev/hdb

works best if hard drives have identical geometry.

-KevinJ

mlp68 07-03-2003 12:50 AM

yes, that works if the drives have the same geometry, but I find that they almost never do -- even if you buy, say, two Maxtor disks with what looks like the same name 6 weeks apart, the geometry is usually different.

There is a more generic (and also faster) procedure which I use in a different way to make an "image backup" of my systems (and also use for cloning purposes). There is an old post of mine at
http://www.linuxquestions.org/questi...338#post295338
about this.

To go from disk to disk, make sure that the *new* disk is what it's gonna be later, such as /dev/hda. Your existing boot disk would be, say, /dev/hdc temporarily.

Then boot a rescue disk (in that post I have a pointer to one that I maintain that will do the trick, but the Redhat disk will suffice). Then, on the virgin /dev/hda make matching partitions as they are on your "good" boot disk. Be very careful not to confuse the disks... you can use fdisk and type the numbers, or use sfdisk -d to capture the partition info and make the other disk the same. Format the file systems on the new disk.

Then, mount each partition pair ( eg /dev/hda1 (=to) and /dev/hdc1 (=from) ), and cp -a or tar the contents from -> to.

Finally, end up with your later / partition mounted, in this example, as /to and run

lilo -r /to

(that's why it has to be what it will be later, e.g, /dev/hda )

The reason why this is faster in addition to geometry-independent is that with dd you copy each byte on the disk, even the unused ones. With that procedure, you copy only the actual files, which can be a lot less.

Hope it helps,

mlp

Pcghost 07-03-2003 01:35 PM

I would check out Power Quests Drive Image program. It's not open source but it is the be-all-end-all of drive copy utilities. It handles different drive geometries well.

Half_Elf 07-03-2003 01:59 PM

boot from something (floppy, installation cd, KNOPPIX).
mount the two hard drive (if you have more than one partition, mount every one).

then do something like
cp -a /mnt/old /mnt/back_up (I'm assuming that /mnt/old is your old hd and /mnt/back_up is the new one)

this will do the job, no matter the hd size. All you have to do then, it to install lilo on your new hd.

chongman99 08-08-2003 04:22 AM

Follow up question from someone else:

I have several partitions and want to move my linux on hda5 to hda12.

=====
1st: Copy the contents.

hda5 is about 20 GB, with only 1GB full.
hda12 is about 5 GB, completely empty.

I booted up with MORPHIX (like Knoppix, live-CD), mounted both drives and then did the following:

cp -a /mnt/hda5 /mnt/hda12

=====
2nd: modify LILO to boot off hda12.

change /etc/lilo.conf

root=/dev/hda12


Just wondering, will this work? Will there be any problems with hda12 thinking things need to be on hda5 (like do partitions know what they are?)? Is there something that will look like it worked but really didn't?

I'm gonna try it and get back to y'all

chongman99 08-08-2003 05:16 AM

It worked!
 
What I just described above worked, moving a distro from one partition to another.

The only problem I had was with LILO. I need to learn more about having more than one distro and how to handle the boot drive issue. (I have a boot partition on /dev/hda2).

Half_Elf 08-08-2003 08:08 AM

yeah it should work well, you will just need some ajustement to your boot loader (or to completly reinstall the boot loader if you are moving to a new HD) but 'cept that, it should goes well.

Moving a *nix system is pretty easy... not like Windoze :D

ksnash 08-11-2003 10:22 AM

If you could find the appropriate blocksize you could set count.
ie: dd if=/dev/hda of=/dev/hdb ibs=4096 count=250k
partition information will be wrong though.

chongman99 08-12-2003 05:30 PM

Boot partition still points to old root partition
 
So I moved my linux root from hda5 to hda12. My boot partition is on hda5.

While booted into hda5, I added the options into lilo with the
same boot image and two entries, the only difference is that one has root=/dev/hda12 and the other has root=/dev/hda5.


Here's the funky thing. Even when I load the /dev/hda12 one, /dev/hda5 gets mounted and set as root in the bootup.

My guess is that it is either:
1) Something on my boot partition that has a global reference to /dev/hda5.
2) Something in the bootup process (initd routines) has a global reference to /dev/hda5

I've got no clue how to figure this out though, so any help is appreciated.

==========

I am running Morphix (which may be part of the problem), but I'd be curious if this were something common to debian.

Has anyone moved their debian partition after install and not had to deal with something in the boot sequence deciding to mount the old drive?


All times are GMT -5. The time now is 05:28 AM.