You are not logged in.

#1 2023-12-14 16:54:34

dab9966
Member
Registered: 2023-12-05
Posts: 44

[SOLVED] Can you encrypt root partition and keep your data intact?

I want to encrypt my root volume. Checking docs here https://wiki.archlinux.org/title/Dm-cry … partitions

It mentions to run this command:

cryptsetup -y -v luksFormat /dev/sda2

This will overwrite data on this partition (looking at this video: https://youtu.be/dI3bGeT31Bo?t=894). I have a system running now, is there any way to encrypt your root partition without erasing/overwriting data?

Last edited by dab9966 (2023-12-14 18:23:02)

Offline

#2 2023-12-14 18:10:19

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 714

Re: [SOLVED] Can you encrypt root partition and keep your data intact?

If your root file system is shrinkable (e.g. ext4) and you have a separate /boot partition, then it's possible by following https://wiki.archlinux.org/title/dm-cry … ile_system. Make sure to have a backup of all data that you don't want to lose in case things go wrong.

It would most likely be faster to make a full system backup, repartition, set up LUKS and restore the file system contents (+ adjust, fstab, boot loader configuration, etc.) instead.

Offline

#3 2023-12-14 18:22:47

dab9966
Member
Registered: 2023-12-05
Posts: 44

Re: [SOLVED] Can you encrypt root partition and keep your data intact?

nl6720 wrote:

If your root file system is shrinkable (e.g. ext4) and you have a separate /boot partition, then it's possible by following https://wiki.archlinux.org/title/dm-cry … ile_system. Make sure to have a backup of all data that you don't want to lose in case things go wrong.

It would most likely be faster to make a full system backup, repartition, set up LUKS and restore the file system contents (+ adjust, fstab, boot loader configuration, etc.) instead.

Must have missed this page, thanks!

Offline

#4 2025-07-29 20:52:32

salfter
Member
Registered: 2024-05-23
Posts: 2

Re: [SOLVED] Can you encrypt root partition and keep your data intact?

I knocked together a cheatsheet that goes through the steps to encrypt an existing root partition:

https://alfter.us/2025/07/29/cheatsheet … x-install/

I figured it out in a scratch VM first, then applied it to my notebook in about an hour. 

Whatever you have in your root filesystem will be encrypted when you're done; it'll be accessible as long as you don't forget the passphrase.  The OP was missing some options to cryptsetup that are needed to encrypt an existing filesystem.

Last edited by salfter (2025-07-29 20:57:26)

Offline

#5 2025-07-30 10:21:28

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,962

Re: [SOLVED] Can you encrypt root partition and keep your data intact?

Thank you for contributing..

Please (re-)read Old threads/"necro-bumping" .
Closing this old thread.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB