Block-device encryption without reinstallation
Block-device encryption without reinstallation
Posted Sep 30, 2025 12:08 UTC (Tue) by geert (subscriber, #98403)Parent article: Managing encrypted filesystems with dirlock
I think it would be possible to convert from an unencrypted to an encrypted block-device without reinstallation, by teaching dm-crypt to handle partially-encrypted block devices. The conversion procedure would be:
1. Unmount file system,
2. Shrink/modify file system to cater for space for the LUKS header and dm-crypt,
3. Add a LUKS header, and a counter that is initialized at zero (nothing encrypted yet),
4. Setup dm-crypt and remount file system,
5. Dm-crypt background task encrypts blocks, and updates the stored counter accordingly, until everything is encrypted.
1. Unmount file system,
2. Shrink/modify file system to cater for space for the LUKS header and dm-crypt,
3. Add a LUKS header, and a counter that is initialized at zero (nothing encrypted yet),
4. Setup dm-crypt and remount file system,
5. Dm-crypt background task encrypts blocks, and updates the stored counter accordingly, until everything is encrypted.
