1

I have a hard drive in my laptop with a windows and an ubuntu partition. I got an SSD to replace my hard drive, but it has a slightly lower capacity. I've already partitioned the SSD to the sizes I want, and each partition on the new disk is larger than the amount of used space on my old hard drive.

I was going to use dd, but it appears that it requires partitions to be the same size.

How can I copy my old partitions onto my new ssd? I'm copying my boot partition too, so how can I make sure the new disk is bootable, and the new partitions are exactly the same as the old ones (but with less free space)?

2

4 Answers 4

3

Don't bother to partition SSD disk.

I would suggest to shrink the partitions on the old disk first to fit the size of the SSD, then dd old disk to new one

But make a backup first.

2

You can definitely use dd, as long as the data on the larger drive is notably smaller than the SSD and that no data exists in the area that is beyond the SSD's storage limits.

Just do a straight up dd sector by sector from the source drive to the SSD until the SSD is "full" and then use parted to fix up the incorrect partition table that says the SSD has larger geometry than it really does by "deleting" and "recreating" the truncated partition with the correct geometry (this doesn't delete data in that partition, it simply changes the start and end of that partition).

Alternatively, as already mentioned, use a tool like GParted to shrink down the partition to less than the size of the SSD, clone it over using either dd (it will have correct geometry and no risk of data loss this time) or Clonezilla (faster than dd because it only clones the occupied areas of the drive rather than everything - you still need to resize the partition down beforehand), and then resize the partition on the SSD up again afterwards to fill any empty space below the total capacity.

0

Disclaimer: I am the author of the WereSync software

WereSync can do this with one command. Install the program with:

pip install weresync

And then run it:

weresync -C --grub-partition 2 --efi-partition 1 /dev/sda /dev/sdb

This will copy the data from /dev/sda to /dev/sdb. The -C flag makes weresync copy the partitions to the target drive, then resize them so they fit. --grub-partition is the number of the partition you want weresync to install grub on, and --efi-partition is the partition number you want to be mounted and passed to grub-installs --efi-directory flag. Generally --grub-partition should be your root drive, so if /dev/sda2 is mounted on /, pass a 2 to --grub-partition. If you have your boot folder on a seperate partition, you will need to pass that number to the --boot-partition flag. For more detailed information, see the WereSync Documentation.

Note: As of yet, WereSync only supports GPT drives as the source drive. Support for MBR drives is being actively developed.

4
  • BTW, I take it WereSync isn't so suitable for cloning a laptop that only has Windows on it (even from a linux Live USB)?
    – gmatht
    Jan 29, 2017 at 3:38
  • @gmatht well it's certainly not supported. It should copy all the files properly, but the boot probably won't work. If you have a recovery disk you might be able to get it to work.
    – DonyorM
    Jan 29, 2017 at 13:06
  • @DonyorM Very neat piece of software. I did run into several issues though. What's the best way to communicate those to you?
    – insaner
    Mar 5, 2019 at 1:23
  • 1
    @insaner the best place would be the issues page on Github: github.com/DonyorM/weresync
    – DonyorM
    Mar 5, 2019 at 3:22
0

Use lsblk to get your device ID and do (running it without arguments)

lsblk -b /dev/sdYY

This is to get the exact size of the disks and make dd from there.

Before dd you might need to use Gparted to resize it to fit. Go to the device picker on the top right of Gparted, right click on the partition to be resized and hit the Apply button (and make a Home run) but watch for your finger. And you'll be ready to "dd" the disk.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .