LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 09-08-2004, 06:40 PM   #1
fireman949
Member
 
Registered: Dec 2003
Location: Walls
Distribution: Slackware 10.1;CentOS 4
Posts: 51

Rep: Reputation: 15
Cloning 1 hard disk to smaller hard disk, dd or ghost?


As the title says.

I've got 2 disks, source disk is 4GB with 2.5GB used and target is 3.2GB. The file system is NTFS with Windows2k.

I've been using dd if=/dev/hda of=/dev/hdb for the past five (identical) disks without a problem. I have 3 more disks to clone. A 3.2GB disk and 2-13GB disks.

I have several linux boxes and an XP box, is this something I can do in Linux with the smaller and larger disks or is this something I have to by ghost/partition magic for?

Any help is appreciated.


-eric
 
Old 09-08-2004, 10:05 PM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
I'm no ntfs guru, but I'm pretty sure it often scatters data, and you might have some valuable data at the end of the drive. If you have a copy of that partition to restore from, you might be better off using NTFS-resize to make it a 3GB partition and cloning that.

Otherwise, Ghost or Partition Magic would handle this with the least amount of uncertainty.
 
Old 12-09-2005, 07:24 AM   #3
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
dd writes out the information natively in 1s and 0s and so the filing system, the operating system and the conent has no influence. You basically mirror the disk 100%.

For obvious reason one can clone a hard disk if both the source and target disk have identical size. The effect of doing it with different size is the copied partition table can't match the disk interior and the operation may be fruitless when the disk cannot be read.

One can dd one partition at a time as it is easier to have the target partition created in exactly the same size as the source. The successfull rate is pretty good with XP and Win2k, the toughest Windows to be cloned. Like

dd if=/dev/hda1 of=/dev/hdb1

I always add bs=32256 to speed up the process. 32256=63 sector times 512 bytes and is a full track size. Omitting the bs parameter Linux will defaults to copying 512 byte at a time.

Ghost can "scale" the different sizes automatically but again one should know if one has in the source disk more data than the capacity of the target disk nothing in the world can make it work, unless the content is compressed.

Unless the NTFS disk has a XP or Win2k system inside the normal data can be done in "drag and drop" without cloning. If the disk does have a XP or Win2k inside it wouldn't be any good other than the machine from which it is installed. NT versions of Windows will lock up if it detects a significant hardware change. A legal copy XP of course will necessitate a re-activation whereas an illegal copy can work for a while without activation and then drops dead suddenly. So know where you are going with the "dd" command.

Last edited by saikee; 12-09-2005 at 07:31 AM.
 
Old 12-11-2005, 12:00 AM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
If I understand correctly how dd works, if you copy a 2.5 gig partition to a 3 gig partition, dd truncates the 3 gig down to 2.5 gig. To reclaim the lost .5 gig, you will have to resize the partition.

On the other hand, you could use tar to clone the partitions.
1) it's faster.
2) it doesn't resize the partition.

First, cd to the root of the filesystem, or the highest level directory to be cloned.
cd /, or cd /<some directory>
Then clone from one partition to another.
tar cf - . | (cd /path/to/mountpoint; tar xf -)

It should be obvious that both the target and object partitions must be mounted.

Last edited by bigrigdriver; 12-11-2005 at 12:02 AM.
 
Old 12-11-2005, 03:29 AM   #5
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
Slightly incorrect interpretation.

The empty space in the 3G can be use for another partition. It is never lost and permantly available. Resizing is an option.

What dd got over tar is dd writes the full partition "including" the boot sector, which is a reserved area of the partition.

Tar and its variants deal with the filing system only and the boot sector is untouched because it is not part of the filing system. Tar is for backup and not intended for cloning.

There is no such thing one is better than the other. Just pick the right tool for the right job. For example you can't possibly tar a NTFS partition and have it bootable , can't you? Also dd is king when cloning the whole disk with multiple partition.

I use tar as suggested by bigrigdriver a lot. Speed wise tar is slightly slower but more flexible.

Between tar, dd and ghost the transfer speeds are not much to choose from, in my experience. I got a kick out of not using Ghost after learning the Linux way because it is so simple.
 
Old 12-13-2005, 12:47 PM   #6
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
I am seeing a lot of confusion here.

dd will not resize a 3GB partition to a 2.5GB partition if you specify partition devices instead of drive devices. i.e if you partition the destination drive first and use:
dd if=/dev/hda1 of=/dev/hdb1

However, the original question states pretty clearly that he wants to copy a 4GB drive to a 3.2GB drive. Only 2.5GB is used, but NTFS does not necessarily store all its data sequentially on the disk, and dd would lose any data stored beyond the 3.2GB mark on the original drive.

I can't believe this question is being re-answered so badly more than a year after it was originally posted and solved.
 
Old 12-13-2005, 01:34 PM   #7
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
You would be right is there is always "one" partition in the hard disk. I did state that the "partition sizes" have to match.

The post was answered by mistake becasue it was displayed at the bottom of a similar thread.

It is a fact that a PC user can download a Linux Live CD and use it to clone a bootable XP partition.
 
Old 10-11-2010, 12:57 AM   #8
elperrillo
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0
I hate to crash a really and old thread but this one keeps coming up every time I search for "cloning a hard drive to a smaller drive", the way I usually do it is with the following method:

1) I resize the partition using gparted
2) I let the operating system with the resized partition boot so it can fix any possible errors.
3) I use clonezilla to clone the drive

This is how I do it and it has NEVER failed for me

http://geekyprojects.com/storage/how...smaller-drive/

Hope it helps.
 
Old 12-23-2012, 12:51 AM   #9
grscjo3
LQ Newbie
 
Registered: Dec 2012
Posts: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by elperrillo View Post
I hate to crash a really and old thread but this one keeps coming up every time I search for "cloning a hard drive to a smaller drive",
... I hate to too, but, this came up in a Google search for me, too, and I think I managed to still improve on the procedure, and thought I'd share.

Quote:
Originally Posted by elperrillo View Post
the way I usually do it is with the following method:

1) I resize the partition using gparted
2) I let the operating system with the resized partition boot so it can fix any possible errors.
3) I use clonezilla to clone the drive
The thing is that, if you're using a current version of gparted (0.12.1), and you resize a drive, if you view the details of the process in gparted, you'll notice that one of the steps is actually to check the partition.

Here was my process:

1) Use dd to copy from big partitions to small partitions on a 500GB harddrive to an 80GB SSD.
2) Open up gparted, and see that the small partition had a red exclamation point. When I viewed the information about the drive, the error status window was too tall for my screen.
3) Switch to the big drive and shrink the partitions to match exactly in MiB the size of the target, small partitions. Gparted claims that part of this process is checking the new small partitions on the big harddrive.
4) Use dd again, to partition on small drive, from equally-sized parition on the big drive.
5) In gparted, right click on the partitions on the small drive that still have exclamation points, and choose "check." This queues checking the partitions, and when I pressed the green check mark to do the queued operations, it worked for a sec and then the red exclamation points went away.

Seems to me like you could get away with just doing steps 3 and 4, and that steps 1, 2, and 5 were only because I originally used dd to copy from a larger partition to a smaller one. The real timesaver is that you don't need a Clonezilla live CD/USB key. I did all of this from an Ubuntu live USB. So basically, the answer to everyone saying "oh, but, dd doesn't work from a larger partition to a smaller one," is, "make the larger partition smaller first, and then use dd."

(I'll admit that I'm writing this from the live USB while the second dd run for the second partition I want is running. So, I'm not 100% positive that it worked. But it looks from here like it will have. If I don't reply, assume it worked.)
 
  


Reply



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
Reiser file system / Hard Disk/ Hard Drive Problems Oxyacetylene Linux - Software 4 10-10-2005 02:24 PM
Reclaim disk partition from hard disk installation EStester Linux - Enterprise 2 03-09-2005 11:46 AM
Reclaim disk partition from hard disk installation EStester Linux - General 1 03-09-2005 11:25 AM
Cloning Hard Drives and Partitions! an alternative to Norton ghost thebover Linux - Software 3 08-18-2004 03:40 PM
Hard Disk question - Making a big hard disk MrAnonym Linux - General 2 09-15-2003 06:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:29 AM.

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
Open Source Consulting | Domain Registration