linux – Drive encryption with Luks on LVM


Hello. There is a Centos 7 server on which there are 2 disks. There is data on the second disk and you need to encrypt it with Luks but don't lose the data (don't do cryptosetup -y luksFormat). Please tell me how to do it right.

Thanks a lot!


Good day! There are options like this , this and in Russian , but it's all risky and instead of encrypting data, you can lose all data. But you can try 🙂 Good luck!

ps An example of encrypting a partition without data loss:

  1. Unmount our disk umount /dev/sda1
  2. Check fs for errors: e2fsck -f /dev/sda1
  3. Now you need to reduce the size of the file system: resize2fs /dev/sda1 $size-10M (10Mb should be enough for the LUKS header)
  4. Then the encryption process itself is luksConvert /dev/sda1 (here the options may differ depending on whose script you decide to use, they will have to be downloaded and installed not from official reps)
Scroll to Top