aboutsummaryrefslogtreecommitdiff
path: root/docs/gnulinux/encrypted_parabola.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/gnulinux/encrypted_parabola.md')
-rw-r--r--docs/gnulinux/encrypted_parabola.md309
1 files changed, 206 insertions, 103 deletions
diff --git a/docs/gnulinux/encrypted_parabola.md b/docs/gnulinux/encrypted_parabola.md
index f6c022a0..51ba0b5f 100644
--- a/docs/gnulinux/encrypted_parabola.md
+++ b/docs/gnulinux/encrypted_parabola.md
@@ -70,12 +70,14 @@ article](https://wiki.archlinux.org/index.php/Solid_State_Drives). Edit
/etc/fstab later on when chrooted into your install. Also, read the
whole article and keep all points in mind, adapting them for this guide.
-Securely wipe the drive:\
+Securely wipe the drive:
+
# dd if=/dev/urandom of=/dev/sda; sync
NOTE: If you have an SSD, only do this the first time. If it was already
LUKS-encrypted before, use the info below to wipe the LUKS header. Also,
check online for your SSD what the recommended erase block size is. For
-example if it was 2MiB:\
+example if it was 2MiB:
+
# **dd if=/dev/urandom of=/dev/sda bs=2M; sync**
If your drive was already LUKS encrypted (maybe you are re-installing
@@ -84,7 +86,8 @@ header.
<https://www.lisenet.com/2013/luks-add-keys-backup-and-restore-volume-header/>
showed me how to do this. It recommends doing the first 3MiB. Now, that
guide is recommending putting zero there. I'm going to use urandom. Do
-this:\
+this:
+
# head -c 3145728 /dev/urandom > /dev/sda; sync
(Wiping the LUKS header is important, since it has hashed passphrases
and so on. It's 'secure', but 'potentially' a risk).
@@ -95,7 +98,8 @@ Change keyboard layout
----------------------
Parabola live shell assumes US Qwerty. If you have something different,
-list the available keymaps and use yours:\
+list the available keymaps and use yours:
+
# localectl list-keymaps
# loadkeys LAYOUT
For me, LAYOUT would have been dvorak-uk.
@@ -124,7 +128,8 @@ dm-mod
------
device-mapper will be used - a lot. Make sure that the kernel module is
-loaded:\
+loaded:
+
# **modprobe dm-mod**
Create LUKS partition
@@ -138,28 +143,34 @@ prepared cryptsetup command below. Note that the iteration time is for
security purposes (mitigates brute force attacks), so anything lower
than 5 seconds is probably not ok.
-I am using MBR partitioning, so I use cfdisk:\
+I am using MBR partitioning, so I use cfdisk:
+
# **cfdisk /dev/sda**
I create a single large sda1 filling the whole drive, leaving it as the
default type 'Linux' (83).
Now I refer to
-<https://wiki.archlinux.org/index.php/Dm-crypt/Drive_preparation#Partitioning>:\
+<https://wiki.archlinux.org/index.php/Dm-crypt/Drive_preparation#Partitioning>:
+
I am then directed to
<https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption>.
Parabola forces you to RTFM. Do that.
-It tells me to run:\
+It tells me to run:
+
# **cryptsetup benchmark** (for making sure the list below is
-populated)\
-Then:\
+populated)
+
+Then:
+
# cat /proc/crypto
This gives me crypto options that I can use. It also provides a
representation of the best way to set up LUKS (in this case, security is
a priority; speed, a distant second). To gain a better understanding, I
-am also reading:\
+am also reading:
+
# **man cryptsetup**
Following that page, based on my requirements, I do the following based
@@ -168,7 +179,8 @@ on
Reading through, it seems like Serpent (encryption) and Whirlpool (hash)
is the best option.
-I am initializing LUKS with the following:\
+I am initializing LUKS with the following:
+
# **cryptsetup -v \--cipher serpent-xts-plain64 \--key-size 512 \--hash
whirlpool \--iter-time 500 \--use-random \--verify-passphrase luksFormat
/dev/sda1** Choose a **secure** passphrase here. Ideally lots of
@@ -186,31 +198,40 @@ Create LVM
Now I refer to <https://wiki.archlinux.org/index.php/LVM>.
-Open the LUKS partition:\
+Open the LUKS partition:
+
# cryptsetup luksOpen /dev/sda1 lvm
(it will be available at /dev/mapper/lvm)
-Create LVM partition:\
+Create LVM partition:
+
# pvcreate /dev/mapper/lvm
-Show that you just created it:\
+Show that you just created it:
+
# **pvdisplay**
Now I create the volume group, inside of which the logical volumes will
-be created:\
+be created:
+
# vgcreate matrix /dev/mapper/lvm
(volume group name is 'matrix' - choose your own name, if you like)
-Show that you created it:\
+Show that you created it:
+
# **vgdisplay**
-Now create the logical volumes:\
+Now create the logical volumes:
+
# **lvcreate -L 2G matrix -n swapvol** (2G swap partition, named
-swapvol)\
+swapvol)
+
Again, choose your own name if you like. Also, make sure to choose a
swap size of your own needs. It basically depends on how much RAM you
have installed. I refer to
-<http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space>.\
+<http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space>.
+
# **lvcreate -l +100%FREE matrix -n root** (single large partition in
-the rest of the space, named root)\
+the rest of the space, named root)
+
You can also be flexible here, for example you can specify a /boot, a /,
a /home, a /var, a /usr, etc. For example, if you will be running a
web/mail server then you want /var in its own partition (so that if it
@@ -218,7 +239,8 @@ fills up with logs, it won't crash your system). For a home/laptop
system (typical use case), a root and a swap will do (really).
Verify that the logical volumes were created, using the following
-command:\
+command:
+
# **lvdisplay**
@@ -226,15 +248,19 @@ command:\
Create / and swap partitions, and mount
---------------------------------------
-For the swapvol LV I use:\
+For the swapvol LV I use:
+
# mkswap /dev/mapper/matrix-swapvol
-Activate swap:\
+Activate swap:
+
# **swapon /dev/matrix/swapvol**
-For the root LV I use:\
+For the root LV I use:
+
# **mkfs.btrfs /dev/mapper/matrix-root**
-Mount the root (/) partition:\
+Mount the root (/) partition:
+
# **mount /dev/matrix/root /mnt**
@@ -249,7 +275,8 @@ Now I am following the rest of
<https://wiki.parabolagnulinux.org/Installation_Guide>. I also cross
referenced <https://wiki.archlinux.org/index.php/Installation_guide>.
-Create /home and /boot on root mountpoint:\
+Create /home and /boot on root mountpoint:
+
# mkdir -p /mnt/home
# **mkdir -p /mnt/boot**
@@ -258,50 +285,68 @@ devices are ready to install Parabola.
In **/etc/pacman.d/mirrorlist**, comment out all lines except the Server
line closest to where you are (I chose the UK Parabola server (main
-server)) and then did:\
+server)) and then did:
+
# pacman -Syy
# pacman -Syu
# **pacman -Sy pacman** (and then I did the other 2 steps above,
-again)\
+again)
+
In my case I did the steps in the next paragraph, and followed the steps
in this paragraph again.
-<troubleshooting>\
+<troubleshooting>
+
   The following is based on 'Verification of package signatures' in
-the Parabola install guide.\
-   Check there first to see if steps differ by now.\
+the Parabola install guide.
+
+   Check there first to see if steps differ by now.
+
   Now you have to update the default Parabola keyring. This is used for
-signing and verifying packages:\
+signing and verifying packages:
+
    # pacman -Sy parabola-keyring
   It says that if you get GPG errors, then it's probably an expired
-key and, therefore, you should do:\
+key and, therefore, you should do:
+
    # pacman-key \--populate parabola
    # pacman-key \--refresh-keys
    # pacman -Sy parabola-keyring
   To be honest, you should do the above anyway. Parabola has a lot of
-maintainers, and a lot of keys. Really!\
-   If you get an error mentioning dirmngr, do:\
+maintainers, and a lot of keys. Really!
+
+   If you get an error mentioning dirmngr, do:
+
    # dirmngr </dev/null
   Also, it says that if the clock is set incorrectly then you have to
-manually set the correct time\
-   (if keys are listed as expired because of it):\
+manually set the correct time
+
+   (if keys are listed as expired because of it):
+
    # date MMDDhhmm\[\[CC\]YY\]\[.ss\]
-   I also had to install:\
+   I also had to install:
+
    # pacman -S archlinux-keyring
    # pacman-key \--populate archlinux
   In my case I saw some conflicting files reported in pacman, stopping
-me from using it.\
+me from using it.
+
   I deleted the files that it mentioned and then it worked.
-Specifically, I had this error:\
-   *licenses: /usr/share/licenses/common/MPS exists in filesystem*\
+Specifically, I had this error:
+
+   *licenses: /usr/share/licenses/common/MPS exists in filesystem*
+
   I rm -Rf'd the file and then pacman worked. I'm told that the
-following would have also made it work:\
+following would have also made it work:
+
    # pacman -Sf licenses
-</troubleshooting>\
+</troubleshooting>
+
I also like to install other packages (base-devel, compilers and so on)
and wpa\_supplicant/dialog/iw/wpa\_actiond are needed for wireless after
-the install:\
+the install:
+
# **pacstrap /mnt base base-devel wpa\_supplicant dialog iw
wpa\_actiond**
@@ -312,21 +357,26 @@ Configure the system
Generate an fstab - UUIDs are used because they have certain advantages
(see <https://wiki.parabola.nu/Fstab#Identifying_filesystems>. If you
-prefer labels instead, replace the -U option with -L):\
+prefer labels instead, replace the -U option with -L):
+
# genfstab -U -p /mnt >> /mnt/etc/fstab
-Check the created file:\
+Check the created file:
+
# cat /mnt/etc/fstab
(If there are any errors, edit the file. Do **NOT** run the genfstab
command again!)
-Chroot into new system:\
+Chroot into new system:
+
# **arch-chroot /mnt /bin/bash**
-It's a good idea to have this installed:\
+It's a good idea to have this installed:
+
# **pacman -S linux-libre-lts**
It was also suggested that you should install this kernel (read up on
-what GRSEC is):\
+what GRSEC is):
+
# **pacman -S linux-libre-grsec**
This is another kernel that sits inside /boot, which you can use. LTS
@@ -334,35 +384,43 @@ means 'long-term support'. These are so-called 'stable' kernels that
can be used as a fallback during updates, if a bad kernel causes issues
for you.
-Parabola does not have wget. This is sinister. Install it:\
+Parabola does not have wget. This is sinister. Install it:
+
# **pacman -S wget**
-Locale:\
+Locale:
+
# vi /etc/locale.gen
Uncomment your needed localisations. For example en\_GB.UTF-8 (UTF-8 is
-highly recommended over other options).\
+highly recommended over other options).
+
# locale-gen
# echo LANG=en\_GB.UTF-8 > /etc/locale.conf
# **export LANG=en\_GB.UTF-8**
-Console font and keymap:\
+Console font and keymap:
+
# vi /etc/vconsole.conf
In my case:
KEYMAP=dvorak-uk
FONT=lat9w-16
-Time zone:\
+Time zone:
+
# ln -s /usr/share/zoneinfo/Europe/London /etc/localtime
(Replace Zone and Subzone to your liking. See /usr/share/zoneinfo)
-Hardware clock:\
+Hardware clock:
+
# **hwclock \--systohc \--utc**
Hostname: Write your hostname to /etc/hostname. For example, if your
-hostname is parabola:\
+hostname is parabola:
+
# echo parabola > /etc/hostname
-Add the same hostname to /etc/hosts:\
+Add the same hostname to /etc/hosts:
+
# vi /etc/hosts
#<ip-address> <hostname.domain.org> <hostname>
@@ -376,7 +434,8 @@ Mkinitcpio: Configure /etc/mkinitcpio.conf as needed (see
<https://wiki.parabola.nu/Mkinitcpio>). Runtime modules can be found in
/usr/lib/initcpio/hooks, and build hooks can be found in
/usr/lib/initcpio/install. (# **mkinitcpio -H hookname** gives
-information about each hook.) Specifically, for this use case:\
+information about each hook.) Specifically, for this use case:
+
# vi /etc/mkinitcpio.conf
Then modify the file like so:
@@ -401,18 +460,23 @@ Then modify the file like so:
Now using mkinitcpio, you can create the kernel and ramdisk for booting
with (this is different from Arch, specifying linux-libre instead of
-linux):\
+linux):
+
# mkinitcpio -p linux-libre
-Also do it for linux-libre-lts:\
+Also do it for linux-libre-lts:
+
# mkinitcpio -p linux-libre-lts
-Also do it for linux-libre-grsec:\
+Also do it for linux-libre-grsec:
+
# **mkinitcpio -p linux-libre-grsec**
Set the root password: At the time of writing, Parabola used SHA512 by
default for its password hashing. I referred to
-<https://wiki.archlinux.org/index.php/SHA_password_hashes>.\
+<https://wiki.archlinux.org/index.php/SHA_password_hashes>.
+
# vi /etc/pam.d/passwd
-Add rounds=65536 at the end of the uncommented 'password' line.\
+Add rounds=65536 at the end of the uncommented 'password' line.
+
# passwd root
Make sure to set a secure password! Also, it must never be the same as
your LUKS password.
@@ -427,17 +491,24 @@ Extra security tweaks
Based on <https://wiki.archlinux.org/index.php/Security>.
-Restrict access to important directories:\
+Restrict access to important directories:
+
# **chmod 700 /boot /etc/{iptables,arptables}**
-Lockout user after three failed login attempts:\
-Edit the file /etc/pam.d/system-login and comment out that line:\
-*# auth required pam\_tally.so onerr=succeed file=/var/log/faillog*\
-Or just delete it. Above it, put:\
+Lockout user after three failed login attempts:
+
+Edit the file /etc/pam.d/system-login and comment out that line:
+
+*# auth required pam\_tally.so onerr=succeed file=/var/log/faillog*
+
+Or just delete it. Above it, put:
+
*auth required pam\_tally.so deny=2 unlock\_time=600 onerr=succeed
-file=/var/log/faillog*\
+file=/var/log/faillog*
+
To unlock a user manually (if a password attempt is failed 3 times),
-do:\
+do:
+
# **pam\_tally \--user *theusername* \--reset** What the above
configuration does is lock the user out for 10 minutes, if they make 3
failed login attempts.
@@ -451,18 +522,22 @@ don't really need sudo.
Unmount, reboot!
----------------
-Exit from chroot:\
+Exit from chroot:
+
# **exit**
-unmount:\
+unmount:
+
# umount -R /mnt
# **swapoff -a**
-deactivate the lvm lv's:\
+deactivate the lvm lv's:
+
# lvchange -an /dev/matrix/root
# lvchange -an /dev/matrix/swapvol
-Lock the encrypted partition (close it):\
+Lock the encrypted partition (close it):
+
# **cryptsetup luksClose lvm**
# shutdown -h now
@@ -480,7 +555,8 @@ underlines will boot lts kernel instead of normal).
grub> cryptomount -a
grub> set root='lvm/matrix-root'
grub> **linux /boot/vmlinuz-linux-libre-lts root=/dev/matrix/root
-cryptdevice=/dev/sda1:root**\
+cryptdevice=/dev/sda1:root**
+
grub> initrd /boot/initramfs-linux-libre-lts.img
grub> boot
@@ -520,16 +596,21 @@ possibility of bricking your device!
I will go for the re-flash option here. Firstly, cd to the
libreboot\_util/cbfstool/{armv7l i686 x86\_64} directory. Dump the
current firmware - where *libreboot.rom* is an example: make sure to
-adapt:\
+adapt:
+
# flashrom -p internal -r libreboot.rom
If flashrom complains about multiple flash chips detected, add a *-c*
-option at the end, with the name of your chosen chip is quotes.\
+option at the end, with the name of your chosen chip is quotes.
+
You can check if everything is in there (*grub.cfg* and *grubtest.cfg*
-would be really nice):\
+would be really nice):
+
$ ./cbfstool libreboot.rom print
-Extract grubtest.cfg:\
+Extract grubtest.cfg:
+
$ ./cbfstool libreboot.rom extract -n grubtest.cfg -f grubtest.cfg
-And modify:\
+And modify:
+
$ **vi grubtest.cfg**
In grubtest.cfg, inside the 'Load Operating System' menu entry, change
@@ -558,18 +639,23 @@ detected LUKS volumes. You can also specify -u UUID or -a (device).
hardening your GRUB configuration, for security purposes.
Save your changes in grubtest.cfg, then delete the unmodified config
-from the ROM image:\
+from the ROM image:
+
$ ./cbfstool libreboot.rom remove -n grubtest.cfg
-and insert the modified grubtest.cfg:\
+and insert the modified grubtest.cfg:
+
$ **./cbfstool libreboot.rom add -n grubtest.cfg -f grubtest.cfg -t
-raw**\
+raw**
+
Now refer to <http://libreboot.org/docs/install/#flashrom>. Cd (up) to
-the libreboot\_util directory and update the flash chip contents:\
+the libreboot\_util directory and update the flash chip contents:
+
# ./flash update libreboot.rom
Ocassionally, coreboot changes the name of a given board. If flashrom
complains about a board mismatch, but you are sure that you chose the
-correct ROM image, then run this alternative command:\
+correct ROM image, then run this alternative command:
+
# ./flash forceupdate libreboot.rom
You should see "Verifying flash... VERIFIED." written at the end of
the flashrom output.
@@ -596,25 +682,31 @@ the main config still links (in the menu) to grubtest.cfg, so that you
don't have to manually switch to it, in case you ever want to follow
this guide again in the future (modifying the already modified config).
Inside libreboot\_util/cbfstool/{armv7l i686 x86\_64}, we can do this
-with the following command:\
+with the following command:
+
$ **sed -e 's:(cbfsdisk)/grub.cfg:(cbfsdisk)/grubtest.cfg:g' -e
's:Switch to grub.cfg:Switch to grubtest.cfg:g' < grubtest.cfg >
-grub.cfg**\
-Delete the grub.cfg that remained inside the ROM:\
+grub.cfg**
+
+Delete the grub.cfg that remained inside the ROM:
+
$ ./cbfstool libreboot.rom remove -n grub.cfg
-Add the modified version that you just made:\
+Add the modified version that you just made:
+
$ ./cbfstool libreboot.rom add -n grub.cfg -f grub.cfg -t raw
Now you have a modified ROM. Once more, refer to
<http://libreboot.org/docs/install/#flashrom>. Cd to the libreboot\_util
-directory and update the flash chip contents:\
+directory and update the flash chip contents:
+
# ./flash update libreboot.rom
And wait for the "Verifying flash... VERIFIED." Once you have done
that, shut down and then boot up with your new configuration.
When done, delete GRUB (remember, we only needed it for the
*grub-mkpasswd-pbkdf2* utility; GRUB is already part of libreboot,
-flashed alongside it as a *payload*):\
+flashed alongside it as a *payload*):
+
# **pacman -R grub**
@@ -635,23 +727,31 @@ fact that it is being loaded from an encrypted volume. Therefore, you
will be asked to enter your passphrase a second time. A workaround is to
put a keyfile inside initramfs, with instructions for the kernel to use
it when booting. This is safe, because /boot/ is encrypted (otherwise,
-putting a keyfile inside initramfs would be a bad idea).\
-Boot up and login as root or your user. Then generate the key file:\
+putting a keyfile inside initramfs would be a bad idea).
+
+Boot up and login as root or your user. Then generate the key file:
+
# **dd bs=512 count=4 if=/dev/urandom of=/etc/mykeyfile
-iflag=fullblock**\
-Insert it into the luks volume:\
+iflag=fullblock**
+
+Insert it into the luks volume:
+
# cryptsetup luksAddKey /dev/sdX /etc/mykeyfile
and enter your LUKS passphrase when prompted. Add the keyfile to the
-initramfs by adding it to FILES in /etc/mkinitcpio.conf. For example:\
+initramfs by adding it to FILES in /etc/mkinitcpio.conf. For example:
+
# FILES="/etc/mykeyfile"
-Create the initramfs image from scratch:\
+Create the initramfs image from scratch:
+
# mkinitcpio -p linux-libre
# mkinitcpio -p linux-libre-lts
# mkinitcpio -p linux-libre-grsec
Add the following to your grub.cfg - you are now able to do that, see
-above! -, or add it in the kernel command line for GRUB:\
+above! -, or add it in the kernel command line for GRUB:
+
# cryptkey=rootfs:/etc/mykeyfile
-\
+
+
You can also place this inside the grub.cfg that exists in CBFS:
[grub\_cbfs.html](grub_cbfs.html).
@@ -660,7 +760,8 @@ You can also place this inside the grub.cfg that exists in CBFS:
Further security tips
---------------------
-<https://wiki.archlinux.org/index.php/Security>.\
+<https://wiki.archlinux.org/index.php/Security>.
+
<https://wiki.parabolagnulinux.org/User:GNUtoo/laptop>
@@ -755,8 +856,10 @@ problems. Removing that worked around the issue.
-Copyright © 2014, 2015, 2016 Leah Rowe <info@minifree.org>\
-Copyright © 2015 Jeroen Quint <jezza@diplomail.ch>\
+Copyright © 2014, 2015, 2016 Leah Rowe <info@minifree.org>
+
+Copyright © 2015 Jeroen Quint <jezza@diplomail.ch>
+
Permission is granted to copy, distribute and/or modify this document
under the terms of the Creative Commons Attribution-ShareAlike 4.0
International license or any later version published by Creative