I currently have a 128GB SSD. Its using encryption that comes with Ubuntu.
What's the best way to clone this to another SSD that's bigger and then expand the partition to be bigger to fit this new larger SSD?
Can I just clone the disk like for like, and then use something like Gparted to expand the partition? Or does it not work like that with the encryption ?
Any help would be appreciated.
Best Answer
Assumptions:
Because I cannot comment on your post I am going to have to assume some things:
/dev/sdX
/dev/sdY
/dev/sdX1
/dev/mapper/sdX1_crypt
and it is using an ext4 file systemEasier Method:
The easiest and slowest way would be to use
dd
to copy every byte from the smaller SSD to the larger SSD. This would give you a fully boot-able system you would have to disconnect the smaller SSD in order to boot because both SSDs share the same UUID which the system uses to identify individual disks. Before booting you would expand the physical partition using
fdisk
.fdisk is an interactive tool, you would first delete the partition LUKS is on (because its ending address is shorter than the new bigger SSD), then you would create a new partition (the defaults fdisk uses will fill all unused space), then save (this is how software "extends" a partition). then you would expand the LUKS container using
cryptsetup
and finally you would expand the files system using
resize2fs
Faster Method:
A faster and more complex method would be to create a new partition
sdY1
withfdisk
on the bigger SSD for the encrypted volume, then create a new LUKS volume usingand mount it on
sdY1_crypt
.then use
dd
to copy the unencrypted file system from one encryption volume to another.then expand the file system with
resize2fs
In order to be able to boot from the new bigger SSD you would have to install grub in the MBR of the SSD with
Note:
All the commands used are highly configurable and you will want to use some of their options because you know your system better than I do, use
man <command>
or<command> --help
to learn about what they can do.