guix.info 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. 1 Guix System and Libreboot
  2. ***************************
  3. Guix System is an exotic distribution of GNU+Linux operating system,
  4. with Guix as package+system manager, Linux-Libre as kernel and Shepherd
  5. as init system.
  6. Libreboot is a de-blobbed distribution of Coreboot firmware. By
  7. default, Libreboot comes with GRUB bootloader as a payload.
  8. The objective of this manual is to provide step-by-step guide for
  9. setting up Guix System (stand-alone Guix), with Full Disk Encryption
  10. (FDE), on devices powered by Libreboot.
  11. Any users, for their generalized use cases, need not stumble away
  12. from this guide to accomplish the setup. Advancers, for deviant use
  13. cases, will have to explore outside this guide for customization;
  14. although this guide provides information that is of paramount use.
  15. Let us begin!
  16. * Menu:
  17. * Preparation::
  18. * Installation::
  19. * Completion::
  20. * Conclusion::
  21. * References::
  22. * Acknowledgements::
  23. * License::
  24. 
  25. File: guix.info, Node: Preparation, Next: Installation, Up: Guix System and Libreboot
  26. 1.1 Preparation
  27. ===============
  28. In the current GNU+Linux system, open terminal as root user.
  29. Insert USB drive and get the device letter ‘/dev/sdX’, where “X” is
  30. the device letter.
  31. lsblk --list
  32. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  33. sda 8:0 0 223.6G 0 disk
  34. sda1 8:1 0 2M 0 part
  35. sda2 8:2 0 3.7G 0 part
  36. sda3 8:3 0 219.9G 0 part /
  37. zram0 251:0 0 512M 0 disk [SWAP]
  38. Unmount the device just in case if it is auto-mounted.
  39. umount /dev/sdX --verbose
  40. Download the Guix System ISO installer package and it’s GPG
  41. signature; where “a.b.c” is the version number and “sss” is the system
  42. architecture.
  43. wget --verbose https://ftp.gnu.org/gnu/guix/guix-system-install-a.b.c.sss-linux.iso.xz
  44. wget --verbose https://ftp.gnu.org/gnu/guix/guix-system-install-a.b.c.sss-linux.iso.xz.sig
  45. Import the Guix’s public key.
  46. gpg --verbose --keyserver pool.sks-keyservers.net –-receive-keys 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
  47. Verify the GPG signature of the downloaded package.
  48. gpg --verbose --verify guix-system-install-a.b.c.sss-linux.iso.xz.sig
  49. Extract ISO image from the downloaded package.
  50. xz --verbose --decompress guix-system-install-a.b.c.sss-linux.iso.xz
  51. Write the extracted ISO image to the drive.
  52. dd if=guix-system-install-a.b.c.sss-linux.iso of=/dev/sdX status=progress; sync
  53. Reboot the device.
  54. reboot
  55. 
  56. File: guix.info, Node: Installation, Next: Completion, Prev: Preparation, Up: Guix System and Libreboot
  57. 1.2 Installation
  58. ================
  59. On reboot, as soon as the Libreboot’s graphic art appears, press "S" or
  60. choose ‘Search for GRUB2 configuration on external media [s]’. Wait for
  61. the Guix System from USB drive to load.
  62. Once Guix System installer starts, choose "Install using the shell
  63. based process".
  64. Set your keyboard layout, where “lo” is the two-letter keyboard
  65. layout code (lower-case).
  66. loadkeys --verbose lo
  67. Unblock network interfaces.
  68. rfkill unblock all
  69. Get the names of network interfaces.
  70. ifconfig -v -a
  71. enp0s25 Link encap:Ethernet HWaddr 00:1C:25:9A:37:BA
  72. UP BROADCAST MULTICAST MTU:1500 Metric:1
  73. RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  74. TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  75. collisions:0 txqueuelen:1000
  76. RX bytes:0 TX bytes:0
  77. Interrupt:16 Memory:98800000-98820000
  78. lo Link encap:Local Loopback
  79. inet addr:127.0.0.1 Bcast:0.0.0.0 Mask:255.0.0.0
  80. UP LOOPBACK RUNNING MTU:65536 Metric:1
  81. RX packets:265 errors:0 dropped:0 overruns:0 frame:0
  82. TX packets:265 errors:0 dropped:0 overruns:0 carrier:0
  83. collisions:0 txqueuelen:1000
  84. RX bytes:164568 TX bytes:164568
  85. wlp2s0 Link encap:Ethernet HWaddr E4:CE:8F:59:D6:BF
  86. inet addr:192.168.1.133 Bcast:192.168.1.255 Mask:255.255.255.0
  87. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  88. RX packets:58799 errors:0 dropped:71 overruns:0 frame:0
  89. TX packets:32519 errors:0 dropped:0 overruns:0 carrier:0
  90. collisions:0 txqueuelen:1000
  91. RX bytes:44632193 TX bytes:4816175
  92. Bring the desired network interface (wired or wireless) up, where
  93. “nwif” is the network interface name.
  94. ifconfig -v nwif up
  95. For wireless connection, follow the wireless setup.
  96. * Menu:
  97. * Wireless Setup::
  98. 
  99. File: guix.info, Node: Wireless Setup, Up: Installation
  100. 1.2.1 Wireless Setup
  101. --------------------
  102. Create a configuration file using text editor, where “fname” is any
  103. desired name for file.
  104. nano fname.conf
  105. Choose, type and save ONE of the following snippets, where ‘net’ is
  106. the network name, ‘pass’ is the password or passphrase and ‘uid’ is the
  107. user identity.
  108. For most private networks:
  109. network={
  110. ssid="net"
  111. key_mgmt=WPA-PSK
  112. psk="pass"
  113. }
  114. (or)
  115. For most public networks:
  116. network={
  117. ssid="net"
  118. key_mgmt=NONE
  119. }
  120. (or)
  121. For most organizational networks:
  122. network={
  123. ssid="net"
  124. scan_ssid=1
  125. key_mgmt=WPA-EAP
  126. identity="uid"
  127. password="pass"
  128. eap=PEAP
  129. phase1="peaplabel=0"
  130. phase2="auth=MSCHAPV2"
  131. }
  132. Connect to the configured network.
  133. wpa_supplicant -B -c fname.conf -i nwif
  134. Assign an IP address to the network interface.
  135. dhclient -v nwif
  136. Obtain the device letter ‘/dev/sdX’ in which you would like to deploy
  137. and install Guix System, where “X” is the device letter.
  138. lsblk --list
  139. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  140. sda 8:0 0 223.6G 0 disk
  141. sda1 8:1 0 2M 0 part
  142. sda2 8:2 0 3.7G 0 part
  143. sda3 8:3 0 219.9G 0 part /
  144. zram0 251:0 0 512M 0 disk [SWAP]
  145. Wipe the device (Ignore if the device is new).
  146. shred --verbose --random-source=/dev/urandom /dev/sdX
  147. Load the device-mapper module in the current kernel.
  148. modprobe --verbose dm_mod
  149. Partition the device. Follow the prompts. Just do, GPT –> New –>
  150. Write –> Quit; defaults will be set.
  151. cfdisk /dev/sdX
  152. #+END_SRC>
  153. Obtain the partition number from the device, where “Y” is the
  154. partition number.
  155. #+BEGIN_SRC sh :results output :exports both
  156. lsblk --list
  157. #+END_SRC>
  158. Encrypt the partition. Follow the prompts.
  159. #+BEGIN_SRC sh :results output :exports both
  160. cryptsetup --verbose --hash whirlpool --cipher serpent-xts-plain64 --verify-passphrase --use-random --key-size 512 --iter-time 500 luksFormat /dev/sdXY
  161. #+END_SRC>
  162. Obtain and note down the UUID of the LUKS partition.
  163. #+BEGIN_SRC sh :results output :exports both
  164. cryptsetup --verbose luksUUID /dev/sdXY
  165. #+END_SRC>
  166. Open the encrypted partition, where "luks-uuid" is the LUKS UUID and
  167. “partname” is any desired name for partition. cryptsetup --verbose
  168. #+BEGIN_SRC sh :results output :exports both
  169. luksOpen UUID=luks-uuid partname
  170. #+END_SRC>
  171. Create a physical volume in the partition.
  172. #+BEGIN_SRC sh :results output :exports both
  173. pvcreate /dev/mapper/partname --verbose
  174. #+END_SRC>
  175. Create a volume group in the physical volume, where "vgname" is any desired name for volume group.
  176. #+BEGIN_SRC sh :results output :exports both
  177. vgcreate vgname /dev/mapper/partname --verbose
  178. #+END_SRC>
  179. Create logical volumes in the volume group; where "num" is the number
  180. for space in GB, and "lvnameroot" and "lvnamehome" are any desired
  181. names for root and home volumes respectively.
  182. #+BEGIN_SRC sh :results output :exports both
  183. lvcreate --extents 25%VG vgname --name lvnameroot --verbose
  184. lvcreate --extents 100%FREE vgname --name lvnamehome --verbose
  185. #+END_SRC>
  186. Create filesystems on the logical-volumes, where "fsnameroot" and
  187. "fsnamehome" are any desired names for root and home filesystems
  188. respectively.
  189. #+BEGIN_SRC sh :results output :exports both
  190. mkfs.btrfs --metadata dup --label fsnameroot /dev/vgname/lvnameroot
  191. mkfs.btrfs --metadata dup --label fsnamehome /dev/vgname/lvnamehome
  192. #+END_SRC>
  193. Mount the filesystems under the current system.
  194. #+BEGIN_SRC sh :results output :exports both
  195. mount --label fsnameroot --target /mnt --types btrfs --verbose
  196. mkdir --verbose /mnt/home && mount --label fsnamehome --target /mnt/home --types btrfs --verbose
  197. #+END_SRC>
  198. Create a swap file.
  199. #+BEGIN_SRC sh :results output :exports both
  200. dd bs=1MiB count=1GiB if=/dev/zero of=/mnt/swapfile status=progress
  201. mkswap --verbose /mnt/swapfile
  202. #+END_SRC>
  203. Make the swap file readable and writable only by root account.
  204. #+BEGIN_SRC sh :results output :exports both
  205. chmod --verbose 600 /mnt/swapfile
  206. #+END_SRC>
  207. Activate the swap file.
  208. #+BEGIN_SRC sh :results output :exports both
  209. swapon --verbose /mnt/swapfile
  210. #+END_SRC>
  211. Make the installation packages to be written on the mounted root
  212. filesystem.
  213. #+BEGIN_SRC sh :results output :exports both
  214. herd start cow-store /mnt
  215. #+END_SRC>
  216. Create the system-wide configuration files directory.
  217. #+BEGIN_SRC sh :results output :exports both
  218. mkdir --verbose /mnt/etc
  219. #+END_SRC>
  220. Create, edit and save the system configuration file by typing the
  221. following code snippet. WATCH-OUT for variables in the code snippet
  222. and replace them with the relevant values.
  223. #+BEGIN_SRC sh :results output :exports both
  224. nano /mnt/etc/config.scm
  225. #+END_SRC>
  226. Snippet:
  227. #+BEGIN_SRC scheme
  228. (use-modules
  229. (gnu)
  230. (gnu system nss))
  231. (use-package-modules
  232. certs
  233. gnome
  234. linux)
  235. (use-service-modules
  236. desktop
  237. xorg)
  238. (operating-system
  239. (kernel linux-libre-lts)
  240. (kernel-arguments
  241. (append
  242. (list
  243. "iomem=relaxed")
  244. %default-kernel-arguments))
  245. (bootloader
  246. (bootloader-configuration
  247. (bootloader
  248. (bootloader
  249. (inherit grub-bootloader)
  250. (installer #~(const #t))))
  251. (keyboard-layout keyboard-layout)))
  252. (keyboard-layout
  253. (keyboard-layout
  254. "xy"
  255. "altgr-intl"))
  256. (host-name "hostname")
  257. (mapped-devices
  258. (list
  259. (mapped-device
  260. (source
  261. (uuid "luks-uuid"))
  262. (target "partname")
  263. (type luks-device-mapping))
  264. (mapped-device
  265. (source "vgname")
  266. (targets
  267. (list
  268. "vgname-lvnameroot"
  269. "vgname-lvnamehome"))
  270. (type lvm-device-mapping))))
  271. (file-systems
  272. (append
  273. (list
  274. (file-system
  275. (type "btrfs")
  276. (mount-point "/")
  277. (device "/dev/mapper/vgname-lvnameroot")
  278. (flags '(no-atime))
  279. (options "space_cache=v2")
  280. (needed-for-boot? #t)
  281. (dependencies mapped-devices))
  282. (file-system
  283. (type "btrfs")
  284. (mount-point "/home")
  285. (device "/dev/mapper/vgname-lvnamehome")
  286. (flags '(no-atime))
  287. (options "space_cache=v2")
  288. (dependencies mapped-devices)))
  289. %base-file-systems))
  290. (swap-devices
  291. (list
  292. "/swapfile"))
  293. (users
  294. (append
  295. (list
  296. (user-account
  297. (name "username")
  298. (comment "Full Name")
  299. (group "users")
  300. (supplementary-groups '("audio" "cdrom" "kvm" "lp" "netdev" "tape" "video" "wheel"))))
  301. %base-user-accounts))
  302. (packages
  303. (append
  304. (list
  305. nss-certs)
  306. %base-packages))
  307. (timezone "Zone/SubZone")
  308. (locale "ab_XY.1234")
  309. (name-service-switch %mdns-host-lookup-nss)
  310. (services
  311. (append
  312. (list
  313. (service gnome-desktop-service-type))
  314. %desktop-services)))
  315. Initialize new Guix System. #+BEGIN_SRC sh :results output :exports
  316. both guix system init /mnt/etc/config.scm /mnt #+END_SRC>
  317. Reboot the device. #+BEGIN_SRC sh :results output :exports both
  318. reboot #+END_SRC>
  319. 
  320. File: guix.info, Node: Completion, Next: Conclusion, Prev: Installation, Up: Guix System and Libreboot
  321. 1.3 Completion
  322. ==============
  323. On reboot, as soon as the Libreboot graphic art appears, press “C” to
  324. enter the command-line.
  325. Enter the following commands and respond to first command with the
  326. LUKS Key. #+BEGIN_SRC sh :results output :exports both cryptomount -u
  327. luks-uuid set root=(lvm/vgname-lvnameroot) #+END_SRC>
  328. Upon Guix’s GRUB menu, go with the default option.
  329. Enter the LUKS Key again, for kernel, as prompted.
  330. Upon login screen, login as "root" with password field empty.
  331. Open terminal.
  332. Set passkey for the "root" user. Follow the prompts. #+BEGIN_SRC sh
  333. :results output :exports both passwd root #+END_SRC>
  334. Set passkey for the "username" user. Follow the prompts.
  335. #+BEGIN_SRC sh :results output :exports both passwd username #+END_SRC>
  336. Install flashrom and wget. #+BEGIN_SRC sh :results output :exports
  337. both guix package –-install flashrom wget #+END_SRC>
  338. Obtain the ROM chip’s model and size. Look for the output line
  339. “Found [...] flash chip [...]”. #+BEGIN_SRC sh :results output :exports
  340. both flashrom –verbose –programmer internal #+END_SRC>
  341. Download Libreboot ROM and utilities, where "YYYYMMDD" is the release
  342. date, ‘devmod’ is the device model and "N" is the ROM chip size.
  343. #+BEGIN_SRC sh :results output :exports both wget –verbose
  344. <https://rsync.libreboot.org/stable/YYYYMMDD/rom/grub/libreboot_rYYYYMMDD_grub_devmod_Nmb.tar.xz>
  345. wget –verbose
  346. <https://rsync.libreboot.org/stable/YYYYMMDD/libreboot_rYYYYMMDD_util.tar.xz>
  347. #+END_SRC>
  348. Extract the downloaded files. #+BEGIN_SRC sh :results output
  349. :exports both tar –extract
  350. –file=libreboot_rYYYYMMDD_grub_devmod_Nmb.tar.xz –verbose tar –extract
  351. –file=libreboot_rYYYYMMDD_util.tar.xz –verbose #+END_SRC>
  352. Rename the directories of extracted files. #+BEGIN_SRC sh :results
  353. output :exports both mv –verbose
  354. "libreboot_rYYYYMMDD_grub_devmod_Nmb.tar.xz" "libreboot_rom" mv –verbose
  355. "libreboot_rYYYYMMDD_util" "libreboot_util" #+END_SRC>
  356. Copy the ROM image to the directory of cbfstool, where "kbdlo" is the
  357. keyboard layout and "arch" is the system architecture. #+BEGIN_SRC sh
  358. :results output :exports both cp
  359. libreboot_rom/devmod_Nmb_kbdlo_vesafb.rom
  360. libreboot_util/cbfstool/arch/libreboot.rom #+END_SRC>
  361. Change directory to the directory of cbfstool. #+BEGIN_SRC sh
  362. :results output :exports both cd libreboot_util/cbfstool/arch/
  363. #+END_SRC>
  364. Extract the GRUB configuration file from the image. #+BEGIN_SRC sh
  365. :results output :exports both ./cbfstool libreboot.rom extract -n
  366. grub.cfg -f grub.cfg #+END_SRC>
  367. Edit the GRUB configuration file and insert the following code
  368. snippet above the line ‘“menuentry 'Load Operating System [o]'
  369. --hotkey='o' --unrestricted { [...] }”’. #+BEGIN_SRC sh :results output
  370. :exports both nano grub.cfg #+END_SRC>
  371. Snippet:
  372. menuentry ‘Guix System (An advanced distribution of the GNU operating system) [g]’ --hotkey=’g’ --unrestricted
  373. {
  374. cryptomount -u luks-uuid
  375. set root=(lvm/vgname-lvnameroot)
  376. configfile /boot/grub/grub.cfg
  377. }
  378. Remove the old GRUB configuration file from the ROM image.
  379. #+BEGIN_SRC sh :results output :exports both ./cbfstool libreboot.rom
  380. remove -n grub.cfg #+END_SRC>
  381. Insert the new GRUB configuration file into the ROM image.
  382. #+BEGIN_SRC sh :results output :exports both ./cbfstool libreboot.rom
  383. add -n grub.cfg -f grub.cfg -t raw #+END_SRC>
  384. Move the ROM image to the directory of ich9gen. #+BEGIN_SRC sh
  385. :results output :exports both mv libreboot.rom
  386. ~/libreboot_util/ich9deblob/arch/libreboot.rom #+END_SRC>
  387. Change directory to the directory of ich9gen. #+BEGIN_SRC sh
  388. :results output :exports both cd ~/libreboot_util/ich9deblob/arch/
  389. #+END_SRC>
  390. Generate descriptor+GbE images with the MAC address, where "mac-addr"
  391. is the MAC address of the machine. #+BEGIN_SRC sh :results output
  392. :exports both ich9gen –macaddress mac-addr #+END_SRC>
  393. Insert the descriptor+GbE image into the ROM image, where "N" is the
  394. ROM chip size. #+BEGIN_SRC sh :results output :exports both dd bs=12k
  395. conv=notrunc count=1 if=ich9fdgbe_Nm.bin of=libreboot.rom
  396. status=progress #+END_SRC>
  397. Move the ROM image to the directory of flash. #+BEGIN_SRC sh
  398. :results output :exports both mv libreboot.rom
  399. ~/libreboot_util/libreboot.rom #+END_SRC>
  400. Change directory to the directory of flash. #+BEGIN_SRC sh :results
  401. output :exports both cd ~/libreboot_util #+END_SRC>
  402. Modify the shebang of flash script, from ‘#!/bin/bash‘ to
  403. ‘#!/bin/sh‘. #+BEGIN_SRC sh :results output :exports both nano flash
  404. #+END_SRC>
  405. Flash the ROM with the new image. #+BEGIN_SRC sh :results output
  406. :exports both ./flash update libreboot.rom #+END_SRC>
  407. (or)
  408. #+BEGIN_SRC sh :results output :exports both ./flash forceupdate
  409. libreboot.rom #+END_SRC>
  410. Reboot the device. #+BEGIN_SRC sh :results output :exports both
  411. reboot #+END_SRC>
  412. 
  413. File: guix.info, Node: Conclusion, Next: References, Prev: Completion, Up: Guix System and Libreboot
  414. 1.4 Conclusion
  415. ==============
  416. Everything should be stream-lined from now. Upon Libreboot’s GRUB menu,
  417. you can either press "G" or choose "Guix System (An advanced
  418. distribution of the GNU operating system) [g]".
  419. During the boot process, as prompted, you have to type LUKS key
  420. twice; once for Libreboot’s GRUB and once more for Linux-Libre kernel.
  421. Generally, you will be using Libreboot’s initial/default grub.cfg,
  422. whose Guix menu-entry invokes Guix’s grub.cfg located at ‘/boot/grub/’.
  423. For trouble-shooting, you can also use Libreboot’s ‘grubtest.cfg’, which
  424. hasn’t been modified.
  425. That is it! You have now setup Guix System with Full Disk Encryption
  426. on your device powered by Libreboot. Enjoy!
  427. 
  428. File: guix.info, Node: References, Next: Acknowledgements, Prev: Conclusion, Up: Guix System and Libreboot
  429. 1.5 References
  430. ==============
  431. [1] Guix manual (<http://guix.gnu.org/manual/en/>).
  432. [2] Libreboot documentation (<https://libreboot.org/docs/>).
  433. 
  434. File: guix.info, Node: Acknowledgements, Next: License, Prev: References, Up: Guix System and Libreboot
  435. 1.6 Acknowledgements
  436. ====================
  437. [1] Thanks to Guix developer, Clement Lassieur (clement@lassieur.org),
  438. for helping me with the Scheme code for the bootloader configuration.
  439. [2] Thanks to Libreboot founder and developer, Leah Rowe
  440. (leah@libreboot.org), for helping me with the understanding of
  441. Libreboot’s functionalities.
  442. 
  443. File: guix.info, Node: License, Prev: Acknowledgements, Up: Guix System and Libreboot
  444. 1.7 License
  445. ===========
  446. This work by Raghav Gururajan is licensed under the Creative Commons
  447. Attribution-ShareAlike 4.0 International License.
  448. To view a copy of this license, visit
  449. <https://creativecommons.org/licenses/by-sa/4.0/>
  450. 
  451. Tag Table:
  452. Node: Top69
  453. Node: Guix System and Libreboot420
  454. Node: Preparation1429
  455. Node: Installation2988
  456. Node: Wireless Setup5107
  457. Node: Completion12928
  458. Node: Conclusion17953
  459. Node: References18791
  460. Node: Acknowledgements19054
  461. Node: License19505
  462. 
  463. End Tag Table
  464. 
  465. Local Variables:
  466. coding: utf-8
  467. End: