LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-24-2008, 01:44 PM   #1
pafos
LQ Newbie
 
Registered: Mar 2008
Posts: 6

Rep: Reputation: 0
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
 
Old 03-24-2008, 01:57 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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....
 
Old 03-24-2008, 11:45 PM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,712
Blog Entries: 27

Rep: Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055
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'.
 
Old 03-25-2008, 04:29 AM   #4
pafos
LQ Newbie
 
Registered: Mar 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Question

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
 
Old 03-25-2008, 05:04 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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)
 
Old 03-25-2008, 08:19 AM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
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
 
Old 03-25-2008, 02:17 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by tredegar View Post
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.
 
Old 03-25-2008, 03:53 PM   #8
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
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
 
Old 03-26-2008, 04:33 AM   #9
pafos
LQ Newbie
 
Registered: Mar 2008
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 03-27-2008, 05:33 AM   #10
pafos
LQ Newbie
 
Registered: Mar 2008
Posts: 6

Original Poster
Rep: Reputation: 0
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
 
Old 03-27-2008, 06:14 AM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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.
 
Old 03-27-2008, 10:12 PM   #12
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
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.

Last edited by konsolebox; 03-27-2008 at 10:21 PM.
 
Old 03-27-2008, 10:31 PM   #13
aus9
LQ Guru
 
Registered: Oct 2003
Distribution: Fedora 25 Gnome (Wayland)
Posts: 5,132

Rep: Reputation: Disabled
there are forums for pvr as well.

do you have an error with your STB saying the drive is full by any chance?
 
Old 03-28-2008, 04:38 AM   #14
pafos
LQ Newbie
 
Registered: Mar 2008
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 03-28-2008, 07:01 AM   #15
aus9
LQ Guru
 
Registered: Oct 2003
Distribution: Fedora 25 Gnome (Wayland)
Posts: 5,132

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

aussie flavour of course
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
make exact copy of hda1 for new HD nephish Linux - General 5 06-24-2006 04:49 PM
How do I make an exact copy of a movie DVD u6jaf Linux - Software 1 07-08-2004 12:45 PM
make an exact copy of Fedora from 1 PC to another lothario Linux - Newbie 1 06-04-2004 12:34 PM
How to make an exact copy of a Hard Disk danishmr Linux - General 15 11-10-2003 01:48 AM
Disc clone/copy szak Linux - Newbie 1 01-21-2002 07:40 AM


All times are GMT -5. The time now is 11:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration