encrypted_parabola.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <style type="text/css">
  7. @import url('../css/main.css');
  8. </style>
  9. <title>Installing Parabola GNU/Linux with full disk encryption (including /boot)</title>
  10. </head>
  11. <body>
  12. <div class="section">
  13. <h1>Installing Parabola GNU/Linux with full disk encryption (including /boot)</h1>
  14. <p>
  15. Libreboot uses the GRUB <a href="http://www.coreboot.org/Payloads#GRUB_2">payload</a>
  16. by default, which means that the GRUB configuration file
  17. (where your GRUB menu comes from) is stored directly alongside libreboot
  18. and it's GRUB payload executable, inside
  19. the flash chip. In context, this means that installing distributions and managing them
  20. is handled slightly differently compared to traditional BIOS systems.
  21. </p>
  22. <p>
  23. On most systems, the /boot partition has to be left unencrypted while the others are encrypted.
  24. This is so that GRUB, and therefore the kernel, can be loaded and executed since the firmware
  25. can't open a LUKS volume. Not so with libreboot! Since GRUB is already included directly as a
  26. payload, even /boot can be encrypted. This protects /boot from tampering by someone with physical
  27. access to the system.
  28. </p>
  29. <p>
  30. <a href="index.html">Back to previous index</a>
  31. </p>
  32. </div>
  33. <div class="section">
  34. <p>
  35. Boot Parabola's install environment. <a href="grub_boot_installer.html">How to boot a GNU/Linux installer</a>.
  36. </p>
  37. <p>
  38. For this guide I used the 2015 08 01 image to boot the live installer and install the system.
  39. This is available at <a href="https://wiki.parabola.nu/Get_Parabola#Main_live_ISO">this page</a>.
  40. </p>
  41. <p>
  42. This guide will go through the installation steps taken at the time of writing, which may or may not change due to
  43. the volatile nature of Parabola (it changes all the time). In general most of it should remain the same. If you spot mistakes,
  44. please say so! This guide will be ported to the Parabola wiki at a later date. For up to date Parabola install guide, go to
  45. the Parabola wiki. This guide essentially cherry picks the useful information (valid at the
  46. time of writing: 2015-08-25).
  47. </p>
  48. </div>
  49. <div class="section">
  50. <p> This section deals with wiping the storage device on which you plan to install Parabola
  51. GNU/Linux. Follow these steps, but if you use an SSD, also:
  52. <p>
  53. - beware there are issues with TRIM (not enabled through luks) and security issues if you do enable it.
  54. See <a href="https://wiki.archlinux.org/index.php/Dm-crypt/Specialties#Discard.2FTRIM_support_for_solid_state_drives_.28SSD.29">this page</a>
  55. for more info.
  56. </p>
  57. <p> - make sure it's brand-new (or barely used). Or, otherwise, be sure that it never previously contained plaintext copies of your data.
  58. </p>
  59. <p> - make sure to read <a href="https://wiki.archlinux.org/index.php/Solid_State_Drives">this article</a>. Edit /etc/fstab later on when
  60. chrooted into your install. Also, read the whole article and keep all points in mind, adapting them for this guide.
  61. </p>
  62. <p>
  63. Wipe the MBR (if you use MBR):<br/>
  64. # <b>lsblk</b><br/>
  65. Your storage is probably /dev/sda, but be very sure to double check this or you WILL lose your data!<br/>
  66. # <b>dd if=/dev/zero of=/dev/sda bs=446 count=1; sync</b><br/>
  67. Never use SeaBIOS! The MBR section can easily be changed with malicious code, which SeaBIOS will blindly execute.
  68. This guide is for libreboot with GRUB-as-payload only.
  69. </p>
  70. <p>
  71. Securely wipe the drive:<br/>
  72. # <b>dd if=/dev/urandom of=/dev/sda; sync</b><br/>
  73. NOTE: If you have an SSD, only do this the first time. If it was already LUKS-encrypted before,
  74. use the info below to wipe the LUKS header. Also, check online for your SSD what the recommended
  75. erase block size is. For example if it was 2MiB:<br/>
  76. # <b>dd if=/dev/urandom of=/dev/sda bs=2M; sync</b>
  77. </p>
  78. <p>
  79. If your drive was already LUKS encrypted (maybe you are re-installing your distro) then
  80. it is already 'wiped'. You should just wipe the LUKS header.
  81. <a href="https://www.lisenet.com/2013/luks-add-keys-backup-and-restore-volume-header/">https://www.lisenet.com/2013/luks-add-keys-backup-and-restore-volume-header/</a>
  82. 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:<br/>
  83. # <b>head -c 3145728 /dev/urandom &gt; /dev/sda; sync</b><br/>
  84. (Wiping the LUKS header is important, since it has hashed passphrases and so on. It's 'secure', but 'potentially' a risk).
  85. </p>
  86. </div>
  87. <div class="section">
  88. <h2>
  89. Change keyboard layout
  90. </h2>
  91. <p>
  92. Parabola live shell assumes US Qwerty. If you have something different, list the available keymaps and use yours:<br/>
  93. # <b>localectl list-keymaps</b><br/>
  94. # <b>loadkeys LAYOUT</b><br/>
  95. For me, LAYOUT would have been dvorak-uk.
  96. </p>
  97. </div>
  98. <div class="section">
  99. <h2>Establish an internet connection</h2>
  100. <p>
  101. Refer to <a href="https://wiki.parabola.nu/Beginners%27_guide#Establish_an_internet_connection">this guide</a>. Wired is recommended,
  102. but wireless is also explained there.
  103. </p>
  104. </div>
  105. <div class="section">
  106. <h2>Getting started</h2>
  107. <p>
  108. The beginning is based on <a href="https://wiki.parabolagnulinux.org/Installation_Guide">https://wiki.parabolagnulinux.org/Installation_Guide</a>.
  109. Then I referred to <a href="https://wiki.archlinux.org/index.php/Partitioning">https://wiki.archlinux.org/index.php/Partitioning</a> at first.
  110. </p>
  111. </div>
  112. <div class="section">
  113. <h2>dm-mod</h2>
  114. <p>
  115. device-mapper will be used - a lot. Make sure that the kernel module is loaded:<br/>
  116. # <b>modprobe dm-mod</b>
  117. </p>
  118. <h2>Create LUKS partition</h2>
  119. <p>
  120. I am using MBR partitioning, so I use cfdisk:<br/>
  121. # <b>cfdisk /dev/sda</b>
  122. </p>
  123. <p>
  124. I create a single large sda1 filling the whole drive, leaving it as the default type 'Linux' (83).
  125. </p>
  126. <p>
  127. Now I refer to <a href="https://wiki.archlinux.org/index.php/Dm-crypt/Drive_preparation#Partitioning">https://wiki.archlinux.org/index.php/Dm-crypt/Drive_preparation#Partitioning</a>:<br/>
  128. I am then directed to <a href="https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption">https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption</a>.
  129. </p>
  130. <p>
  131. Parabola forces you to RTFM. Do that.
  132. </p>
  133. <p>
  134. It tells me to run:<br/>
  135. # <b>cryptsetup benchmark</b> (for making sure the list below is populated)<br/>
  136. Then:<br/>
  137. # <b>cat /proc/crypto</b><br/>
  138. 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).
  139. To gain a better understanding, I am also reading:<br/>
  140. # <b>man cryptsetup</b>
  141. </p>
  142. <p>
  143. Following that page, based on my requirements, I do the following based on <a href="https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption#Encryption_options_for_LUKS_mode">https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption#Encryption_options_for_LUKS_mode</a>.
  144. Reading through, it seems like Serpent (encryption) and Whirlpool (hash) is the best option.
  145. </p>
  146. <p>
  147. I am initializing LUKS with the following:<br/>
  148. # <b>cryptsetup -v --cipher serpent-xts-plain64 --key-size 512 --hash whirlpool --use-random --verify-passphrase luksFormat /dev/sda1</b>
  149. Choose a <b>secure</b> passphrase here. Ideally lots of lowercase/uppercase numbers, letters, symbols etc all in a random pattern. The
  150. password length should be as long as you are able to handle without writing it down or storing it anywhere.
  151. </p>
  152. </div>
  153. <div class="section">
  154. <h2>Create LVM</h2>
  155. <p>
  156. Now I refer to <a href="https://wiki.archlinux.org/index.php/LVM">https://wiki.archlinux.org/index.php/LVM</a>.
  157. </p>
  158. <p>
  159. Open the LUKS partition:<br/>
  160. # <b>cryptsetup luksOpen /dev/sda1 lvm</b><br/>
  161. (it will be available at /dev/mapper/lvm)
  162. </p>
  163. <p>
  164. Create LVM partition:<br/>
  165. # <b>pvcreate /dev/mapper/lvm</b><br/>
  166. Show that you just created it:<br/>
  167. # <b>pvdisplay</b>
  168. </p>
  169. <p>
  170. Now I create the volume group, inside of which the logical volumes will be created:<br/>
  171. # <b>vgcreate matrix /dev/mapper/lvm</b><br/>
  172. (volume group name is 'matrix' - choose your own name, if you like)
  173. Show that you created it:<br/>
  174. # <b>vgdisplay</b>
  175. </p>
  176. <p>
  177. Now create the logical volumes:<br/>
  178. # <b>lvcreate -L 2G matrix -n swapvol</b> (2G swap partition, named <u>swapvol</u>)<br/>
  179. 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
  180. you have installed. I refer to <a
  181. href="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</a>.<br/>
  182. # <b>lvcreate -l +100%FREE matrix -n rootvol</b> (single large partition in the rest of the space, named <u>rootvol</u>)<br/>
  183. You can also be flexible here, for example you can specify a /boot, a /, a /home, a /var, a /usr, etc. For example,
  184. if you will be running a web/mail server then you want /var in its own partition (so that if it fills up with logs, it won't crash your system).
  185. For a home/laptop system (typical use case), a root and a swap will do (really).
  186. </p>
  187. <p>
  188. Verify that the logical volumes were created, using the following command:<br/>
  189. # <b>lvdisplay</b>
  190. </p>
  191. </div>
  192. <div class="section">
  193. <h2>Create / and swap partitions, and mount</h2>
  194. <p>
  195. For the swapvol LV I use:<br/>
  196. # <b>mkswap /dev/mapper/matrix-swapvol</b><br/>
  197. Activate swap:<br/>
  198. # <b>swapon /dev/matrix/swapvol</b>
  199. </p>
  200. <p>
  201. For the rootvol LV I use:<br/>
  202. # <b>mkfs.ext4 /dev/mapper/matrix-rootvol</b>
  203. </p>
  204. <p>
  205. Mount the root (/) partition:<br/>
  206. # <b>mount /dev/matrix/rootvol /mnt</b>
  207. </p>
  208. </div>
  209. <div class="section">
  210. <h2>Continue with Parabola installation</h2>
  211. <p>
  212. This guide is really about GRUB, Parabola and cryptomount. I have to show how to install Parabola
  213. so that the guide can continue.
  214. </p>
  215. <p>
  216. Now I am following the rest of <a href="https://wiki.parabolagnulinux.org/Installation_Guide">https://wiki.parabolagnulinux.org/Installation_Guide</a>.
  217. I also cross referenced <a href="https://wiki.archlinux.org/index.php/Installation_guide">https://wiki.archlinux.org/index.php/Installation_guide</a>.
  218. </p>
  219. <p>
  220. Create /home and /boot on rootvol mountpoint:<br/>
  221. # <b>mkdir -p /mnt/home</b><br/>
  222. # <b>mkdir -p /mnt/boot</b>
  223. </p>
  224. <p>
  225. Once all the remaining partitions, if any, have been mounted, the devices are ready to install Parabola.
  226. </p>
  227. <p>
  228. In <b>/etc/pacman.d/mirrorlist</b>, comment out all lines except the Server line closest to where you are (I chose the UK Parabola
  229. server (main server)) and then did:<br/>
  230. # <b>pacman -Syy</b><br/>
  231. # <b>pacman -Syu</b><br/>
  232. # <b>pacman -Sy pacman</b> (and then I did the other 2 steps above, again)<br/>
  233. In my case I did the steps in the next paragraph, and followed the steps in this paragraph again.
  234. </p>
  235. <p>
  236. &lt;troubleshooting&gt;<br/>
  237. &nbsp;&nbsp;&nbsp;The following is based on 'Verification of package signatures' in the Parabola install guide.<br/>
  238. &nbsp;&nbsp;&nbsp;Check there first to see if steps differ by now.<br/>
  239. &nbsp;&nbsp;&nbsp;Now you have to update the default Parabola keyring. This is used for signing and verifying packages:<br/>
  240. &nbsp;&nbsp;&nbsp;# <b>pacman -Sy parabola-keyring</b><br/>
  241. &nbsp;&nbsp;&nbsp;It says that if you get GPG errors, then it's probably an expired key and, therefore, you should do:<br/>
  242. &nbsp;&nbsp;&nbsp;# <b>pacman-key --populate parabola</b><br/>
  243. &nbsp;&nbsp;&nbsp;# <b>pacman-key --refresh-keys</b><br/>
  244. &nbsp;&nbsp;&nbsp;# <b>pacman -Sy parabola-keyring</b><br/>
  245. &nbsp;&nbsp;&nbsp;To be honest, you should do the above anyway. Parabola has a lot of maintainers, and a lot of keys. Really!<br/>
  246. &nbsp;&nbsp;&nbsp;If you get an error mentioning dirmngr, do:<br/>
  247. &nbsp;&nbsp;&nbsp;# <b>dirmngr &lt;/dev/null</b><br/>
  248. &nbsp;&nbsp;&nbsp;Also, it says that if the clock is set incorrectly then you have to manually set the correct time <br/>
  249. &nbsp;&nbsp;&nbsp;(if keys are listed as expired because of it):<br/>
  250. &nbsp;&nbsp;&nbsp;# <b>date MMDDhhmm[[CC]YY][.ss]</b><br/>
  251. &nbsp;&nbsp;&nbsp;I also had to install:<br/>
  252. &nbsp;&nbsp;&nbsp;# <b>pacman -S archlinux-keyring</b><br/>
  253. &nbsp;&nbsp;&nbsp;# <b>pacman-key --populate archlinux</b><br/>
  254. &nbsp;&nbsp;&nbsp;In my case I saw some conflicting files reported in pacman, stopping me from using it.<br/>
  255. &nbsp;&nbsp;&nbsp;I deleted the files that it mentioned
  256. and then it worked. Specifically, I had this error:<br/>
  257. &nbsp;&nbsp;&nbsp;<i>licenses: /usr/share/licenses/common/MPS exists in filesystem</i><br/>
  258. &nbsp;&nbsp;&nbsp;I rm -Rf'd the file and then pacman worked. I'm told that the following would have also made it work:<br/>
  259. &nbsp;&nbsp;&nbsp;# <b>pacman -Sf licenses</b><br/>
  260. &lt;/troubleshooting&gt;<br/>
  261. </p>
  262. <p>
  263. 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:<br/>
  264. # <b>pacstrap /mnt base base-devel wpa_supplicant dialog iw wpa_actiond</b>
  265. </p>
  266. </div>
  267. <div class="section">
  268. <h2>Configure the system</h2>
  269. <p>
  270. Generate an fstab - UUIDs are used because they have certain advantages (see <a href="https://wiki.parabola.nu/Fstab#Identifying_filesystems">https://wiki.parabola.nu/Fstab#Identifying_filesystems</a>.
  271. If you prefer labels instead, replace the -U option with -L):<br/>
  272. # <b>genfstab -U -p /mnt &gt;&gt; /mnt/etc/fstab</b><br/>
  273. Check the created file:<br/>
  274. # <b>cat /mnt/etc/fstab</b><br/>
  275. (If there are any errors, edit the file. Do <b>NOT</b> run the genfstab command again!)
  276. </p>
  277. <p>
  278. Chroot into new system:<br/>
  279. # <b>arch-chroot /mnt /bin/bash</b>
  280. </p>
  281. <p>
  282. It's a good idea to have this installed:<br/>
  283. # <b>pacman -S linux-libre-lts</b>
  284. </p>
  285. <p>
  286. It was also suggested that you should install this kernel (read up on what GRSEC is):<br/>
  287. # <b>pacman -S linux-libre-grsec</b>
  288. </p>
  289. <p>
  290. This is another kernel that sits inside /boot, which you can use. LTS means 'long-term support'. These are so-called 'stable' kernels
  291. that can be used as a fallback during updates, if a bad kernel causes issues for you.
  292. </p>
  293. <p>
  294. Parabola does not have wget. This is sinister. Install it:<br/>
  295. # <b>pacman -S wget</b>
  296. </p>
  297. <p>
  298. Locale:<br/>
  299. # <b>nano /etc/locale.gen</b><br/>
  300. Uncomment your needed localisations. For example en_GB.UTF-8 (UTF-8 is highly recommended over other options).<br/>
  301. # <b>locale-gen</b><br/>
  302. # <b>echo LANG=en_GB.UTF-8 &gt; /etc/locale.conf</b><br/>
  303. # <b>export LANG=en_GB.UTF-8</b>
  304. </p>
  305. <p>
  306. Console font and keymap:<br/>
  307. # <b>nano /etc/vconsole.conf</b><br/>
  308. In my case:
  309. </p>
  310. <pre>
  311. KEYMAP=dvorak-uk
  312. FONT=Lat9w-16
  313. </pre>
  314. <p>
  315. Time zone:<br/>
  316. # <b>ln -s /usr/share/zoneinfo/Europe/London /etc/localtime</b><br/>
  317. (Replace Zone and Subzone to your liking. See /usr/share/zoneinfo)
  318. </p>
  319. <p>
  320. Hardware clock:<br/>
  321. # <b>hwclock --systohc --utc</b>
  322. </p>
  323. <p>
  324. Hostname:
  325. Write your hostname to /etc/hostname. For example, if your hostname is parabola:<br/>
  326. # <b>echo parabola &gt; /etc/hostname</b><br/>
  327. Add the same hostname to /etc/hosts:<br/>
  328. # <b>nano /etc/hosts</b><br/>
  329. </p>
  330. <pre>
  331. #&lt;ip-address&gt; &lt;hostname.domain.org&gt; &lt;hostname&gt;
  332. 127.0.0.1 localhost.localdomain localhost parabola
  333. ::1 localhost.localdomain localhost parabola
  334. </pre>
  335. <p> Configure the network:
  336. Refer to <a href="https://wiki.parabola.nu/Beginners%27_guide#Configure_the_network">https://wiki.parabola.nu/Beginners%27_guide#Configure_the_network</a>.
  337. </p>
  338. <p> Mkinitcpio:
  339. Configure /etc/mkinitcpio.conf as needed (see <a href="https://wiki.parabola.nu/Mkinitcpio">https://wiki.parabola.nu/Mkinitcpio</a>).
  340. Runtime modules can be found in /usr/lib/initcpio/hooks, and build hooks can be found in /usr/lib/initcpio/install. (# <b>mkinitcpio -H hookname</b> gives information about each hook.)
  341. Specifically, for this use case:<br/>
  342. # <b>nano /etc/mkinitcpio.conf</b><br/>
  343. Then modify the file like so:
  344. </p>
  345. <ul>
  346. <li>MODULES="i915"</li>
  347. <li>This forces the driver to load earlier, so that the console font isn't wiped out after getting to login)</li>
  348. <li>HOOKS="base udev autodetect modconf block keyboard keymap consolefont encrypt lvm2 filesystems fsck shutdown"</li>
  349. <li>Explanation:</li>
  350. <li>keymap adds to initramfs the keymap that you specified in /etc/vconsole.conf</li>
  351. <li>consolefont adds to initramfs the font that you specified in /etc/vconsole.conf</li>
  352. <li>encrypt adds LUKS support to the initramfs - needed to unlock your disks at boot time</li>
  353. <li>lvm2 adds LVM support to the initramfs - needed to mount the LVM partitions at boot time</li>
  354. <li>shutdown is needed according to Parabola wiki for unmounting devices (such as LUKS/LVM) during shutdown)</li>
  355. </ul>
  356. <p>
  357. Now using mkinitcpio, you can create the kernel and ramdisk for booting with (this is different from Arch, specifying linux-libre instead of linux):<br/>
  358. # <b>mkinitcpio -p linux-libre</b><br/>
  359. Also do it for linux-libre-lts:<br/>
  360. # <b>mkinitcpio -p linux-libre-lts</b><br/>
  361. Also do it for linux-libre-grsec:<br/>
  362. # <b>mkinitcpio -p linux-libre-grsec</b>
  363. </p>
  364. <p>
  365. Set the root password:
  366. At the time of writing, Parabola used SHA512 by default for its password hashing. I referred to <a href="https://wiki.archlinux.org/index.php/SHA_password_hashes">https://wiki.archlinux.org/index.php/SHA_password_hashes</a>.<br/>
  367. # <b>nano /etc/pam.d/passwd</b><br/>
  368. Add rounds=65536 at the end of the uncommented 'password' line.<br/>
  369. # <b>passwd root</b><br/>
  370. Make sure to set a secure password! Also, it must never be the same as your LUKS password.
  371. </p>
  372. </div>
  373. <div class="section">
  374. <h2>Extra security tweaks</h2>
  375. <p>
  376. Based on <a href="https://wiki.archlinux.org/index.php/Security">https://wiki.archlinux.org/index.php/Security</a>.
  377. </p>
  378. <p>
  379. Restrict access to important directories:<br/>
  380. # <b>chmod 700 /boot /etc/{iptables,arptables}</b>
  381. </p>
  382. <p>
  383. Lockout user after three failed login attempts:<br/>
  384. Edit the file /etc/pam.d/system-login and comment out that line:<br/>
  385. <i># auth required pam_tally.so onerr=succeed file=/var/log/faillog</i><br/>
  386. Or just delete it. Above it, put:<br/>
  387. <i>auth required pam_tally.so deny=2 unlock_time=600 onerr=succeed file=/var/log/faillog</i><br/>
  388. To unlock a user manually (if a password attempt is failed 3 times), do:<br/>
  389. # <b>pam_tally --user <i>theusername</i> --reset</b>
  390. What the above configuration does is lock the user out for 10 minutes, if they make 3 failed login attempts.
  391. </p>
  392. <p>
  393. Configure sudo - not covered here. Will be covered post-installation in another tutorial, at a later date.
  394. If this is a single-user system, you don't really need sudo.
  395. </p>
  396. </div>
  397. <div class="section">
  398. <h2>Unmount, reboot!</h2>
  399. <p>
  400. Exit from chroot:<br/>
  401. # <b>exit</b>
  402. </p>
  403. <p>
  404. unmount:<br/>
  405. # <b>umount -R /mnt</b><br/>
  406. # <b>swapoff -a</b>
  407. </p>
  408. <p>
  409. deactivate the lvm lv's:<br/>
  410. # <b>lvchange -an /dev/matrix/rootvol</b><br/>
  411. # <b>lvchange -an /dev/matrix/swapvol</b><br/>
  412. </p>
  413. <p>
  414. Lock the encrypted partition (close it):<br/>
  415. # <b>cryptsetup luksClose lvm</b>
  416. </p>
  417. <p>
  418. # <b>shutdown -h now</b><br/>
  419. Remove the installation media, then boot up again.
  420. </p>
  421. </div>
  422. <div class="section">
  423. <h2>Booting from GRUB</h2>
  424. <p>
  425. Initially you will have to boot manually. Press C to get to the GRUB command line. The underlined parts are optional
  426. (using those 2 underlines will boot lts kernel instead of normal).
  427. </p>
  428. <p>
  429. grub> <b>cryptomount -a</b><br/>
  430. grub> <b>set root='lvm/matrix-rootvol'</b><br/>
  431. grub> <b>linux /boot/vmlinuz-linux-libre<u>-lts</u> root=/dev/matrix/rootvol cryptdevice=/dev/sda1:root</b><br/>
  432. grub> <b>initrd /boot/initramfs-linux-libre<u>-lts</u>.img</b><br/>
  433. grub> <b>boot</b><br/>
  434. </p>
  435. <p>
  436. You could also make it load /boot/vmlinuz-linux-libre-grsec and /boot/initramfs-linux-libre-grsec.img
  437. </p>
  438. </div>
  439. <div class="section">
  440. <h2>Follow-up tutorial: configuring Parabola</h2>
  441. <p>
  442. We will modify grub.config inside the ROM and do all kinds of fun stuff, but I recommend that you first transform the current bare-bones Parabola install into a more useable system.
  443. Doing so will make the upcoming ROM modifications MUCH easier to perform and less risky!
  444. <a href="configuring_parabola.html">configuring_parabola.html</a> shows my own notes post-installation. Using these, you can get a basic
  445. system similar to the one that I chose for myself. You can also cherry pick useful notes and come up with your own system.
  446. Parabola is user-centric, which means that you are in control. For more information, read <a href="https://wiki.archlinux.org/index.php/The_Arch_Way">The Arch Way</a>
  447. (Parabola also follows it).
  448. </p>
  449. </div>
  450. <div class="section">
  451. <h2>Modify grub.cfg inside the ROM</h2>
  452. <p>
  453. (Re-)log in to your system, pressing C, so booting manually from GRUB (see above). You need to modify the ROM, so that Parabola can boot automatically with this configuration.
  454. <a href="grub_cbfs.html">grub_cbfs.html</a> shows you how. Follow that guide, using the configuration details below.
  455. If you go for option 2 (re-flash), promise to do this on grubtest.cfg first! We can't emphasise this enough. This is to reduce the possibility of bricking your device!
  456. </p>
  457. <p>
  458. I will go for the re-flash option here. Firstly, cd to the libreboot_util/cbfstool/{armv7l i686 x86_64} directory.
  459. Dump the current firmware - where <i>libreboot.rom</i> is an example: make sure to adapt:<br/>
  460. # <b>flashrom -p internal -r libreboot.rom</b><br/>
  461. If flashrom complains about multiple flash chips detected, add a <i>-c</i> option at the end, with the name of your chosen chip is quotes.<br/>
  462. You can check if everything is in there (<i>grub.cfg</i> and <i>grubtest.cfg</i> would be really nice):<br/>
  463. $ <b>./cbfstool libreboot.rom print</b><br/>
  464. Extract grubtest.cfg:<br/>
  465. $ <b>./cbfstool libreboot.rom extract -n grubtest.cfg -f grubtest.cfg</b><br/>
  466. And modify:<br/>
  467. $ <b>nano grubtest.cfg</b>
  468. </p>
  469. <p>
  470. In grubtest.cfg, inside the 'Load Operating System' menu entry, change the contents to:
  471. </p>
  472. <pre>
  473. cryptomount -a<br/>
  474. set root='lvm/matrix-rootvol'<br/>
  475. linux /boot/vmlinuz-linux-libre<u>-lts</u> root=/dev/matrix/rootvol cryptdevice=/dev/sda1:root<br/>
  476. initrd /boot/initramfs-linux-libre<u>-lts</u>.img
  477. </pre>
  478. <p>
  479. Note: the underlined parts above (-lts) can also be removed, to boot the latest kernel instead of LTS (long-term support) kernels.
  480. You could also copy the menu entry and in one have -lts, and without in the other menuentry.
  481. You could also create a menu entry to load /boot/vmlinuz-linux-libre-grsec and /boot/initramfs-linux-libre-grsec.img
  482. The first entry will load by default.
  483. </p>
  484. <p>
  485. Without specifying a device, the <i>-a</i> parameter tries to unlock all detected LUKS volumes.
  486. You can also specify -u UUID or -a (device).
  487. </p>
  488. <p>
  489. Now, to protect your system from an attacker simply booting a live usb distro and re-flashing the boot firmware, we are going to add a password for GRUB.
  490. In a new terminal window, if you are not yet online, start dhcp on ethernet:<br/>
  491. # <b>systemctl start dhcpcd.service</b>
  492. Or make sure to get connected to the internet in any other way you prefer, at least.
  493. </p>
  494. <p style="font-size:2em;">
  495. AGAIN: MAKE SURE TO DO THIS WHOLE SECTION ON grubtest.cfg *BEFORE* DOING IT ON grub.cfg.
  496. (When we get there, upon reboot, select the menu entry that says <i>Switch to grubtest.cfg</i> and test that it works.
  497. Only once you are satisfied, copy that to grub.cfg. Only a few steps to go, though.)
  498. WHY? BECAUSE AN INCORRECTLY SET PASSWORD CONFIG MEANS YOU CAN'T AUTHENTICATE, WHICH MEANS 'BRICK'.
  499. </p>
  500. <p>
  501. (emphasis added, because it's needed: this is a common roadblock for users.)
  502. </p>
  503. <p>
  504. We need a utility that comes with GRUB, so we will download it temporarily. (Remember that GRUB isn't needed for booting, since it's already included as a payload in libreboot.)
  505. Also, we will use flashrom, and I installed dmidecode. You only need base-devel (compilers and so on) to build and use cbfstool. It was already installed if you followed this tutorial, but here
  506. it is:<br/>
  507. # <b>pacman -S grub flashrom dmidecode base-devel</b><br/>
  508. Next, do:<br/>
  509. # <b>grub-mkpasswd-pbkdf2</b><br/>
  510. Enter your chosen password at the prompt and your hash will be shown. Copy this string - you will add it to your grubtest.cfg.
  511. </p>
  512. <p>
  513. The password below (it's <b>password</b>, by the way) after <i>'password_pbkdf2 root'</i> <i>should be changed</i> to your own.
  514. Make sure to specify a password that is different from both your LUKS *and* your root/user password.
  515. Obviously, do not simply copy and paste the examples shown here...
  516. </p>
  517. <p>
  518. Next, back in grubtest.cfg, above the first 'Load Operating System' menu entry, you should now add your GRUB password, like so
  519. (replace with your own name (I used <b>root</b> on both lines, feel free to choose another one) and the password hash which you copied):
  520. </p>
  521. <pre>
  522. set superusers=&quot;root&quot;
  523. password_pbkdf2 root grub.pbkdf2.sha512.10000.711F186347156BC105CD83A2ED7AF1EB971AA2B1EB2640172F34B0DEFFC97E654AF48E5F0C3B7622502B76458DA494270CC0EA6504411D676E6752FD1651E749.8DD11178EB8D1F633308FD8FCC64D0B243F949B9B99CCEADE2ECA11657A757D22025986B0FA116F1D5191E0A22677674C994EDBFADE62240E9D161688266A711
  524. </pre>
  525. <p>
  526. Save your changes in grubtest.cfg, then delete the unmodified config from the ROM image:<br/>
  527. $ <b>./cbfstool libreboot.rom remove -n grubtest.cfg</b><br/>
  528. and insert the modified grubtest.cfg:<br/>
  529. $ <b>./cbfstool libreboot.rom add -n grubtest.cfg -f grubtest.cfg -t raw</b><br/>
  530. </p>
  531. <p>
  532. Now refer to <a href="http://libreboot.org/docs/install/index.html#flashrom">http://libreboot.org/docs/install/index.html#flashrom</a>.
  533. Cd (up) to the libreboot_util directory and update the flash chip contents:<br/>
  534. # <b>./flash update libreboot.rom</b><br/>
  535. 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:<br/>
  536. # <b>./flash forceupdate libreboot.rom</b><br/>
  537. You should see "Verifying flash... VERIFIED." written at the end of the flashrom output.
  538. </p>
  539. <p>
  540. With this new configuration, Parabola can boot automatically and you will have to enter a password at boot time, in GRUB, before being able to use any of the menu entries or switch to the terminal.
  541. Let's test it out: reboot and choose grubtest.cfg from the GRUB menu, using the arrow keys on your keyboard.
  542. Enter the name you chose, the GRUB password, your LUKS passphrase and login as root/your user. All went well? Great!
  543. </p>
  544. <p>
  545. If it does not work like you want it to, if you are unsure or sceptical in any way, don't despair: you have been wise and did not brick your device! Reboot and login the default way, and then modify
  546. your grubtest.cfg until you get it right!
  547. <b>Do *not* proceed past this point unless you are 100% sure that your new configuration is safe (or desirable) to use.</b>
  548. </p>
  549. <p>
  550. Now, we can easily and safely create a copy of grubtest.cfg, called grub.cfg. This will be the same except for one difference: the menuentry 'Switch to grub.cfg' is changed to 'Switch to grubtest.cfg'
  551. and, inside it, all instances of grub.cfg to grubtest.cfg. This is so that 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
  552. want to follow this guide again in the future (modifying the already modified config).
  553. Inside libreboot_util/cbfstool/{armv7l i686 x86_64}, we can do this with the following command:<br/>
  554. $ <b>sed -e 's:(cbfsdisk)/grub.cfg:(cbfsdisk)/grubtest.cfg:g' -e 's:Switch to grub.cfg:Switch to grubtest.cfg:g' &lt; grubtest.cfg &gt; grub.cfg</b><br/>
  555. Delete the grub.cfg that remained inside the ROM:<br/>
  556. $ <b>./cbfstool libreboot.rom remove -n grub.cfg</b><br/>
  557. Add the modified version that you just made:<br/>
  558. $ <b>./cbfstool libreboot.rom add -n grub.cfg -f grub.cfg -t raw</b><br/>
  559. </p>
  560. <p>
  561. Now you have a modified ROM. Once more, refer to <a href="http://libreboot.org/docs/install/index.html#flashrom">http://libreboot.org/docs/install/index.html#flashrom</a>.
  562. Cd to the libreboot_util directory and update the flash chip contents:<br/>
  563. # <b>./flash update libreboot.rom</b><br/>
  564. And wait for the "Verifying flash... VERIFIED." Once you have done that, shut down and then boot up with your new configuration.
  565. </p>
  566. <p>
  567. When done, delete GRUB (remember, we only needed it for the <i>grub-mkpasswd-pbkdf2</i> utility;
  568. GRUB is already part of libreboot, flashed alongside it as a <i>payload</i>):<br/>
  569. # <b>pacman -R grub</b>
  570. </p>
  571. </div>
  572. <div class="section">
  573. <p>
  574. If you followed all that correctly, you should now have a fully encrypted Parabola installation.
  575. Refer to the wiki for how to do the rest.
  576. </p>
  577. </div>
  578. <div class="section">
  579. <h2>Bonus: Using a key file to unlock /boot/</h2>
  580. <p>
  581. By default, you will have to enter your LUKS passphrase twice; once in GRUB, and once when booting the kernel.
  582. GRUB unlocks the encrypted partition and then loads the kernel, but the kernel is not aware of the fact
  583. that it is being loaded from an encrypted volume. Therefore, you will be asked to enter your passphrase a second time.
  584. A workaround is to put a keyfile inside initramfs, with instructions for the kernel to use it when
  585. booting. This is safe, because /boot/ is encrypted (otherwise, putting a keyfile inside initramfs would be a bad idea).<br/>
  586. Boot up and login as root or your user. Then generate the key file:<br/>
  587. # <b>dd bs=512 count=4 if=/dev/urandom of=/etc/mykeyfile iflag=fullblock</b><br/>
  588. Insert it into the luks volume:<br/>
  589. # <b>cryptsetup luksAddKey /dev/sdX /etc/mykeyfile</b><br/>
  590. and enter your LUKS passphrase when prompted.
  591. Add the keyfile to the initramfs by adding it to FILES in /etc/mkinitcpio.conf. For example:<br/>
  592. # <b>FILES="/etc/mykeyfile"</b><br/>
  593. Create the initramfs image from scratch:<br/>
  594. # <b>mkinitcpio -p linux-libre</b><br/>
  595. # <b>mkinitcpio -p linux-libre-lts</b><br/>
  596. # <b>mkinitcpio -p linux-libre-grsec</b><br/>
  597. 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:<br/>
  598. # <b>cryptkey=rootfs:/etc/mykeyfile</b><br/>
  599. <br/>
  600. You can also place this inside the grub.cfg that exists in CBFS: <a href="grub_cbfs.html">grub_cbfs.html</a>.
  601. </p>
  602. </div>
  603. <div class="section">
  604. <h2>Further security tips</h2>
  605. <p>
  606. <a href="https://wiki.archlinux.org/index.php/Security">https://wiki.archlinux.org/index.php/Security</a>.<br/>
  607. <a href="https://wiki.parabolagnulinux.org/User:GNUtoo/laptop">https://wiki.parabolagnulinux.org/User:GNUtoo/laptop</a>
  608. </p>
  609. </div>
  610. <div class="section">
  611. <h1 id="troubleshooting">Troubleshooting</h1>
  612. <p>
  613. A user reported issues when booting with a docking station attached
  614. on an X200, when decrypting the disk in GRUB. The error
  615. <i>AHCI transfer timed out</i> was observed. The workaround
  616. was to remove the docking station.
  617. </p>
  618. <p>
  619. Further investigation revealed that it was the DVD drive causing problems.
  620. Removing that worked around the issue.
  621. </p>
  622. <pre>
  623. &quot;sudo wodim -prcap&quot; shows information about the drive:
  624. Device was not specified. Trying to find an appropriate drive...
  625. Detected CD-R drive: /dev/sr0
  626. Using /dev/cdrom of unknown capabilities
  627. Device type : Removable CD-ROM
  628. Version : 5
  629. Response Format: 2
  630. Capabilities :
  631. Vendor_info : 'HL-DT-ST'
  632. Identification : 'DVDRAM GU10N '
  633. Revision : 'MX05'
  634. Device seems to be: Generic mmc2 DVD-R/DVD-RW.
  635. Drive capabilities, per MMC-3 page 2A:
  636. Does read CD-R media
  637. Does write CD-R media
  638. Does read CD-RW media
  639. Does write CD-RW media
  640. Does read DVD-ROM media
  641. Does read DVD-R media
  642. Does write DVD-R media
  643. Does read DVD-RAM media
  644. Does write DVD-RAM media
  645. Does support test writing
  646. Does read Mode 2 Form 1 blocks
  647. Does read Mode 2 Form 2 blocks
  648. Does read digital audio blocks
  649. Does restart non-streamed digital audio reads accurately
  650. Does support Buffer-Underrun-Free recording
  651. Does read multi-session CDs
  652. Does read fixed-packet CD media using Method 2
  653. Does not read CD bar code
  654. Does not read R-W subcode information
  655. Does read raw P-W subcode data from lead in
  656. Does return CD media catalog number
  657. Does return CD ISRC information
  658. Does support C2 error pointers
  659. Does not deliver composite A/V data
  660. Does play audio CDs
  661. Number of volume control levels: 256
  662. Does support individual volume control setting for each channel
  663. Does support independent mute setting for each channel
  664. Does not support digital output on port 1
  665. Does not support digital output on port 2
  666. Loading mechanism type: tray
  667. Does support ejection of CD via START/STOP command
  668. Does not lock media on power up via prevent jumper
  669. Does allow media to be locked in the drive via PREVENT/ALLOW command
  670. Is not currently in a media-locked state
  671. Does not support changing side of disk
  672. Does not have load-empty-slot-in-changer feature
  673. Does not support Individual Disk Present feature
  674. Maximum read speed: 4234 kB/s (CD 24x, DVD 3x)
  675. Current read speed: 4234 kB/s (CD 24x, DVD 3x)
  676. Maximum write speed: 4234 kB/s (CD 24x, DVD 3x)
  677. Current write speed: 4234 kB/s (CD 24x, DVD 3x)
  678. Rotational control selected: CLV/PCAV
  679. Buffer size in KB: 1024
  680. Copy management revision supported: 1
  681. Number of supported write speeds: 4
  682. Write speed # 0: 4234 kB/s CLV/PCAV (CD 24x, DVD 3x)
  683. Write speed # 1: 2822 kB/s CLV/PCAV (CD 16x, DVD 2x)
  684. Write speed # 2: 1764 kB/s CLV/PCAV (CD 10x, DVD 1x)
  685. Write speed # 3: 706 kB/s CLV/PCAV (CD 4x, DVD 0x)
  686. Supported CD-RW media types according to MMC-4 feature 0x37:
  687. Does write multi speed CD-RW media
  688. Does write high speed CD-RW media
  689. Does write ultra high speed CD-RW media
  690. Does not write ultra high speed+ CD-RW media
  691. </pre>
  692. </div>
  693. <div class="section">
  694. <p>
  695. Copyright &copy; 2014, 2015 Francis Rowe &lt;info@gluglug.org.uk&gt;<br/>
  696. Copyright &copy; 2015 Jeroen Quint &lt;jezza@diplomail.ch&gt;<br/>
  697. Permission is granted to copy, distribute and/or modify this document
  698. under the terms of the GNU Free Documentation License, Version 1.3
  699. or any later version published by the Free Software Foundation;
  700. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
  701. A copy of the license can be found at <a href="../gfdl-1.3.txt">../gfdl-1.3.txt</a>
  702. </p>
  703. <p>
  704. Updated versions of the license (when available) can be found at
  705. <a href="https://www.gnu.org/licenses/licenses.html">https://www.gnu.org/licenses/licenses.html</a>
  706. </p>
  707. <p>
  708. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
  709. EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
  710. AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
  711. ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
  712. IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
  713. WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
  714. PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
  715. ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
  716. KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
  717. ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
  718. </p>
  719. <p>
  720. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
  721. TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
  722. NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
  723. INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
  724. COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
  725. USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
  726. ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
  727. DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
  728. IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
  729. </p>
  730. <p>
  731. The disclaimer of warranties and limitation of liability provided
  732. above shall be interpreted in a manner that, to the extent
  733. possible, most closely approximates an absolute disclaimer and
  734. waiver of all liability.
  735. </p>
  736. </div>
  737. </body>
  738. </html>