How to clone a HD


Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: How to clone a HD

  1. #1
    Join Date
    Aug 2003
    Location
    Sweden
    Posts
    123

    How to clone a HD

    I have this hard drive and it seems to be a little defect. I'd like to make an exact copy of it onto another HD, so that I don't have to re-install everything, but I need some info on how to do this (cut'n'paste sounds too simple to be enough... )

  2. #2
    Join Date
    Apr 2003
    Location
    chile-valpo
    Posts
    60
    well, if they have same specs(size), U can use dd

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

    (if: input file of: output file)

    this one copies all the content of hda (including the partition tables and boot sector and unused space) to hdb. hdb must not be mounted.

    I guess dd if=/dev/hda1 of=/dev/hdb1 must clone a partition in a HD, but the only time i tried that the HD was old and could'nt say that it works.

    for copying only used space search for replicator (debian).

    if u want to clone across the net, you could use nc & dd , with a knoppix or another live unix on the destination.

  3. #3
    Join Date
    Aug 2003
    Location
    Sweden
    Posts
    123

    Thanks!

    Thanks, sounds great! Replicator sounds interesting, I'll check it out. Unfortunately I don't think they have the same specs, so dd probably won't work then.

  4. #4
    Join Date
    Apr 2003
    Location
    UK
    Posts
    1,180
    They don't have to be the same size for the dd command to work, though hdb would have to be at least the size of hda. You would however need to need to use something like parted to resize the partition to make use of any extra space.

  5. #5
    Join Date
    Apr 2003
    Location
    chile-valpo
    Posts
    60
    if i run:

    dd bs=512 count=1 if=/dev/hda1 of=/dev/hdb1

    and later:

    cp -R hda1_folder hdb1_folder
    ## i don't know how to make it copy .files

    what i get?

  6. #6
    Join Date
    Apr 2003
    Location
    Buenos Aires, Argentina
    Posts
    4,219
    Originally posted by angustia
    cp -R hda1_folder hdb1_folder
    ## i don't know how to make it copy .files
    If hda1_folder has hidden directories inside, they will get copied.
    djserz.com.ar
    "All the drugs in this world won't save you from yourself..."

  7. #7
    Join Date
    Apr 2003
    Location
    chile-valpo
    Posts
    60
    error, was:
    cp -R hda1_folder/* hdb1_folder

  8. #8
    Join Date
    Aug 2003
    Location
    Sweden
    Posts
    123
    Well then dd sounds terriffic

  9. #9
    Join Date
    Nov 2004
    Posts
    62
    dd seems to fail is there are I/O errors (due to a defect HD). If that happens, you can use a noerror flag, see `man dd` for details.

    cp -R only copies recursivly, but permissions are not preserved and the target files will be owned by root. To preserve them and excactly copy the files, you should use `cp -a`.

    If the hd is really defective, you'd better use cp -a since wrong or missing 'raw FS blocks' can mess up your whole file system.
    Last edited by welmers; 12-25-2004 at 11:24 AM.

  10. #10
    Join Date
    Aug 2003
    Location
    Sweden
    Posts
    123
    OK... What about filesystems that are also used by Windows? Like NTFS... how are the windows file permissions preserved when using cp?

    I'm just curious... I'm planning on using dd if=/dev/hda of=/dev/hdb, so it won't be a problem then I assume.

  11. #11
    Join Date
    Feb 2004
    Location
    Singapore
    Posts
    2,170
    on many rescue cds there is also the option to use the partimage. it can actually read partitions and is not as low level as dd. thus it may be easier and more powerful to do partimage than cp -a
    Come under the reign of the Idiot King...
    Come to me ... I love linux!

    Registered Linux user: Idiot King #350544

  12. #12
    Join Date
    Aug 2003
    Location
    Sweden
    Posts
    123
    Sorry for continuing on an old thread like this, but I felt that it was unnessesary to start a new one.

    The scenario has changed a little; now I need to backup one particular partition (my debian partition) for later restoration. The partition is a logical partition, does this matter?

    I've read a little more about replicator, and I'm wondering if it's the way to go if I just want to copy this particulat partition?

    From what I've understood, Win98 can only handle 4 primary partitions, so if I want more than 4 I have to use a logical partition. However, since Win98 can't read my Reiser partitions, it only sees two. What would happen if I created 5 partitions? Will Win98 see the first four and ignore the rest?

    (if you're wondering why I need to do all this, it's because I have only partitioned about half the HD, and I can't add more partitions to the logical partition, so about 30Gb is unused and unavailable)

  13. #13
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    Originally posted by jot-87
    now I need to backup one particular partition (my debian partition) for later restoration. The partition is a logical partition, does this matter?
    No, it does not. Once you know the Linux number (1 through 4 are primary partitions, and the first logical partition is 5) of the partition you want to back up, just do the same thing you did with the entire disk, except with that partition instead. I.e., instead of "dd if=/dev/hda of=whatever", you'd do "dd if=/dev/hda6 of=whatever" (without the quotes, obviously -- And the "whatever" in the second case should be some partition on hdb, not hdb itself). hda6 is the second logical partition on the primary master hard drive.

    From what I've understood, Win98 can only handle 4 primary partitions,
    Well, no, not really. The thing that can't handle more than 4 primary partitions is your DOS-format partition table (however, nothing in the partition table format prevents all 4 primary partitions from being extended partitions instead (extended partitions contain logical partitions)). However, Win98 (and all other versions of Windows) can only handle one primary partition -- no more, and (AFAIK anyway) no less.

    What would happen if I created 5 partitions? Will Win98 see the first four and ignore the rest?
    If the first 3 are primary (the 4th "main" partition must be extended, to contain 2 more logical partitions), then actually, it may not even see the first one. But it definitely won't see more than the first one. If you make one primary and one extended partition, then put 4 logical partitions inside the extended one, 98 will be able to see all of them (though of course, it won't assign a drive letter to any partitions that have a filesystem it doesn't understand, like ReiserFS, or in fact anything other than FAT16 or FAT32).

    Two things determine whether Windows assigns a drive letter: First, can it see the partition at all? Second, does it understand the filesystem in place on the partition? If the answer to either of these is no, then it won't assign that partition a drive letter.

  14. #14
    Join Date
    Aug 2003
    Location
    Sweden
    Posts
    123
    Thanks so much, this will really help me not screwing up and having to install everything over again

    So my DOS-format partition table can only handle four... But with Linux I can use any number of primary partitions, right? I think I'll see what happens if I make all partitions primary... Once i have my Debian partition backuped, I don't really have anything to lose.

  15. #15
    Join Date
    Oct 2003
    Location
    WV
    Posts
    298
    Just my .02, Ghost for Lin is a great tool for cloning. But you need to have an FTP server on your network first. Link
    Sometimes when I reflect back on all the beer I drink I feel ashamed - Then I look into the glass and think about the workers in the brewery and all of their hopes and dreams. If I didn't drink this beer, they might be out of work and their dreams would be shattered. Then I say to myself, "It is better that I drink this beer and let their dreams come true than be selfish and worry about my liver."

    -Deep Thought, Jack Handey

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •