You are not logged in.

#1 2009-01-21 01:47:29

Matt3232
Member
Registered: 2009-01-21
Posts: 11

A question about using dd to clone disks

Hello, I currently have all my data on a 500gb hard drive.  I recently bought a 640gb hard drive that I want to use as my main drive so I will have more room for an archlinux install, while leaving the 500gb drive empty for backups.  I'm planning on just booting up the arch CD and using dd to copy all of the data.  Will there be any problems because the disks are not the same capacity?  Will the extra 140gb be available to use if I am copying from a smaller hard drive?  Also, the 500gb drive will still have the Windows bootloader on it after I remove the partitions, how can I remove this bootloader?  Thanks in advance for the help.

Last edited by Matt3232 (2009-01-21 01:48:25)

Offline

#2 2009-01-21 02:30:41

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Re: A question about using dd to clone disks

Why not mount both drives and then copy the files with the copy command?

Something like:
mount /dev/sda1 /mnt/old
mount /dev/sdb1 /mnt/new

cp -av /mnt/old/* /mnt/new


Website - Blog - arch-home
Arch User since March 2005

Offline

#3 2009-01-21 02:37:14

yingwuzhao
Member
Registered: 2009-01-13
Posts: 109

Re: A question about using dd to clone disks

cp and dd is not so reliable sometimes.

An better way to do back up is to the old fashioned way: the tar command,

 tar cf - * | (cd destination/; tar xfp -)

will copy your current directory to the destination/, I wrote this on the Arch Wiki. Search "tar" you will see it and find more information.

Offline

#4 2009-01-21 02:38:35

PatJr
Member
Registered: 2009-01-18
Posts: 8

Re: A question about using dd to clone disks

Might be some problems with the disk ids?

http://en.wikipedia.org/wiki/Universall … Identifier

Why not use the new disk for the backups, fresh install Arch on the new disk?

If you put grub on the new disk, set your bios to boot from the new drive and set the chainloader to boot Windows from the other drive? Sometimes Windows wants to use it's own bootloader. I used the map function in grub to deal with this problem.

I am not an expert here at all, only offering opinions. A guess is that Arch would have better luck with getting moved over to the new disk then Windows, especially Vista.

Best of Luck,
Pat Jr.

Offline

#5 2009-01-21 02:51:54

lilsirecho
Veteran
Registered: 2003-10-24
Posts: 5,000

Re: A question about using dd to clone disks

I have used dd to transfer a smaller drive to a larger drive with no problem.


Prediction...This year will be a very odd year!
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit!     X-ray confirms Iam spineless!

Offline

#6 2009-01-21 02:57:06

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Re: A question about using dd to clone disks

yingwuzhao wrote:

cp and dd is not so reliable sometimes.

An better way to do back up is to the old fashioned way: the tar command,

 tar cf - * | (cd destination/; tar xfp -)

will copy your current directory to the destination/, I wrote this on the Arch Wiki. Search "tar" you will see it and find more information.

How do you come up with that conclusion?
You're actually probably "risking" more by taring/untaring, especially like that!!!

Last edited by pyther (2009-01-21 03:00:26)


Website - Blog - arch-home
Arch User since March 2005

Offline

#7 2009-01-21 03:31:43

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: A question about using dd to clone disks

pyther wrote:

How do you come up with that conclusion?
You're actually probably "risking" more by taring/untaring, especially like that!!!

I agree. cp and dd are very reliable. Taring and untaring carries a greater risk of something going wrong. It may even be more time consuming and I can see no benefit in doing it.

Offline

#8 2009-01-21 03:37:25

yingwuzhao
Member
Registered: 2009-01-13
Posts: 109

Re: A question about using dd to clone disks

Google it, you will see, tar command as well as cpio command are 2 of the most commonly used ways for system administer to backup partitions.
People put it into conk and let it backup newly modified files automatically. It's been used for decades, and proved to be one the best ways for Unix backup.

tar was originally written to be used to backup files to tapes (in those old days). The command I give does NOT zip anything up, it function purely as coping files, since I didn't put "z" option there.  "p" option means preserve permission and time stamp. Tar has been thought to be much reliable than cp when comes to system backup.

And the time of copying using tar is the same and even faster than cp. Googling Unix backup, you will see the expert view of using tar as backup command. big_smile

In fact, I learn this from the system administer of my department, who has been managed hundreds of computers and servers for more than 10 years, and do backup on a weekly to monthly bases. He is one of the most fearful expert in Unix I have ever met. smile

Last edited by yingwuzhao (2009-01-21 03:50:29)

Offline

#9 2009-01-21 03:41:15

Matt3232
Member
Registered: 2009-01-21
Posts: 11

Re: A question about using dd to clone disks

I can only use dd because there is no filesystem on the new drive, but I may use tar or cp when I'm making backups later.  I think I'll just reinstall Windows onto the new drive, copy my files over and install arch.  Then I'll wipe the 500gb drive and make a big FAT32 partition for shared storage and backups.  If I use "dd if=/dev/zero of=/dev/sdb bs=512 count=1" to erase my MBR(Because I don't need a bootloader on a storage drive) can I then just use cfdisk to make the FAT32 partition or will I have to regenerate the MBR or something like that?

Last edited by Matt3232 (2009-01-21 03:41:50)

Offline

#10 2009-01-21 03:50:24

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,549

Re: A question about using dd to clone disks

cp has served me well so far, just make sure to read the man page first so you know how to deal with permissions, links, special files, etc.

To your last question, Matt, just forget about zeroing the MBR tongue I'm not sure if it's possible, (I'm not extremely familiar with how the MBR works at all) but it's 512 bytes. Half of a KB. There's no point, it may just cause trouble tongue

That said, it'd be cool if someone could go more into how the MBR works through that, I'd like to learn tongue

Offline

#11 2009-01-21 04:09:40

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: A question about using dd to clone disks

I always use a procedure analogous to the one described in this guide for these sorts of tasks: http://inferno.slug.org/cgi-bin/wiki?Dr … nd_Cloning  I used it just now, in fact, to change the root fs to ext4.  As far as I know copying should work just as well as using tar.gz archives, as long as you're preserving permissions, ownership and so on.

Offline

#12 2009-01-21 04:32:12

neowolf
Member
From: North Carolina
Registered: 2008-01-27
Posts: 105

Re: A question about using dd to clone disks

If you just want to make regular backups.. I'd highly recommend checking out clonezilla. Linux livecd with tools meant just for the job. Kinda a poor man's ghost, but better in a lot of areas. wink

Offline

#13 2009-01-21 10:34:07

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Re: A question about using dd to clone disks

Matt3232 wrote:

I can only use dd because there is no filesystem on the new drive, but I may use tar or cp when I'm making backups later.  I think I'll just reinstall Windows onto the new drive, copy my files over and install arch.  Then I'll wipe the 500gb drive and make a big FAT32 partition for shared storage and backups.  If I use "dd if=/dev/zero of=/dev/sdb bs=512 count=1" to erase my MBR(Because I don't need a bootloader on a storage drive) can I then just use cfdisk to make the FAT32 partition or will I have to regenerate the MBR or something like that?

You don't have to use dd, you can format the new drive with a file system. This is how I'd do everything if I was in your shoes.....

/dev/sda = old drive
/dev/sdb = new drive

fdisk/cfdisk /dev/sdb - create partation
mkfs.ext3 /dev/sdb1 - format partation as ext3 (or whatever fs you want)

mount /dev/sda1 /mnt/old
mount /dev/sdb1 /mnt/new

cp -rv /mnt/old/* /mnt/new

Then to install grub....

mount -o bind /dev /mnt/new/dev
mount -t proc none /mnt/new/proc

chroot /mnt/new /bin/bash

modify /etc/fstab if needed

grub-install /dev/sdb

exit (exit's chroot)

umount /mnt/new/proc
umount /mnt/new/dev
umount /mnt/new
umount /mnt/old

Once done verify you can boot from the new drive and everything works without a problem. To be 100% certain unplug the old drive and try to boot only with the new. If this works you can then format the old drive.


Website - Blog - arch-home
Arch User since March 2005

Offline

Board footer

Powered by FluxBB