More for Copying Drives or Partitions

We had a Clonezilla image that was too large and so I was testing out different possible methods for cramming that too-large disc image (500 GB) onto a smaller drive (150 GB). I tried just shrinking the partition on the original drive (down to 65 GB), but since the images we create a disc images this had no impact.

I found this article which, while attempting to explain how to cram a larger drive onto a smaller, also includes a screen shot of Clonezilla where Clonezilla tells us it cannot do so.

No, I Can't
No, I Can't

I tried anyway and it failed same as before.  Maybe there is a way to do this (without hacking the files within the image as this clever thread discusses) but I didn’t find it in there.

Instead I opted to try using dd to copy the disc directly from large to small and let it fail when the small drive runs out of space.  In theory this ought to work since the partition table, both of the partitions Windows creates, and all of files are located at the front of the drive.  It’s running now; I’ll add more later.

It works brilliantly.  Just make certain your partition is significantly smaller than the available space on the destination drive so as to ensure all important data will fit before the copying of the large drive fails.  (In my example the 500 GB drive contained a 65 GB partition which was much smaller than the 150 GB destination drive.)

On that note, here is some information on using dd to make such a copy.  If you are going from same or small to same or large this will definitely work (and would be much faster than using Clonezilla as an intermediary).

sudo dd if=/dev/sda of=/dev/sdb bs=1M

In this case my source and destination were drives a and b respectively.  The bs=1M is a lovely addition which will slightly speed up the process according to the below linked thread.

I used GParted to help figure out which were the source and destination drives.  Be very careful.  If you run dd in the wrong direction you have just copied empty space over what you intended to copy.  I have done this; it sucks.

In doing my research I also came across this thread which contained some other useful possible solutions to the matter.

He includes my above mentioned use of dd but he also mentions using cat which I will echo here for your entertainment and edification.

sudo cat /dev/sda > /dev/sdb

This would basically take as input anything (in order) on a and output it to b.  Again, this seems like a plausible solution for going from a larger to a smaller drive.  If I’m able to make a test I’ll add more information.

I tried using cat but I received permissions errors (including using sudo) and I gave up and used dd instead.  I was running an Ubuntu 10.04 live CD so that may have contributed (but I’ve never seen sudo receive a permissions error using the live CD previously).  Also, both drives were unmounted (though this is usually what is desired in a case like this).

If you are copying a Windows drive there is another recommended step.  After you have copied your drive (using dd) you may want to run chkdsk.  If it runs automatically, great.  If not, boot into Windows and run this command to tell chkdsk to run on the next boot cycle.  (In this example c represents your Windows drive.)

chkdsk c: /r

Sorry not to have anything more definitive than the dd solution (which is pretty good).  If you have a vetted solution feel free to post it in the comments.


4 thoughts on “More for Copying Drives or Partitions

  1. From wikipedia:
    It is jokingly said that dd stands for “destroy disk” or “delete data”, since when used for low-level operations on hard disks, a small mistake such as reversing the input file and output file parameters could result in the loss of some or all data on a disk.

    Yep :P I would target the windows directory and use robocopy (yeah you’ll hate hearing that). Multithreaded copying is the coolest (Billy Madison voice) plus, its called robocopy; it sounds badass (regardless of its etymology), and what is Unix anyways?

  2. This method failed for me this morning while attempting to shrink a Win8 64 bit image onto a 128 GB SSD (from a 500 GB HDD). Chkdsk found nothing and the built-in repair in Win8 was unable to correct whatever problem was preventing it from booting.

    Not sure why it didn’t work (this is the first time I’ve tried to shrink Win8 and also the first time shrinking from an HDD image to an SSD). I didn’t have time to test further (in the end I just used the 500 GB HDD for this machine). If this comes up again or if I get more information I’ll post back.

Leave a Reply

Your email address will not be published. Required fields are marked *