Dual boot: switch to SSD from HDD

I have Ubuntu as dual boot with Windows. Now I want to switch from HDD(1TB) to SSD(1TB). I want to migrate both Windows and Ubuntu with the same partition. Can I do that?[I am on laptop] If yes how? I want to change my internal disk. enter image description here


Solution 1:

General about cloning

Cloning from the HDD to the SSD works, if the SSD is at least as big as the HDD (not one single byte smaller). If that is what you want it is very important to check that (and the nominal size is not good enough), use for example

lsblk -bdo name,size,model

or with more details

lsblk -bo name,size,fstype,label,model

to get the drive sizes in bytes. If the SSD is smaller, you had better make a fresh installation. If the SSD is big enough and there is a GUID partition table, GPT, you must also repair the backup partition table at the end of the drive, because the drives have probably not exactly the same size. You can repair it with gdisk or gpt-fix a shellscript that uses gdisk.

Cloning tools

There are many cloning tools. Most of them are crude, they simply copy each bit as is from the source device to the target, and the target can be another device or a file (which will become an image file).

  • I use Clonezilla because it is smart enough to copy only the used blocks of the file systems and skip free blocks, the content of swap partitions and unallocated drive space. Clonezilla can clone a whole drive or individual partitions, and it can also create an image (which is not a single file, but a directory with a set of files, where the big files are compressed).

    To use Clonezilla you download an iso file, create a USB boot drive and boot from it. There is a text mode user interface, TUI, to help getting things correctly done.

Other tools may be easier to use, but they are slower, which can make a big difference when cloning a 1 TB drive.

  • mkusb can fix the backup partition table at the end of the target drive automatically, and it helps you avoid mistakes when selecting the target drive.

  • Disks alias gnome-disks is already there in an Ubuntu live drive and ready to use.

  • dd is a very powerful but also very dangerous tool for this purpose. It does what you tell it to do without any questions (no final checkpoint), so you can easily overwrite a drive with valuable data.

Advice

  • Buy an SSD that is big enough, 'one step' bigger than the original drive. If there is no margin in the nominal size, there is a risk that it is slightly smaller than the original HDD, and the standard cloning process will not work.

  • If you already have an SSD, that is slightly smaller than the original HDD, there are work-arounds (shrinking and moving some partition(s) on the original drive before cloning), but these are complicated, slow and risky, and I suggest that you

    • backup all personal files (documents, pictures etc) to a separate drive

    • make fresh installations (Windows first, Ubuntu next). This way you can also get an optimal partition table with suitable sizes of the partitions. You may want a fairly large 'data' partition with the NTFS file system for shared data (personal files) with read/write access from both Ubuntu and Windows. However, notice that Ubuntu will work faster with a Linux file system; ext4 is the standard choice in Ubuntu.

    • copy your personal files from the backup to where you want them in the freshly installed systems.

    I think this is more efficient than the work-arounds, and you get fresh systems too, get rid of old cruft, that occupies drive space and maybe also makes the computer slower.