encrypted_parabola.html 39 KB

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