Ubuntu – Clone encrypted HDD to smaller drive

cloneencryptionluks

For my work Laptop I use full HDD encryption and I need to upgrade my 500GB HDD to a 250 SSD drive, my HDD has only around 100GB of data and is created via encrypted LVM.

GParted does not support LUKS encryption, so I am unable to copy (or resize) partitions.
Using dd would be great but because of the different size I might loos data.

Then only valid option I got so far is to try and re-size the partition and then try a clone with dd (but seems very complicated and prone to failure).

There is any other way to clone the data on the HDD without reinstalling ?

Based on what I have read so far I think reinstalling would be the easiest and fastest solution, but I would like to see your ideas/opinion.

Thank you

Best Answer

So this is what I did in the end:

  • While logged in with access to unencrypted data, I copied all the data to a external HDD using rsync.
    ATTENTION: the first attempt copied all the data, but when I checked the data 70% was in binary form (even pictures, text files etc ...) and not useful, so I erased the external HDD and start over, the second time it worked (I have no clue what was wrong the first time), but it is very very important to DOUBLE CHECK the copied files if you plan to tamper with the original data.

  • Make a list with all the programs installed.
    I did it manually from "Software Center", because I wanted to have the installed history available, you can use dpkg -l > textfile or other commands to give you ALL packages installed and then reinstall them via aptitude install $(cat <textfile>). Of course you need to move the textfile to the new installation.

  • Install the same OS version in onto the new HDD, using the same name for your user account.

  • Mount the external drive and copy everything to the new HDD
    ATENTION: If you do this from GUI, do not overwrite your home dir, just put it with a different name for example /home/YOURNAME.orig, and after all files are copied, go to ctrl+alt+F2, log in the machins, stop the gui (for normal ubuntu 12.04 the command is service lightdm stop, mv your old home on top of the new one mv /home/YOURNAME.orig /home/YOURNAME, and start X again service lightdm start.

Here you can see the power of Linux's /home dir, everything was back in place, icons, settings, applications specific settings, even cached data :), and I only had a downtime of about 4 hours (because the first copy failed).

Hope this helps, I still consider this a faster and safer approach compared to resizing the encrypted HDD.