How to clone a partition - Linux

This is a discussion on How to clone a partition - Linux ; Hello, I'm running a Slackware 9.1 / Pentium III system. I want to create an exact clone of my system (which is just one partition) onto a second "backup" IDE hard drive, such that I could take the backup drive, ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to clone a partition

  1. How to clone a partition

    Hello,

    I'm running a Slackware 9.1 / Pentium III system. I want to create an
    exact clone of my system (which is just one partition) onto a second
    "backup" IDE hard drive, such that I could take the backup drive, put
    it on the first channel, and boot it just like the original hard
    drive.

    I've created a partition on the second drive, set it bootable, and
    mke2fs'ed it. Then I ran:

    rsync -ax --delete / /mnt/20gigbackup

    ....which causes /mnt/20gigbackup to be an exact copy of /, excluding
    any mount-points below / which are on other filesystems (-x option).
    The -a (archive) option is a combination of a bunch of other options
    that basically means "clone the source exactly."

    The only thing I'm unsure about is that -a doesn't include -H, which
    is the "hard links" option to rsync, described like this in the
    manpage:

    > -H, --hard-links
    > This tells rsync to recreate hard links on the remote system
    > to be the same as the local system. Without this option hard
    > links are treated like regular files.


    Not being very sure about just what a hard link is, I read the ln
    manpage, and it says that a hard link is "just a name for a file."

    OK, I guess that sort of makes sense, but then why wouldn't the -a
    option to rsync include -H? If you're using rsync to archive (-a) a
    directory, wouldn't you want things copied just as they are, instead
    of having "hard links...treated like regular files"?

    Thanks,
    Anthony
    http://nodivisions.com/

  2. Re: How to clone a partition

    Anthony wrote:
    > Hello,
    >
    > I'm running a Slackware 9.1 / Pentium III system. I want to create an
    > exact clone of my system (which is just one partition) onto a second
    > "backup" IDE hard drive, such that I could take the backup drive, put
    > it on the first channel, and boot it just like the original hard
    > drive.


    The simplest method would be to use DD to clone the partition or the
    entire drive.

    Something along the lines of dd if=/dev/hda1 of=/dev/hdb1 after you've
    created the partition on /dev/hdb should handle it easily, and it will
    be a bit for bit copy.

    --
    Chris Shepherd


  3. Re: How (not) to clone a partition

    On Tuesday 28 October 2003 01:42 pm, Chris Shepherd wrote:

    > Anthony wrote:
    >> Hello,
    >>
    >> I'm running a Slackware 9.1 / Pentium III system. I want to create an
    >> exact clone of my system (which is just one partition) onto a second
    >> "backup" IDE hard drive, such that I could take the backup drive, put
    >> it on the first channel, and boot it just like the original hard
    >> drive.

    >
    > The simplest method would be to use DD to clone the partition or the
    > entire drive.


    I disagree.

    dd is useful for creating binary images. Which work when the target
    medium is an exact clone of the target. For floppies or CDROMs, this
    may well be the case.

    For keeping an active, "hot" backup, far better would be to create an
    initial tar backup of the live system, then periodically update the
    system via rsync. There's actually a neartime mirror solution that does
    this (IIRC it's packaged for Debian). Possibly drsync.

    > Something along the lines of dd if=/dev/hda1 of=/dev/hdb1 after you've
    > created the partition on /dev/hdb should handle it easily, and it will
    > be a bit for bit copy.


    Generally:

    - This takes too long.
    - It's useful in only a very few scenarios.
    - It's touch to keep in sync.

    If you're doing forensics on a bad drive, propogating floppies or CDs,
    or zeroing out partitions, DD can be useful. Otherwise use an
    appropriate *file* syncronization or archival tool.


    Peace.

    --
    Karsten M. Self http://kmself.home.netcom.com/
    What Part of "Gestalt" don't you understand?
    George W. is deceptive to be sure. Dissembling, too. And let's not
    forget deceitful. He is lacking veracity and frankness, and void of
    sooth, though seemingly sincere in his proclivity for pretense. But
    he did not lie.
    http://www.jointhebushwhackers.com/not_a_liar.cfm

  4. Re: How to clone a partition

    Anthony wrote:
    > Hello,
    >
    > I'm running a Slackware 9.1 / Pentium III system. I want to create an
    > exact clone of my system (which is just one partition) onto a second
    > "backup" IDE hard drive, such that I could take the backup drive, put
    > it on the first channel, and boot it just like the original hard
    > drive.
    >
    > I've created a partition on the second drive, set it bootable, and
    > mke2fs'ed it. Then I ran:
    >
    > rsync -ax --delete / /mnt/20gigbackup
    >
    > ...which causes /mnt/20gigbackup to be an exact copy of /, excluding
    > any mount-points below / which are on other filesystems (-x option).
    > The -a (archive) option is a combination of a bunch of other options
    > that basically means "clone the source exactly."
    >
    > The only thing I'm unsure about is that -a doesn't include -H, which
    > is the "hard links" option to rsync, described like this in the
    > manpage:
    >
    >
    >>-H, --hard-links
    >>This tells rsync to recreate hard links on the remote system
    >>to be the same as the local system. Without this option hard
    >>links are treated like regular files.

    >
    >
    > Not being very sure about just what a hard link is, I read the ln
    > manpage, and it says that a hard link is "just a name for a file."
    >
    > OK, I guess that sort of makes sense, but then why wouldn't the -a
    > option to rsync include -H? If you're using rsync to archive (-a) a
    > directory, wouldn't you want things copied just as they are, instead
    > of having "hard links...treated like regular files"?
    >
    > Thanks,
    > Anthony
    > http://nodivisions.com/


    Instead of using rsync, I'd suggest using dd. dd will read one device
    bit-for-bit and dump it to a second device. It doesn't care what it's
    reading, so it will copy partition info and everything (even works with
    NTFS). Only problem is, the drive can't be mounted. Just boot from a
    bootable floppy and do:

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

    Does this help?

    Brandon


+ Reply to Thread