# (Almost) Full Disk Encryption - How to do it?

**URL:** <https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007>\
**Category:** General Discussion\
**Created:** [23 November 2024 16:00 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007 "2024-11-23T16:00:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![KingBongo](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/k/9de053/32.png) [@KingBongo](https://dietpi.com/forum/u/KingBongo)\
**Post date:** [23 November 2024 16:00 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007/1 "2024-11-23T16:00:01Z")

</div>

Hi. I recently started using DietPi and I love it already! However, there is this one major nagging issue: I haven’t been able to encrypt (most of) my DietPi system installation.

On my previous Raspberry Pi’s I have been using Berryboot as a simple way to encrypt my installations. Unfortunately, development was stopped years ago and the RPI Zero 2 W (which I have now) was never supported ☹

Therefore, I have been looking for other means to encrypt the system. I found this great guide which I successfully tried on a regular Raspberry Pi OS installation, works like a charm.

> <https://askubuntu.com/questions/1287837/luks-disk-encryption-on-raspberry-pi-4-and-ubuntu-desktop-20-10>

I thought that I understood every step of the guide, I even made a few modifications by myself, but when I try using it on a DietPi installation it doesn’t work! The system hangs during the boot process, but whyyyyy?

Can someone skilled tell my why the guide isn’t working for DietPi and also suggest some modifications, PLEASE?

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [23 November 2024 17:32 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007/2 "2024-11-23T17:32:26Z")

</div>

Did you complete the initial installation before performing the encryption? DietPi did not include encryption software on a new image. Something that may need to be installed first before encryption can be performed.

---

<div class="post-metadata">

**Author:** ![KingBongo](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/k/9de053/32.png) [@KingBongo](https://dietpi.com/forum/u/KingBongo)\
**Post date:** [24 November 2024 02:47 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007/3 "2024-11-24T02:47:23Z")

</div>

Joulinar:

Actually I believe I did install all relevant encryption software. After flashing the DietPi image to the SD card I booted it up, activated wifi, and installed “cryptsetup-initramfs” from terminal. This installs some important dependencies as well, i.e. “cryptsetup” which is needed.

After all operations are done the system actually gets pretty far into the boot process before suddently hanging without any abvious error(s) displayed. It just freezes.

EDIT: The boot process halts before it reaches the “initramfs shell” or whatever it is called.

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [24 November 2024 16:11 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007/4 "2024-11-24T16:11:26Z")

</div>

Ok, I just played around with a very old guide for RPI SBC and it still works, even including decrypting the root partition via SSH (dropbear)

Guide: [keks24/raspberry-pi-luks: encrypt the "root" partition of the raspberry pi stock image "raspberry pi os lite" - Codeberg.org](https://codeberg.org/keks24/raspberry-pi-luks/src/branch/debian_10_buster#encrypting-the-root-partition-manually)  
Hint 1: [DietPi-Drive\_Manager | Add dm-crypt/LUKS support · Issue #3377 · MichaIng/DietPi · GitHub](https://github.com/MichaIng/DietPi/issues/3377#issuecomment-897580906)  
Hint 2: [Update-initramfs fails due to no compression support of kernel - #3 by LeFish](https://dietpi.com/forum/t/update-initramfs-fails-due-to-no-compression-support-of-kernel/18846/3)

Tested on: RPi4B, Kernel 6.1.21-v8+

```auto
root@DietPi4:~# lsblk -o name,fstype,label,size,ro,type,mountpoint
NAME FSTYPE LABEL SIZE RO TYPE MOUNTPOINT
sda 3.8G 0 disk
├─sda1 vfat 128M 0 part /boot
└─sda2 crypto_LUKS 3.6G 0 part
  └─cryptroot ext4 3.6G 0 crypt /
root@DietPi4:~#

```

---

<div class="post-metadata">

**Author:** ![KingBongo](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/k/9de053/32.png) [@KingBongo](https://dietpi.com/forum/u/KingBongo)\
**Post date:** [5 December 2024 14:50 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007/5 "2024-12-05T14:50:07Z")

</div>

Joulinar:

Thank you! I will try that.

However, I REALLY would like to know why the guide I linked to does not work since I thought I understood every step. Really annoying ☹

---

<div class="post-metadata">

**Author:** ![KingBongo](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/k/9de053/32.png) [@KingBongo](https://dietpi.com/forum/u/KingBongo)\
**Post date:** [27 December 2024 04:08 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007/6 "2024-12-27T04:08:03Z")

</div>

Ok, I am giving up on this. In my opinion it is too complicated right now to encrypt DietPi compared to regular RPI OS so I will wait until it (hopefully) becomes somewhat easier. I spent almost two whole days on this. I am very patient but this is it for me ☹

If somebody would like to go through all the steps involved and provide me with an image having the following specs I wouldn’t break his or her leg 😉

1. No changes from a basic install except for ETH and WIFI modules turned off (no packages removed). Nothing else changed during setup.
2. Root partition encrypted with the password “unlock”. Even I know how to change that.

Thanks.

---

<div class="post-metadata">

**Author:** ![keks24](https://dietpi.com/forum/user_avatar/dietpi.com/keks24/32/7595_2.png) [@keks24](https://dietpi.com/forum/u/keks24)\
**Post date:** [26 February 2025 11:00 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007/7 "2025-02-26T11:00:14Z")

</div>

@KingBongo

Hello, author of [keks24/raspberrypi-luks](https://codeberg.org/keks24/raspberry-pi-luks) here!

I have read the instructions, which you provided in your first post and this part seems to be wrong:

```no-highlight
cryptdevice=/dev/mmcblk0p2:sdcard

```

It will be decrypted as `/dev/mapper/sdcard` and not as `/dev/mapper/rootfs`.

It should have been:

```no-highlight
cryptdevice=/dev/mmcblk0p2:rootfs

```

I would not recommend using `/dev/mmcblk0p2` here, since it can change, if another SD card is connected to the Raspberry Pi. Better use the `UUID` of the partition.

You may want to check out my [updated instructions](https://codeberg.org/keks24/raspberry-pi-luks/src/branch/debian_12_bookworm) for `Raspberry Pi OS (Debian 12 Bookworm, ARM64)`.

I am also thinking of automising it via `Docker`.

-Keks

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [26 February 2025 12:56 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007/8 "2025-02-26T12:56:53Z")

</div>

Thanks for stopping by @keks24 🙂

---

<div class="post-metadata">

**Author:** ![system](https://dietpi.com/forum/uploads/default/original/1X/7e1021de2213860bce185915ce2c1786e56490ec.png) [@system](https://dietpi.com/forum/u/system)\
**Post date:** [25 August 2025 12:57 UTC](https://dietpi.com/forum/t/almost-full-disk-encryption-how-to-do-it/22007/9 "2025-08-25T12:57:37Z")

</div>

Closed on 25 August 2025 12:57 UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
