John, you're right about booting from the live CD.  You usually don't want
to use dd to copy from a mounted (live) filesystem; since it operates at a
block level, any write activity on the source drive during the copy is
likely to produce a corrupt copy. When doing what you want to do, I usually
boot the machine off of a CD and use dd.  If the new drive is larger, or if
I must run in the live machine, I'll partition the new drive with cfdisk
and use rsync to copy the files, then run grub-install to write the boot
track.  In either case, you don't need tar.  Tar doesn't do the right thing
with special files anyway, such as device inodes and sockets, so don't use
it.  (I know much of what I just now said may not make a lot of sense yet.)

Whatever you do, don't get the source and destination drives mixed up.  ;-)


If you want something like a recipe, this google search (on the various
stack exchange web sites) will help:


https://www.google.com/search?q=stack+exchange+clone+drive+linux+dd+rsync

If you want more background and/or have an unusual situation, you'll want
to google for:

- dd
- rsync
- grub
- dmesg  # shows recent hardware activity
- cat /proc/partitions  # shows currently available partitions
- mount # makes an available partition active and attaches it somewhere in
the live filesystem tree
- umount # the Linux equivalent of what you need to do before ejecting
removable media
- chroot

For a boot CD, I usually use systemrescuecd, because it pretty much gives
me a vanilla Linux machine -- I've been working with *nix since the early
80's, so anything more than that just gets in my way for a simple copy.
I've never used clonezilla, but as far as I understand it's got more drive
cloning tools added for what you want to do.  It's also got a lot of
network-based bits in there, the kind of thing needed for multi-machine
deployments, which adds a lot of complexity, but you can just ignore all
that for your use case.

Finally, here's my own completely untested example showing what I usually
would do if using rsync.  I'm probably missing some steps here, and I've
simplified stuff, so use this only as a guide, not a recipe:

Assuming sdc is the source drive and sdd is the destination:

cfdisk /dev/sdd   # make a big Linux partition called sdd1, and a swap
partition roughly 2x RAM size called sdd2
mkfs.ext4 /dev/sdd1  # format sdd1  (caution -- make dead sure sdd1 is the
destination)
mkswap /dev/sdd2  # format swap partition (caution)
mkdir /mnt/sdc1
mkdir /mnt/sdd1
mount /dev/sdc1 /mnt/src  # make source accessible under /mnt/src
mount /dev/sdd1 /mnt/dst  # make destination accessible under /mnt/dst
ls -la /mnt/src  # confirm you're looking at the old drive
ls -la /mnt/dst # confirm this is the new drive -- only thing showing
should be an empty lost+found directory
rsync -HaSx  /mnt/src/ /mnt/dst/  # do the copy -- all of these flags are
important, as well as the trailing slashes
rsync -PHaSvx /mnt/src/ mnt/dst/  # alternative, verbose version of the
above command
mount -t proc none /mnt/dst/proc   # get things set up for the chroot
mount -o bind /dev /mnt/dst/dev
mount -t sysfs sys /mnt/dst/sys
chroot /mnt/dst/ /bin/bash  # start a new shell using /mnt/dst as /
grub-install /dev/sdd  # install boot loader (caution)
exit   # leave the chroot
umount /mnt/dst/proc  # tear down the chroot
umount /mnt/dst/dev
umount /mnt/dst/sys
umount /dev/sdc1  # detach the source and target drives from the live
filesystem tree
umount /dev/sdd1

All of that mount and chroot stuff towards the end is to enable you to use
the new drive's version of grub to install the boot loader in the boot
track of the new drive.  Google for 'chroot grub-install' for more details
about this.

Steve

On Sat, Feb 20, 2016 at 9:28 AM, <tom-...@bgp.nu> wrote:

>
> >> On Feb 20, 2016, at 11:56 AM, Chris Albertson <
> albertson.ch...@gmail.com> wrote:
> >> Note that to close a device you need identical hardware.
> >
> > To clarify, you don’t need “identical” hardware.  You need a disk that
> is the same size or larger to clone a disk.
> > -Tom
>
> And, I should add, that if the disk is larger the extra space is not used
> (due to the partition map).  There are tricks to add that space (or expand
> into it).
> -Tom
>
>
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
> _______________________________________________
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to