How to duplicate a drive in Unix?

I have a drive that I need to make a sector-by-sector or exact image copy of. In Windows, I use a program call Ghost by Symantec, but the version I have does not support Unix.

Does anyone know of a good product for Unix?

Thanks,

Brett Gibson
Gibson Teldata, Inc.

You can use dd for that. Lets say you want to create an image file of hda you would use : dd if=/dev/hda of=/tmp/hdaimage.

If you got 2 identical disks you could mirror them like this :
dd if=/dev/hda of=/dev/hdb

Upgrade your version of Ghost. We have it and it works well. However.. let me caution you on something... When you make exact duplicates of hard drives, I assume that you are changing the liscensing information on the duplicated drive... Right?? Right??? Right???? =)

Maybe he's setting up a homebrew MirrorDisk :stuck_out_tongue:

# crontab -l

          • dd if=/dec/hdc of=/dev/hdd >/dev/null 2>&1

One guy reportedly did this with cat:

# cat /dev/hda >/dev/hdb

The disks were 100% identical, important for such things as sector sizes, etc.

The paranoid way would be to make filesystem, mount the second disk, and use cp -r.

This is what I do when I add one disk and, fx. move the /usr or /home tree to the new disk

Atle

It's OK to do it with cat as well... I think people use dd because you have a little more control (blocksize, count size, etc...) than with cat.
I think it's the FreeBSD Install manual that says: to create the floppy boot image, simply cat boot.flp > /dev/fd0

A not-so-known thing about FreeBSD:
I wanted to duplicate a disk, but couldn't for the life of me get it to work - how the H#&& do I get the SCSI-emulator to work, grrrr!!
Then I found burncd, worked right off the IDE, just like I would have done it.
".. just like I would have ... hmm, lets try .."

# cat /dev/acd0 >file.iso

YES! That is the way to duplicate a disk under FreeBSD:

You cat the CD and pipe it to the CD-R!

I became a _dedicated_ BSD fan after that :slight_smile:

Atle

Heh, that's how I create ISO images to burn in Windows. I use mkisofs (I like it better than the windows program to create a CD), or cat /dev/hdb > /usr/lib/samba/tmp/cd_1.iso

Now I pull it to my Windows CD burner via Samba, and burn away!

Alas, I can't have my cd-burner attached to my Linux machine, since it's a portable, external that attaches to parallel port, and my version of Linux does not have a stable driver out for it...

Soon, hopefully, I'll have time (and energy!) to try fiddling with it...

I just compiles myself a new fBSD4.4 kernel, and there was a 'parallel bus' there - I don't have any parallel devices (whatever happened to Centronics, I still have printer cables that take a Centronics in each end)

Have you tried FreeBSD?
It seems a shame not to be able to run an OS just for that reason!

FreeBSD can also, at least in theory, read ext2, so you don't need a new partition or anything (eh, I think my pants are on fire) :wink: - but you could give it a try - use MFS or something as rootdev?

Atle

The problem with this method is that dd is a block-level copying tool. If your source disk contains some bad blocks, they will be copied exactly to the destination. In addition, if you are using a LVM to span a filesystem across multiple physical disks, the dd can get tricky. A better solution might be to use cpio, tar, or even a simple recursive copy.

I usually use:

find /path/to/orig | cpio -pdmv /path/to/dest

Note that the lowest directory in your original tree will be recreated at the destination, so to move a home directory from /export/home/chuck to /home/chuck, you would use:

find /export/home/chuck | cpio -pdmv /home

I didn't know the cat trick, I like that :slight_smile:

Hello,

First, I apologize in advance for bringing up a question that probably has been answer somewhere in the forum (I've been searching for hours and I finllay decided to post, I'm definitely a noob to UNIX, again sorry).

I am trying to do the same as the original poster, copy/mirror a drive (entire contents) for purpose of backup. Basically duplicate contents of an existing SCSI HardDrive running UNIX SCO Ver.5.0.6 to a new HD, then boot it with a newly backed-up drive to make sure that it works properly.

Reason for this exercise is to make sure that I have a working backup copy before I could setting up RAID or do other potentially stupid things.

I have been reading and sounds like "dd" or "cpio" would do the trick, but I like the simplicity of "dd" unless I misunderstood its functions. I'm a complete newb to UNIX so this could easily happen.

So, is this the path once the backup HD is installed and detected?
dd if=/dev/hda of=/dev/hdb
(where, hda = current drive, hdb = new drive)

If so, any risks or cautions of what not to do?? thank you!!!

This should have been answered 3 years ago by an expert.. shame shame

I'm fresh off the truck but I understand the importance of this question!

First, you are probably use to DOS designations like C: and D: etc., however, in FreeBSD your floppy drive is always FD0 and your hard drives (not the CD) are labeled ad0 ad1 ad4 ad6 (or higher or in between) depending on how they are attached to the system. Attached? like on the IDE controller, on a SATA controller, SCSI and the position they are assigned in bios. For me, finding out that a RAID is usually ar0 was helpful.

So where are your drives??? Simple, do this! at the prompt, type in

ls /dev <enter>

This is going to list all the devices attached to your system and their partitions (? I think).. On my server, I find an ad4 and an ad6 so I would use (hopefully, I'm going to try it here soon):

dd if=/dev/ad4 of=/dev/ad6

This because I want to copy the drive attached to the first controller to the second controller and I DO NOT care if it copies blocks marked as bad so long as the second drive doesn't "really" have bad sectors, it should be a perfect backup for what i want and easier than all the config and slicing ect.

Barry L. Salter

The method that I use to accomplish a bit-by-bit copy of a SCO Openserver 5.0.7 SCSI disk is this:

First, create a small (say, 30 MB) DOS_16 partition on an empty disk. I found that Free Fdisk works great on large SCSI disks. Then format this partition from a bootable DOS floppy (I used MS_DOS ver 6.22); make the new DOS partition bootable by using the DOS "FORMAT C: /S" command. Copy the freeware version of Ranish Partition Manager (for DOS; I use version 2.40.00) to a new directory on this new DOS partition, as well as any other DOS utilities that suit you.

Next, proceed with a fresh install of SCO Openserver, and tell its install routine that you wish to keep the DOS_16 partition intact at the front of the disk, and use the remainder for Unix (and whatever else you wish).

Once SCO Openserver is installed, restart the PC and at the boot manager's "boot:" prompt, enter "dos" (no quotation marks), which will boot DOS from the DOS partition. Run Ranish Partition Manager, and use its D command to copy the entire disk to a second disk. (Play with the program first, to see how versatile and powerful it is. It can copy individual partitions, or an entire disk . . . and it's free.) It works nicely, and is fast, especially if you use EMM386, switch the processor to protected mode, and use DMPI before running Ranish. A 9 GB disk copy takes me less than 10 minutes.

I've used this method to clone a Unix disk a couple times after screwing up my SCO installation and it saves hours of install time.