<p>AlongtimeagoIfiguredoutthat<ahref="https://wiki.archlinux.org/index.php/GRUB#Boot_partition"target="_blank">GRUB2hasthecapabilityofdecryptingaLUKSencryptedpartition</a>thereforeallowingforthe<code>`/boot'</code> partition to be encrypted, however I haven'thadthetimetotestitoutuntiltoday.AfterthatIdecidedit'dbeagoodideatowriteablogentryonhowIdidit,tohelpothersandtoserveasareferenceformyselfnexttimeIwanttodoaninstall.</p>
<p><b>NOTICE:</b>InthispostIwillbeusing<code>`/dev/sda'</code> to refer to the device on which I want to put the encrypted partition, I will be calling my LVM container <code>`lvmcrypt'</code>, the logical volume group <code>`CryptGroup'</code>,theswaplogicalpartition<code>`swap'</code>, and the root logical partition <code>`root'</code>.Changeanyoftheseifyoucareto,feelfreetocustomize.</p>
<p>Alright,solet'sgettoit!</p>
<h3>Partitioning&Formatting</h3>
<p>
Myphysicalpartitioningisquitesimple,Ihaveonepartition(<code>`/dev/sda1'</code>) set to be the entire disk, make sure the type is set to <code>`LinuxLVM'</code>. After this you'llwanttosetupaLUKSpartitionusing<code>`cryptsetup'</code>. First load the <code>`dm-crypt'</code> module via <code>`modprobe dm-crypt'</code>,afterwardsyoucanformatthepartitionvia<code>`cryptsetup -s <key_size> luksFormat /dev/sda1'</code>. You can probably change come settings to it to choose different ciphers and such. In order to get some benchmarks for what cipher would be best for your system use <code>`cryptsetupbenchmark'</code>. After formatting the partition you'llhavetoopenitvia<code>`cryptsetupluksOpen/dev/sda1lvmcrypt'</code>.</p>
# Create physical LVM container on partition<br />
pvcreate/dev/mapper/lvmcrypt<br/>
# Create LVM group<br />
vgcreateCryptGroup/dev/mapper/lvmcrypt<br/>
# Create swap partition<br />
lvcreate-Cy-L4GCryptGroup-nswap<br/>
# Create root partition<br />
lvcreate-l+100%FREECryptGroup-nroot
</code>
<p>Nowyoushouldhavethefollowingspecialfilesinyourmapper:<code>`CryptGroup-swap'</code> and <code>`CryptGroup-root'</code>.Thesenowneedtobeformatted:</p>
<code>
mkfs.ext4/dev/mapper/CryptGroup-root<br/>
mkswap/dev/mapper/CryptGroup-swap-Lswap
</code>
<p>Afterthispointyoucancontinuewithyourtypicalinstallationusing<code>`CryptGroup-root'</code> and <code>`CryptGroup-swap'</code>untilyoureachtheendoftheinstallationwhereyouneedtoconfigureabootloaderandcustomkernelhooks.</p>
<h3>Bootloader(GRUB2)</h3>
<p>Firstly,makesureyou're using GRUB2, older versions of GRUB do not have the decrypt functionality. You'llwanttoeditthe<code>`/etc/default/grub'</code> file. Uncomment the line that says <code>`GRUB_ENABLE_CRYPTODISK=y'</code>.ThiswillallowGRUBtodecryptthepartitioninordertofindthekernel.</p>
<h3>KernelHooks</h3>
<p>JustlikeinLVMonLUKS,thekernelwillneedtodecryptaswell(notonlyGRUB).ForthisyouwillwanttoeditthecommandlineparametersofLinuxin<code>`/etc/default/grub'</code> to look like this: <code>`GRUB_CMDLINE_LINUX_DEFAULT="quiet splash cryptdevice=/dev/sda1:lvmcrypt root=/dev/mapper/VolGroup0-root resume=/dev/mapper/VolGroup0-swap"'</code>. This will tell the Linux kernel where the kernel, root, and swap are. Since we have the root in an LVM container you will also have to set <code>`GRUB_PRELOAD_MODULES="part_gpt part_msdos lvm"'</code>.</p>
<p>Youwillalsohavetoeditthekernelhooksin<code>`/etc/mkinitcpio.conf'</code> to look like this: <code>`HOOKS="base udev autodetect modconf keyboard block encrypt lvm2 resume filesystems fsck"'</code>. The important hooks here are <code>`keyboard'</code>,<code>`encrypt'</code>, <code>`lvm2'</code>, and <code>`resume'</code>.</p>