Moving entire Linux installation to another drive
It can be done in a few ways. But the easiest one is to just copy all files from the old drive to the new one.
Create an ext4 partition and a swap partition on the new drive.
Boot from LiveUSB.
Mount the old Ubuntu partition to some directory, mount the new one to some other directory.
Copy all files from the old one to the new one using
cp -a
command.Install grub to the new drive.
Update
/etc/fstab
with new UUIDs.
If something is not clear, I can add some explanations.
You can use CLONEZILLA for this purpose.
Clonezilla is a free partition and disk imaging/cloning tool which can be used to backup all your data (whole disks or partitions) in a highly compressed way and later clone it back to your hard disk to get it into exact same condition. This is faster than installing the OS most of the times.
Download Clonezilla stable ISO or Direct Download clonezilla-live-2.4.6-25-amd64.iso
Make a bootable (Live) USB using Tuxboot 7.0.
Boot from the created Clonezilla media.
Now you have many options :
- Create an image of only '/' (saveparts) and clone it to any partition of your other SDD.
- Create an image of the full disk (savedisk) and clone it to your new SSD.
In your case you can use the "device-device" option too, but I am not familiar with it.
You can find a detailed guide about Clonezilla here : http://clonezilla.org
In case you have some time and want to go safe:
$ dd if=/dev/sda of=/dev/sdb bs=64K conv=noerror,sync
Explanation of the command:
if
is the input,of
the destinationbs
sets the block size. It's the size of the chunks dd will read and write in. Higher Chunk sizes usually means higher performance but also more corruption of data if input disk has errors, see here: archwiki on ddnoerror
continues in r/w-errors.sync
synchronizes the offsets if an error has occured.
This will basically create an image of you disk sda and write it onto sdb (same partition layout etc.) Ofcourse this'll write the whole 120GB as it's file-agnostic. Thus very safe, but not the fastest, if you only use small portions of the disk. However if the input disk is rather full it might even be faster.
BUT:
- After that you probably want to resize the partitions as otherwise you cannot take advantage of the extra space.
- In any case it might be needed to edit the /etc/fstab file.
This is the case if Hardware-IDs are used to recognize the disks.