How to install CRUX with encryption
How to install fully encrypted CRUX
This post is for crux users who wanna secure their crux installation.
Partitioning
I’m gonna use two partitions. First boot partition will be unencrypted which holds kernel. I use secure boot with my own keys. You can find a post in my blog how to do that. and I have some ports too for secure boot.
Unencrypted Boot Partition
Create a partition more than 200 Mbs for boot ESP with gdisk code ef00.
Let’s create a FAT filesystem on it for EFI.
|
|
Encrypted Partition
Create an encrypted LUKS container
|
|
Type uppercase “YES” and then enter passphrase two times.
Open the encrypted container.
|
|
Now the encrypted container is available at /dev/mapper/crux so lets create some lvm stuff and create filesystems and a swap partition.
|
|
Mount the partitions and start installations.
|
|
Base system installation
Start installation. Type “setup” and select “YES”. Install all packages. Make sure you get no error messages once installation is finished.
|
|
Chroot
Enter chroot.
|
|
fstab
Check fstab by going to /etc/fstab. Open it with vim. You’ll see two uncommented entries there. Leave them as it is. In vim prompt mode just type :r! blkid and you’ll get UUIDs of all partitions. Add them there for root, home, boot and swap partitions.
locales
Generate locales.
|
|
rc.conf
Edit rc.conf. Mine looks like this.
|
|
resolv.conf
Edit /etc/resolv.conf. I’m using OpenDNS nameserver here.
|
|
wifi
For wireless connection, you can use wpa_supplicant. For example if your interface is wlp3s0 and SSID is nix, add passphrase to it using wpa_passphrase like this.
|
|
Kernel
Compile the kernel now. Go to the /usr/src/linux directory. Configure the kernel config. Since we are gonna have an encrypted installation, we need some extra drivers. Invoke ‘make menuconfig’ and enable these options. And also enable what is needed for your hardware. I’ll add only options needed for encryption here.
|
|
You can get my kernel config from https://gitlab.com/Abdullah/cfg/raw/master/kernel/config by using wget and then edit it as per your hardware. This one is for Thinkpad with SSD.
|
|
After you’re done with configuring kernel, compile it. Once it’s compiled, copy it to /boot directory and install modules.
|
|
Users and package management
Root password and a normal user
Set root password. Create our first user. And then we will create a second user for package management.
|
|
Give new user sudo access
Add new created user to sudoers. Uncomment this line in /etc/sudoers.
|
|
User for creating packages
Now let’s create a user for package management.
|
|
Add our user to this newly created group.
|
|
fakeroot
Edit /etc/prt-get.conf to set up fakeroot building.
|
|
Edit /etc/pkgmk.conf.
|
|
Create those directories.
|
|
Enable contrib repository.
|
|
Add my custom ports repository.
|
|
Enable contrib and my repository by editing /etc/prt-get.conf. Uncomment the line which says “prtdir /usr/ports/contrib” and add this line on top of the other port directories path. “prtdir /usr/ports/ak”. Also don’t forget to uncomment the line which says, “runscripts yes”. After editing the file, it should be look like this.
|
|
Sync ports now.
|
|
Get fakeroot installed if you don’t have yet.
|
|
Dracut
Get dracut and create an initramfs.
|
|
Bootloader
I’m using EFISTUB. If you’re using some other boot manager like grub, consult their wiki. There are some dracut related variables in this example. I’d recommand, create a new file with vim, and then in prompt mode, type :r! blkid so you’ll get all UUIDs there in the file. Just copy them in the new file, delete other lines and save it. Then redirect this file’s output to shell like this, ‘cat newCreatedFile | sh’. It will create a new entry. root-UUID=, rd.luks.uuid=, and rd.lvm.vg=. For EFISTUB, create an entry like this.
|
|
Congrats!
Congrats! You have now a fully encrypted system. Reboot now. If you have some problems, just send me an email and I’ll be glad to help.