Clone HDD to smaller SSD on Linux

Starting point

How to speed up your old Windows laptop? Simply, install Linux and upgrade hard drive to solid state drive. First, let’s try Linux. My choice of Linux flavor is Ubuntu 18.04. It is currently installed on old HP Compaq nc6400 (https://support.hp.com/rs-en/document/c00685510). After installation of Ubuntu on laptops larger HDD (Toshiba 1TB), we can try Ubuntu for some time without spending any money on upgrade. I think that Ubuntu 18.04 is a good starting point if you are looking to switch to Linux. You can download Ubuntu 18.04 from next link https://ubuntu.com/download/desktop. So, after some time, you can determine is Ubuntu 18.04 good for you. If this distro is good for you, you can purchase new solid state drive. Now we just need to clone HDD to Smaller SSD on Linux. 


Old laptop – HP Compaq nc6400

 

New SSD drive – Kingston SA400S37/120G

 

Selected distor – Ubuntu 18.04

Necessary Hardware

To clone HDD that is inside a laptop to SSD we need SATA to USB 3.1 Adapter. With this additional hardware we can easier clone data. Link for adapter:

With this adapter we can connect SSD via USB port on our laptop without opening the laptop. Please insert new SSD drive into adapter and connect via USB to the laptop. Now, we can start the process of cloning data from SSD to HDD.

 

SATA to USB Adapter – UGREEN

Cloning Process 

Shrinking Down HDD partition to SSD size

First thing we need to do is to shrink down HDD partition with installed Ubuntu 18.04. We cannot do this while Ubuntu partition is mounted. We need to do next process:

  1. Create Live USB stick with Ubuntu
  2. Try Ubuntu from USB stick
  3. Install Gparted with command sudo apt install gparted
  4. Shrink partition to SSD size (in this case to 110 GB) with Gparted tool

You can find the tutorial on how to try Linux distribution on your Windows 10 Laptop without loosing your data with  Live USB stick on next link:

Cloning process with dd

Now we are ready to clone. First step, we need to expect both drives with command sudo fdisk -l /dev/sda, shown on the image below. 

We need to compose dd cloning command. We are interested in two numbers:

  1. Units: sectors of 1 * 512 = 512 bytes
  2. End Sector number = 225282047 

Now we have our dd command sudo dd if=/dev/sda bs=2048 count=56320512 conv=noerror | pv -s 110G | sudo dd of=/dev/sdb. We need to “pipe” couple of commands to easier follow cloning process. 

  1. sudo dd if=/dev/sda bs=2048 count=56320512 conv=noerror
    1. if option – defines source disk to clone from. In this case HDD.
    2. bs option –  how many bytes are transferred at the time (4x512bytes)
    3. count option – how many sectors are transferred for input stream (225282047+1/4)
  2. pv -s 110G – monitor the progress of data through a pipe 
  3. sudo dd of=/dev/sdb
    1. of option – defines target drive to clone to. In this case SSD. 

 

full command — sudo dd if=/dev/sda bs=2048 count=56320512 conv=noerror | pv -s 110G | sudo dd of=/dev/sdb

This command takes a long time to process, so be patient. After the command is finished, we can  swap drives. Following images show how to swap drives if you have HP Compaq nc6400 laptop.

 

Remove charger

 

Remove battery

 

Press power botton for couple of seconds

 

Remove two screws from HDD bay cover

 

Look at HDD bay

 

Remove HDD bay

 

Look at removed HDD bay with drive

 

Replace HDD with SSD and return to HDD bay

Now we have copy of our installed Ubuntu 18.04 on our new SSD. What are the advantages?

SPEED

I did some testing with and without SSD. I measured power on time with HDD and in was very slow process. Power on time was 1 minute and 20 seconds.  After replacing HDD with SSD with same copy for Ubuntu, power on time was decreased to 32 seconds. Good progress!

How much faster your PC boots up? Did you manage to clone HDD to Smaller SSD on Linux with this method? Please comment down below and see you in next project. Also check out my other fun project in the links below:

6 thoughts on “Clone HDD to smaller SSD on Linux”

  1. I read again and again that you can not clone a big hard drive into a smaller one unless you pay for a third party software. This article is superb and I did not find similar one when I googled the subject . The only difficulty was that I did notice the difference in the formula of the difference between “/” and “|” and I tried several modifications without success . Eventually the cloning worked without ” | pv -s 110G | “. Another lesson learned. Thank you very much Blagoje Nikolić for your helpful article .

    Reply
  2. Hi,
    Same as Gabriel I also read we can not clone a big had drive into a smaller one unless we pay for a third party software. This article is boost confidence in me to try this. so I followed the 4 steps as below.
    1. Create a Live USB stick with Ubuntu
    2. Try Ubuntu from a USB stick
    3. Install Gparted with command `sudo apt install gparted`
    4. Shrink partition to SSD size (I’ve 1T HDD and 512GB SDD so in my case to 360 GB) with Gparted tool.
    I tried 4-5 times the **dd** command doing calculations for `bs` and `count`, but unfortunately, the **count** factor did not work in my case and the **dd** command ran until **out of disk space** for SDD error.
    5. then I followed https://askubuntu.com/questions/842029/cloning-hard-disk-partition-to-smaller-ssd-on-laptop this answer did partition on SSD and copy-pasted using Gparted.
    6. Changed the UUID of the new filesystem.
    7. Update the fstab on the new filesystem.
    8. Move SSD to the top in boot priority, Done.
    Thanks

    Reply
  3. 01) Boot from the Live USB of the distro you like.
    02) Shrink partition so it will fit on the new hard drive.
    03) Make a Clonezilla Live USB.
    04) Boot into Clonezilla and select the disk to disk option.
    05) Use the Expert mode option.
    06) Select source drive and destination drive.
    07) Leave the other stuff checked, but make sure to also check the icds option as well.
    08) Clone your drive.
    09) Shut down Clonezilla when done.
    10) Remove old hard drive and boot on new drive 🙂

    Reply
    • bs is set to 2048 witch is 4*512 (we are sending 4 sectors, and each sector is 512 bytes). Because of this we are dividing by 4 in order to get amount of data in sectors, not in bytes.

      Reply

Leave a Comment