Encrypt entire disk whit data

New to Debian (Or Linux in general)? Ask your questions here!

Encrypt entire disk whit data

Postby WhyDub » 2020-08-09 21:04

Hi,

is there a way to encrypt an entire disk partition whit all its data like it can be done whit bit-locker in Windows ? Or if not, suppose that i have an image of my disk partition in question saved in an external hard drive, if I format the partition im talking about whit luks, after that, can i restore the image in the now encrypted same partition ? or if doing so will erase the encrypted partition in order to restore the image??

thanks.
WhyDub
 
Posts: 5
Joined: 2020-05-06 18:45

Re: Encrypt entire disk whit data

Postby p.H » 2020-08-10 11:50

WhyDub wrote:is there a way to encrypt an entire disk partition whit all its data like it can be done whit bit-locker in Windows ?

None I am aware of.

WhyDub wrote:if I format the partition im talking about whit luks, after that, can i restore the image in the now encrypted same partition ?

Not without truncating it. The encrypted volume is smaller than the partition by a few megabytes because of the LUKS header. Or you have to use a detached (separated) LUKS header, which obviously has issues (the detached header has to be stored somewhere else, and its UUID cannot be used to identify the encrypted partition).
p.H
 
Posts: 1434
Joined: 2017-09-17 07:12

Re: Encrypt entire disk whit data

Postby dilberts_left_nut » 2020-08-10 12:32

If you can mount your "backup image" you can copy the files back to the new encrypted filesystem.
AdrianTM wrote:There's no hacker in my grandma...
User avatar
dilberts_left_nut
 
Posts: 5071
Joined: 2009-10-05 07:54
Location: enzed

Re: Encrypt entire disk whit data

Postby WhyDub » 2020-08-10 20:52

So really if I want my disk to be encrypted, i have, in other words, to reinstall the operating system and its data (fresh install) after the encryption of the disk is done. That's right isn't it ?

Or, if I trunk my actual partition to be the size of the future encrypted partition and there I backup-image this partition, can I restore it on the new same sized but now encrypted partition without loosing the encryption ?

Thanks
WhyDub
 
Posts: 5
Joined: 2020-05-06 18:45

Re: Encrypt entire disk whit data

Postby pylkko » 2020-08-11 14:56

Unless, I missed your point somehow, I believe VeraCrypt can "encrypt an entire partition and the data".
User avatar
pylkko
 
Posts: 1780
Joined: 2014-11-06 19:02

Re: Encrypt entire disk whit data

Postby p.H » 2020-08-12 11:31

WhyDub wrote:So really if I want my disk to be encrypted, i have, in other words, to reinstall the operating system and its data (fresh install) after the encryption of the disk is done. That's right isn't it ?

Not exactly. The Debian installer cannot use an existing encrypted partition, it must be created during the installation process.

WhyDub wrote:Or, if I trunk my actual partition to be the size of the future encrypted partition and there I backup-image this partition, can I restore it on the new same sized but now encrypted partition without loosing the encryption ?

You must distinguish between a system partition (/ or /usr) and a data partition.
For a data partition, you do not have to reinstall the system. You can install cryptsetup-bin, encrypt the partition, restore the shrunk image on the encrypted volume and update /etc/crypttab and /etc/fstab.
For a system partition, this is not that simple.
- In its default configuration, GRUB cannot handle an encrypted /boot, so /boot must be in a separate unencrypted partition (and GRUB must be reinstalled if the /boot partition was not already used)
- cryptsetup must be installed
- crypttab, fstab and grub.cfg must be updated and the initramfs must be rebuilt in a chroot

So in most cases it is probably easier to reinstall the system with encryption.
p.H
 
Posts: 1434
Joined: 2017-09-17 07:12

Re: Encrypt entire disk whit data

Postby WhyDub » 2020-08-13 13:48

OK I understand that there is no easy solution for my case... I will leave it there for the moment, until i have figure it out. thanks
WhyDub
 
Posts: 5
Joined: 2020-05-06 18:45


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 13 guests

fashionable