LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 08-27-2008, 11:43 PM   #1
diego_cn
Member
 
Registered: Mar 2006
Distribution: fedora 7
Posts: 62

Rep: Reputation: 16
using dd to clone partition


Hi,

I just bought a new 500G hard drive, and want to move linux partition on old 80G hard drive to the new one.

fdisk shows 2 hard drives have different cylinder size:
Unit: cylinder of $SIZE * 512 = xxxx
$SIZE is different for 2 hard drives.

Question being, can I create a partition of "almost" same size and use dd to copy the data? Would it cause logical error on the partition? Is there any way I can clone the partition in my case?

Thanks in advance.
 
Old 08-27-2008, 11:52 PM   #2
/usr/darien
Member
 
Registered: Mar 2008
Location: Virginia
Distribution: RHEL 4/5, Fedora 6-9, SuSE 10.1-11, Open Solaris 10.8, WinXP,2003,Vista
Posts: 59

Rep: Reputation: 15
Take the easy track. Google and download Clonezilla. Smoke the .iso to a CD, boot and enjoy.
 
Old 08-28-2008, 12:07 AM   #3
diego_cn
Member
 
Registered: Mar 2006
Distribution: fedora 7
Posts: 62

Original Poster
Rep: Reputation: 16
Very interesting software, even surprise me is it's dev team are mainly our Chinese

While I take that path, I am still curious what would happen if a partition of smaller size is copied to a larger one using dd.
 
Old 08-28-2008, 05:52 AM   #4
mrrangerman
Member
 
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 50
Take a look at this HOWTO
 
Old 08-28-2008, 10:56 AM   #5
ceantuco
Member
 
Registered: Mar 2008
Location: New Jersey
Distribution: CentOS, Debian, Kali
Posts: 579

Rep: Reputation: 37
Clozilla is awesome! I just downloaded and tried it! I like it!
 
Old 08-28-2008, 11:42 AM   #6
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 diego_cn View Post
Very interesting software, even surprise me is it's dev team are mainly our Chinese

While I take that path, I am still curious what would happen if a partition of smaller size is copied to a larger one using dd.
dd does byte-by-byte copying without regard to what the bytes mean. It can start at the beginning of the device (eg /dev/sda), or at the beginning of a partition (eg /dev/sda1). You can confirm this behavior by looking at a partition using the offset from the beginning of the drive. (fdisk -u will give you the partition offsets in sectors).

I believe if you copy a smaller partition to a larger, you simply replace the larger one with the smaller, and leave behind some dead space. Conversely copying larger to smaller will overrun whatever was after the end of the smaller.

I'm off to run some tests to confirm this....
 
Old 08-28-2008, 11:54 AM   #7
diego_cn
Member
 
Registered: Mar 2006
Distribution: fedora 7
Posts: 62

Original Poster
Rep: Reputation: 16
Thanks for the reply. I think copy to a larger partition the use GParted to fix the dead space should do the job. I will try that to see if it works.
 
Old 08-28-2008, 12:14 PM   #8
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
OK---I was almost right.

copy small to large:
small contains a file which is almost as big as the partition---df reports 100% full
after copying, df reports the larger partition also 100% full. fdisk still says it is larger.
SO--what actually got copied was the filesystem. fdisk reports the same size since it is looking at the partition table.

copy large to small:
It does not overrun as I suggested. dd simply reports that there is no more space on the target (the smaller partition)
 
Old 08-28-2008, 12:16 PM   #9
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 diego_cn View Post
Thanks for the reply. I think copy to a larger partition the use GParted to fix the dead space should do the job. I will try that to see if it works.
Based on my previous post, that won't work. I'm guessing you have to resize the filesystem.
 
Old 08-30-2008, 12:51 AM   #10
diego_cn
Member
 
Registered: Mar 2006
Distribution: fedora 7
Posts: 62

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by pixellany View Post
OK---I was almost right.

copy small to large:
small contains a file which is almost as big as the partition---df reports 100% full
after copying, df reports the larger partition also 100% full. fdisk still says it is larger.
SO--what actually got copied was the filesystem. fdisk reports the same size since it is looking at the partition table.

copy large to small:
It does not overrun as I suggested. dd simply reports that there is no more space on the target (the smaller partition)
very descriptive, also solve my curiosity Again thank you for experimenting into that.
 
  


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
Can dd be used to clone just the data on a partition ? uncle-c Linux - Newbie 15 10-29-2007 07:57 PM
Clone Dos partition. voger Linux - General 2 08-26-2007 05:03 PM
Using dd to clone an NTFS partition from a strange partition table jgombos Linux - Software 2 10-26-2006 01:10 AM
can i use dd to clone a partition? dr_zayus69 Linux - Software 1 01-25-2005 05:57 PM
How do clone Linux partition? samxiao Linux - Software 5 12-24-2003 08:50 PM


All times are GMT -5. The time now is 04:53 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