LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Will dd command make an exact copy (clone) of a disc (https://www.linuxquestions.org/questions/linux-newbie-8/will-dd-command-make-an-exact-copy-clone-of-a-disc-630289/)

pafos 03-24-2008 01:44 PM

Will dd command make an exact copy (clone) of a disc
 
Hi--I am still finding my way round Knoppix Linux so I have this question to ask as a newbie to Linux

I have a PVR which has an HDD in it. I want to make an exact copy of it to put it into another machine. This HDD has two Linux partitions (ext2). One contains the machine software and the other the data files. The machine boots from the first partition when powered on.
My question is, if I use the dd command e.g dd if=/dev/hda of=/dev/hdb where hda is the old disc and hdb the new one to be made, will this copy ALL the disc including the boot information and the partition details. The two discs are identical models. In other words is it a bootable exact copy.
If not any suggestions for the best way to proceed.

thanks in advance for any help :)

pixellany 03-24-2008 01:57 PM

Welcome to LQ!!

For dd, you have it exactly right. The only refinement might be to play with the block size to make it go a bit faster. I've never run tests, but I think that the block size that fits comfortably into available RAM is the fastest.

Do a couple of trial runs with something like these:

dd if=/dev/hda of=/dev/hdb bs=10M count=10

dd if=/dev/hda of=/dev/hdb bs=100M count=1

This will tell you which is fastest, and how long the total copy is going to take. (Hint: You may want to start it before going to bed.)

Finally, be REALLY SURE which drive is hda and which is hdb....;)

onebuck 03-24-2008 11:45 PM

Hi,

I would suggest that you look at 'Learn The DD Command Revised'.

You do have it right. I would also suggest that you 'man dd'.

pafos 03-25-2008 04:29 AM

Thank you for your replies. You state

Do a couple of trial runs with something like these:

dd if=/dev/hda of=/dev/hdb bs=10M count=10

dd if=/dev/hda of=/dev/hdb bs=100M count=1

I am not certain how to do trial runs or is it implied in the count command. Sorry to ask but this one is new to me.
Thanks ;)

pixellany 03-25-2008 05:04 AM

Each of the two examples I gave will copy only 100Mbytes. By looking at the time required, you can estimate how long the total copy is going to take.

"man dd" will explain all the options (bs = block size, count = # of blocks to copy)

tredegar 03-25-2008 08:19 AM

pafos
If I were you, I'd run the dd command from a live cd, it's not always a good idea to clone a system while it is running. And as pixellany said, be really really really sure which is /dev/sda and which is /dev/sdb or you will find that you have wiped your installation :(

pixellany 03-25-2008 02:17 PM

Quote:

Originally Posted by tredegar (Post 3099793)
pafos
If I were you, I'd run the dd command from a live cd, it's not always a good idea to clone a system while it is running.

WHACK!!!! (I just disciplined myself for not mentioning this......;)) I would say never even think about running dd on an active partition.

tredegar 03-25-2008 03:53 PM

Quote:

I would say never even think about running dd on an active partition.
So could I, but I was being polite :)

No harm done though, as long as he doesn't get his disks muddled up, which is our primary concern.

If he does the dd on a running system, the cloned disk may not function as expected (the presence of lock-files and all that...) In which case I expect he'll be back, and read the solution here.

In your defence, knoppix is widely regarded as a brilliant liveCD for getting one out of the "Oops, I hadn't thought of that. Now how can I get back in there and .. [tweak my fstab or reinstall grub] so I can get my linux to boot?". We probably all have an old knoppix CD buried somewhere, that we dig out and boot live in case of another careless, drastic misconfiguration. So we (well, I) tend to think of it as a LiveCD, not an installation. That may yet be his situation, perhaps we'll discover.

So pixellany, I think you should take the hairshirt off right now ;)

pafos 03-26-2008 04:33 AM

Hi Guys

Thanks for all the tips. Yes, I am using the live CD version and I will also be removing my system HDD from the PC to prevent an accidental wipe.

pafos 03-27-2008 05:33 AM

Hi Guys again

Just one thought. The disk that I will be copying TO is formatted with a single NTFS partion. Will DD command copy the ext2 file system over from the old HDD or should I reformat in Linux with a ext2 file system BEFORE I do the copy.
Regards to all ;)

pixellany 03-27-2008 06:14 AM

dd will copy to and from a file, but--for what you are doing--it reads and writes the raw data (which includes the filesystem, partition tables, etc. It does not matter what is on the target drive--it will wind up being exactly like the source.

konsolebox 03-27-2008 10:12 PM

this is just an alternative.. you can backup your working root partition by doing mounting it on a different directory (not root) and tarring the files inside it:

Code:

mount /dev/sda1 /mnt/root
cd /mnt/root
tar -cpzf /somewhere/sda1.tar.gz *
or
tar -cpzf /somewhere/sda1.tar.gz $(ls | sort)

note that there are some drawbacks here like if you mount /var with a different partition

edit: no problem if only about sda1.. perhaps with runtime files... but you can prevent this by
close io heavy programs first.

aus9 03-27-2008 10:31 PM

there are forums for pvr as well.

do you have an error with your STB saying the drive is full by any chance?

pafos 03-28-2008 04:38 AM

Thanks to all. I will try it all out this weekend as Imagine that it will not be quick.

Ref AUS9 's remark re disc full message. No, the disc is fine in the PVR, just that it is a Panasonic PVR. I Have several of these but the most recently aquired one has the very original software on it which was full of problems. My other ones all have the latest software version and It is that I want to clone. Panasonic will not send out any more "over the air updates" nor will they offer any suppport directly so I am left with a cloning as the only way out short of legal action.
Thanks again and if it all works out I will post again.

aus9 03-28-2008 07:01 AM

others may not be aware of this forum so its
http://www.dtvforum.info/index.php?

aussie flavour of course


All times are GMT -5. The time now is 07:22 AM.