LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 10-07-2012, 10:43 AM   #1
13_
LQ Newbie
 
Registered: Oct 2012
Posts: 13

Rep: Reputation: Disabled
Cloning a drive.


Hi, I was wondering if anyone could tell me the best way to clone a hard drive. I was looking at Clonezilla but was wondering if it could be done with dd within slackware.

Thanks.
 
Old 10-07-2012, 11:01 AM   #2
Martinus2u
Member
 
Registered: Apr 2010
Distribution: Slackware
Posts: 338

Rep: Reputation: 41
Quote:
Originally Posted by 13_ View Post
wondering if it could be done with dd
yes but it only really makes sense if both drives have excatly the same size and geometry. Theoretically you have a few options using dd in case the second drive is larger. However, I would clearly advocate creating fresh filesystems and copying on file level.
 
Old 10-07-2012, 11:32 AM   #3
13_
LQ Newbie
 
Registered: Oct 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
So with different size drives this wouldn't work with dd?
 
Old 10-07-2012, 11:41 AM   #4
mutput7
LQ Newbie
 
Registered: Oct 2012
Location: A magical place full of Canadian dirt.
Distribution: Arch Linux
Posts: 12

Rep: Reputation: 4
Not if the new drive if smaller.
If the new drive is larger, you can just
Code:
dd if=/dev/OLDDRIVE of=/dev/NEWDRIVE
And resize the new drive's partitions with (e.g.) GParted.
(Make ABSOLUTELY sure you don't mix them up!)
 
1 members found this post helpful.
Old 10-07-2012, 11:42 AM   #5
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-19-live-usb/ aix
Posts: 3,551

Rep: Reputation: 513Reputation: 513Reputation: 513Reputation: 513Reputation: 513Reputation: 513
with dd if you clone a 100 gb drive to a 10 gb drive it will get truncated and probably wont boot (like pouring a gallon of paint into a quart container -- you will get a lot of spillage).

if you clone a 10 gb drive to a 100 gb drive. it will boot up but will act as if it has only 10 gb of space (you will be wasting 90 gb). there are probably ways to use gparted to make the rest of the space useful (i think that is how some live-usb's do it).

Last edited by schneidz; 10-07-2012 at 11:44 AM.
 
Old 10-07-2012, 11:44 AM   #6
manwichmakesameal
Member
 
Registered: Aug 2006
Distribution: Slackware
Posts: 800

Rep: Reputation: 99
Couldn't you just mount both of them and use rsync?
 
Old 10-07-2012, 11:51 AM   #7
escaflown
Member
 
Registered: Apr 2009
Location: Canada
Distribution: Slackware
Posts: 235

Rep: Reputation: 30
Quote:
Originally Posted by 13_ View Post
Hi, I was wondering if anyone could tell me the best way to clone a hard drive. I was looking at Clonezilla but was wondering if it could be done with dd within slackware.

Thanks.
Using dd to clone a live partition/drive might not be a good practice. You might have to run dd from a live distribution to clone the drive while it is not in use.
 
1 members found this post helpful.
Old 10-07-2012, 11:57 AM   #8
mutput7
LQ Newbie
 
Registered: Oct 2012
Location: A magical place full of Canadian dirt.
Distribution: Arch Linux
Posts: 12

Rep: Reputation: 4
Quote:
Originally Posted by escaflown View Post
Using dd to clone a live partition/drive might not be a good practice. You might have to run dd from a live distribution to clone the drive while it is not in use.
I can't believe I forgot that. If you use dd, you should also really try and make sure you do it from some LiveCD/DVD/USB or something.
 
Old 10-07-2012, 11:58 AM   #9
13_
LQ Newbie
 
Registered: Oct 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
So, if I used identical drives

dd=/dev/OLDDRIVE of=/dev/NEWDRIVE

would work? And the new cloned drive would boot?
 
Old 10-07-2012, 12:02 PM   #10
mutput7
LQ Newbie
 
Registered: Oct 2012
Location: A magical place full of Canadian dirt.
Distribution: Arch Linux
Posts: 12

Rep: Reputation: 4
Quote:
Originally Posted by 13_ View Post
So, if I used identical drives

dd=/dev/OLDDRIVE of=/dev/NEWDRIVE

would work? And the new cloned drive would boot?
I replaced a dying drive like this once, so I'm pretty sure it will work for you. Just remember that it's safest to do it from some live removable media. Good luck!
 
Old 10-07-2012, 12:06 PM   #11
13_
LQ Newbie
 
Registered: Oct 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
mutput, if I wanted to keep a clone image on spare drive how would you do that?

dd=/dev/OLDDRIVE of=/root/clone.iso

To use repeatedly.
 
Old 10-07-2012, 12:10 PM   #12
mutput7
LQ Newbie
 
Registered: Oct 2012
Location: A magical place full of Canadian dirt.
Distribution: Arch Linux
Posts: 12

Rep: Reputation: 4
Quote:
Originally Posted by 13_ View Post
mutput, if I wanted to keep a clone image on spare drive how would you do that?

dd=/dev/OLDDRIVE of=/root/clone.iso

To use repeatedly.
I'm not sure I understand, but if I do, then

dd if=/dev/OLDDRIVE of=/SPAREDRIVEMOUNT/path/to/backup.img.iso.bak.clone.drv

Should work for what I think you mean.
 
1 members found this post helpful.
Old 10-07-2012, 12:14 PM   #13
13_
LQ Newbie
 
Registered: Oct 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Yes, that's what I was meaning, thanks.
 
Old 10-07-2012, 04:54 PM   #14
riwi
LQ Newbie
 
Registered: Jul 2011
Location: space
Distribution: Slackware 14.0
Posts: 27

Rep: Reputation: Disabled
Quote:
Originally Posted by 13_ View Post
So, if I used identical drives

dd=/dev/OLDDRIVE of=/dev/NEWDRIVE

would work? And the new cloned drive would boot?
I use this to backup my slackware systems.
Even from a booted drive it works OK.

After booting with the backed up drive it looks as if it was switched off suddenly so the filesystem check will repair any 'open' files.

https://wiki.archlinux.org/index.php/Disk_Cloning

Also add the bs=1M option so the copying will go faster.

You could also copy 'per partition' and MBR+partition table separately
like :
dd if=/dev/sda of=/dev/sdb bs=512 count=1
dd if=/dev/sda1 of=/dev/sdb1 bs=1M
dd if=/dev/sda2 of=/dev/sdb2 bs=1M
etc.

Nice trick (during copying):
find the pid of the dd process : ps -ef | grep dd
from another terminal : kill -s SIGUSR1 <pid>
That will print the amount of data copied so far.

Ofcourse if you could unmount the drive to be copied that is preferable.

Last edited by riwi; 10-07-2012 at 04:54 PM. Reason: added link
 
2 members found this post helpful.
Old 10-08-2012, 09:31 AM   #15
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-19-live-usb/ aix
Posts: 3,551

Rep: Reputation: 513Reputation: 513Reputation: 513Reputation: 513Reputation: 513Reputation: 513
this thread has a lot of info on dd:
http://www.linuxquestions.org/questi...ommand-362506/
 
1 members found this post helpful.
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cloning a drive with dd scandalist Linux - Newbie 19 06-25-2012 08:06 PM
Cloning dual-boot drive onto a smaller drive. Harju Linux - Newbie 4 05-29-2010 11:40 AM
cloning a drive with dd gdanko Linux - General 3 01-20-2010 01:11 PM
Need help in cloning drive raddad51x Fedora 1 05-16-2006 01:31 AM
Cloning a hard drive davcefai Debian 3 11-28-2005 05:36 PM


All times are GMT -5. The time now is 02:12 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration