Cloning 1 hard disk to smaller hard disk, dd or ghost?
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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?
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.
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.
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.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.