Disk encryption in debian-installer recipe

Hello everyone, I allow myself to contact you because I need a little help, I am new to Foreman I do not know too much, I am trying to find out how to use it. I use Foreman in my job and I use it to be able to install machines. I have performed tests to try to install encrypted stations in debian 8. I made a template that works but there are some adjustments to be made. When it finishes installing I have the part of the sda1 disk which is in boot but then I have two parts: sda2 and sda5. the sda2 is in “extended” format and the sda5 in “Linux” format.
What I would like is to have the following line:

Device Boot Start End Sectors Size Id Type
/ dev / sda1 * 2048 499711 497664 243M 83 Linux
/ dev / sda2 501758 968957951 968456194 461.8G 5 Linux LVM

I would like the encrypted part to be sda2.

That’s why I need a little help from you. Could someone please fill me in on that?

I leave the template I created to be able to encrypt the disk.

*d-i partman-auto/disk string /dev/sda*
*# In addition, you'll need to specify the method to use.*
*# The presently available methods are:*
*# - regular: use the usual partition types for your architecture*
*# - lvm:     use LVM to partition the disk*
*# - crypto:  use LVM within an encrypted partition*
*# d-i partman-auto/method string crypto*

*# crypto with preseeded passphrase*
*d-i partman-auto/method string crypto *
*d-i partman-crypto/passphrase password *******
*d-i partman-crypto/passphrase-again password *******


*# If one of the disks that are going to be automatically partitioned*
*# contains an old LVM configuration, the user will normally receive a*
*# warning. This can be preseeded away...*
*d-i partman-lvm/device_remove_lvm boolean true*
*# The same applies to pre-existing software RAID array:*
*d-i partman-md/device_remove_md boolean true*
*# And the same goes for the confirmation to write the lvm partitions.*
*d-i partman-lvm/confirm boolean true*
*d-i partman-lvm/confirm_nooverwrite boolean true *
*#NOTE: This was missing in the example preseed*

*# For LVM partitioning, you can select how much of the volume group to use*
*# for logical volumes.*
*d-i partman-auto-lvm/guided_size string max*
*#d-i partman-auto-lvm/guided_size string 10GB*
*#d-i partman-auto-lvm/guided_size string 50%*
* *
*d-i partman-auto-lvm/new_vg_name string VG01*

*# You can choose one of the three predefined partitioning recipes:*
*# - atomic: all files in one partition*
*# - home:   separate /home partition*
*# - multi:  separate /home, /usr, /var, and /tmp partitions*
*d-i partman-auto/choose_recipe select custom-lvm*

*# Or provide a recipe of your own...*
*# If you have a way to get a recipe file into the d-i environment, you can*
*# just point at it.*
*#d-i partman-auto/expert_recipe_file string /hd-media/recipe*

*# If not, you can put an entire recipe into the preconfiguration file in one*
*# (logical) line. This example creates a small /boot partition, suitable*
*# swap, and uses the rest of the space for the root partition:*
*d-i partman-auto/expert_recipe string                         \*
*      custom-lvm ::                                           \*
*        256 256 256 ext4 $primary{ } $bootable{ }             \*
*        mountpoint{ /boot }                                   \*
*        method{ format }                                      \*
*        format{ }                                             \*
*        use_filesystem{ }                                     \*
*        filesystem{ ext4 }                                    \*
*        .                                                     \*
*        10240 10240 100% linux-swap $lvmok{ }                   \*
*        lv_name{ swap }                                       \*
*        in_vg { VG01 }                              			\*
*        method{ swap }                                        \*
*        format{ }                                             \*
*		.                                                     \*
*        40960 40960 40960 ext4 $lvmok{ }                      \*
*        mountpoint{ / }                                       \*
*        lv_name{ lv_root }                                       \*
*        in_vg { VG01 }                              			\*
*        method{ format }                                      \*
*        format{ }                                             \*
*        use_filesystem{ }                                     \*
*        filesystem{ ext4 }                                    \*
*        .                                                     \*
*        10240 10240 10240 ext4 $lvmok{ }                    \*
*        mountpoint{ /tmp }                                   \*
*        lv_name{ lv_tmp }                                       \*
*        in_vg { VG01 }                              			\*
*        method{ format }                                      \*
*        format{ }                                             \*
*        use_filesystem{ }                                     \*
*        filesystem{ ext4 }                                    \*
*        .                                                     \*
*        25600 25600 25600 ext4 $lvmok{ }                    \*
*        mountpoint{ /opt/dump }                                   \*
*        lv_name{ lv_dump }                                       \*
*        in_vg { VG01 }                              			\*
*        method{ format }                                      \*
*        format{ }                                             \*
*        use_filesystem{ }                                     \*
*        filesystem{ ext4 }                                    \*
*		.                                                     \*
*        10240 10240 -1 ext4 $lvmok{ }                    \*
*        mountpoint{ /home }                                   \*
*        lv_name{ lv_home }                                       \*
*        in_vg { VG01 }                              			\*
*        method{ format }                                      \*
*        format{ }                                             \*
*        use_filesystem{ }                                     \*
*        filesystem{ ext4 }                                    \*
*		.*

*# If you just want to change the default filesystem from ext3 to something*
*# else, you can do that without providing a full recipe.*
*d-i partman/default_filesystem string ext4*

*# The full recipe format is documented in the file partman-auto-recipe.txt*
*# included in the 'debian-installer' package or available from D-I source*
*# repository. This also documents how to specify settings such as file*
*# system labels, volume group names and which physical devices to include*
*# in a volume group.*

*# This makes partman automatically partition without confirmation, provided*
*# that you told it what to do using one of the methods above.*
*d-i partman-partitioning/confirm_write_new_label boolean true*
*d-i partman/choose_partition select finish*
*d-i partman/confirm boolean true*
*d-i partman/confirm_nooverwrite boolean true*

Hello and welcome.
I am just moving your query to the support section so that members can see you are asking some questions :slight_smile:

Hello, I have fine tuned the subject and formatting. Hopefully someone who uses Debian and encryption can help, I am heavy Red Hat user :slight_smile: We do have a possibility to click through the installation and Anaconda leaves kickstart recipe so it can be reused later on. Not sure if there’s anything like that in D-I (debian installer).

Since this is pretty specific question, you cannot go wrong asking on the D-I mailing list.

1 Like

I Izap,
Thank you for your answer. For the moment I use Debian.
For the moment I am using Debian, but afterwards I will use Red Hat Satellite but I don’t know when it will be implemented.

Regards