Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2020
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.89 KB | None | 0 0
  1. ## MoJo's Gentoo install with LUKS, LVM and EFI
  2.  
  3. Video Tutorial: https://youtu.be/IzUf-wFEirQ
  4. https://pastebin.com/z406J0RD
  5. https://www.youtube.com/watch?v=4FLhSSsIw-E
  6.  
  7. ### Preparing the disks ###
  8. fdisk -l
  9. parted -a optimal /dev/sda
  10. mklabel gpt
  11. unit mib
  12. mkpart primary 1 3
  13. name 1 grub
  14. set 1 bios_grub on
  15. mkpart primary fat32 3 131
  16. name 2 boot
  17. set 2 BOOT on
  18. mkpart primary 131 -1
  19. name 3 lvm
  20. set 3 lvm on
  21. print
  22. quit
  23.  
  24. mkfs.vfat -F32 /dev/sda2
  25.  
  26. ### LVM setup ###
  27. cryptsetup -v -y -c aes-xts-plain64 -s 512 -h sha512 -i 5000 --use-random luksFormat /dev/sda3
  28. YES
  29. Enter: passphrase
  30. Verify
  31.  
  32. cryptsetup luksDump /dev/sda3
  33. cryptsetup luksOpen /dev/sda3 gentoo
  34. Enter passphrase
  35.  
  36. lvmdiskscan
  37. pvcreate /dev/mapper/gentoo
  38. pvdisplay
  39. vgcreate gentoo /dev/mapper/gentoo
  40. vgdisplay
  41.  
  42. lvcreate -C y -L 4G gentoo -n swap
  43. lvcreate -L 10GB gentoo -n root
  44. lvcreate -l +100%FREE gentoo -n home
  45. lvdisplay
  46.  
  47. vgscan (may say running but disabled)
  48. vgchange -ay (should say active now)
  49.  
  50. mkswap /dev/mapper/gentoo-swap
  51. mkfs.ext4 /dev/mapper/gentoo-root
  52. mkfs.ext4 /dev/mapper/gentoo-home
  53.  
  54. swapon /dev/mapper/gentoo-swap
  55. mount /dev/mapper/gentoo-root /mnt/gentoo
  56. mkdir /mnt/gentoo/boot
  57. mkdir /mnt/gentoo/home
  58. mount /dev/sda2 /mnt/gentoo/boot
  59. mount /dev/mapper/gentoo-home /mnt/gentoo/home
  60.  
  61. lsblk /dev/sda
  62. Should print out schematic of lvm
  63.  
  64.  
  65. ### Installing stage3 ###
  66. cd /mnt/gentoo
  67. links gentoo.org/main/en/mirrors.xml
  68. download Stage3 tarball
  69. sha512sum stage3-amd64-*.tar.xz
  70. tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
  71.  
  72. nano -w /mnt/gentoo/etc/portage/make.conf
  73. Set Nexcloud\make_conf\*.txt
  74.  
  75. ### Install Base System ###
  76. mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
  77. mkdir /mnt/gentoo/etc/portage/repos.conf
  78. cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
  79. cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
  80.  
  81. mount --types proc /proc /mnt/gentoo/proc
  82. mount --rbind /sys /mnt/gentoo/sys
  83. mount --rbind /dev /mnt/gentoo/dev
  84.  
  85. #### Prepare chroot environment with lvmetad service (needed for grub-mkconfig when using lvm) ####
  86. mkdir /mnt/gentoo/hostrun
  87. mount --bind /run /mnt/gentoo/hostrun/
  88.  
  89. chroot /mnt/gentoo /bin/bash && source /etc/profile && export PS1="(chroot) $PS1"
  90.  
  91. #### Now mount lvmetad service for grub-mkconfig ####
  92. mkdir /run/lvm
  93. mount --bind /hostrun/lvm /run/lvm/
  94.  
  95. #### Configuring Portage ####
  96. emerge-webrsync
  97. emerge --sync
  98.  
  99. eselect profile list
  100. eselect profile set X
  101.  
  102. echo "Europe/Amsterdam" > /etc/timezone
  103. emerge --config sys-libs/timezone-data
  104.  
  105. nano -w /etc/locale.gen
  106. locale-gen
  107.  
  108. eselect locale list
  109. eselect locale set 4
  110.  
  111. emerge --ask --verbose --update --deep --newuse @world
  112. dispatch-conf
  113.  
  114. emerge --ask --verbose vim sys-kernel/gentoo-sources plymouth sys-apps/pciutils lvm2 sys-kernel/genkernel-next app-editors/vim app-portage/flaggie
  115. emerge --verbose --oneshot app-portage/cpuid2cpuflags sys-apps/kmod
  116. env-update && source /etc/profile && export PS1="(chroot) ${PS1}"
  117. ### Configuring the kernel ###
  118. cd /usr/src/linux
  119. genkernel --makeopts=-j3 --menuconfig --lvm --luks all
  120. or
  121. make menuconfig
  122. lvm requirements
  123. luks requirements (sha512,AES)
  124. make && make modules_install
  125. make install
  126.  
  127. ### Configuring the system ###
  128. vim /etc/fstab
  129. # <file system> <dir> <type> <options> <dump> <pass>
  130. /dev/sda2 /boot ext2 noatime 0 2
  131. /dev/mapper/gentoo-root / ext4 defaults,rw,relatime,data=ordered 0 1
  132. /dev/mapper/gentoo-home /home ext4 rw,relatime,data=ordered 0 2
  133. /dev/mapper/gentoo-swap none swap defaults 0 0
  134.  
  135. passwd
  136.  
  137. useradd -m -G users,wheel,audio,video -s /bin/bash main
  138. passwd main
  139.  
  140. rm stage*
  141.  
  142. echo "home" > /etc/hostname
  143. vim /etc/hosts
  144. home localhost
  145. ""
  146. ### Installing system tools ###
  147. emerge -av app-admin/sysklogd sys-process/cronie sys-apps/mlocate net-misc/dhcpcd app-misc/tmux
  148. rc-update add sysklogd default
  149. rc-update add cronie default
  150. rc-update add sshd default
  151. rc-update add lvm boot
  152.  
  153. emerge -av sys-kernel/linux-firmware net-tools app-text/tree
  154. tree /sys/class/net
  155.  
  156. emerge --ask --noreplace net-misc/netifrc
  157. vim /etc/conf.d/net
  158. config_enp0s3="dhcp"
  159.  
  160. cd /etc/init.d
  161. ln -s net.lo net.enp0s3
  162. rc-update add net.enp0s3 default
  163.  
  164. vim /etc/rc.conf
  165. vim /etc/conf.d/keymaps
  166. vim /etc/conf.d/hwclock
  167. clock="local"
  168.  
  169. ### Configuring the bootloader/GRUB install ###
  170. echo 'GRUB_PLATFORMS="emu efi-64 pc"' >> /etc/portage/make.conf
  171. flaggie grub +mount +device-mapper
  172. emerge -av sys-boot/grub:2 sys-kernel/linux-firmware sys-fs/e2fsprogs sys-fs/dosfstools
  173.  
  174. vim /etc/default/grub
  175. GRUB_PRELOAD_MODULES=lvm
  176. GRUB_ENABLE_CRYPTODISK=y
  177. GRUB_DEVICE=/dev/ram0
  178. GRUB_CMDLINE_LINUX="crypt_root=/dev/sda3 real_root=/dev/mapper/gentoo-root rootfstype=ext4 dolvm quiet splash"
  179. (remove quiet splash for debugging)
  180. grub-install --target=x86_64-efi --efi-directory=/boot --modules="linux crypto search_fs_uuid luks lvm" --recheck /dev/sda
  181. grub-mkconfig -o /boot/grub/grub.cfg
  182.  
  183. exit
  184. cd ~
  185.  
  186. umount -l /mnt/gentoo/dev{/shm,/pts,}
  187. umount -R /mnt/gentoo
  188.  
  189. reboot
  190.  
  191. should see "Enter passphrase for /dev/sda2"
  192.  
  193. echo "SOLARIZED=TRUE" > /etc/eixrc/99-color
  194. SOLARIZED=true
  195.  
  196. ### Updating Plymouth Theme ###
  197.  
  198. plymouth-set-default-theme --list
  199. plymouth-set-default-theme set X
  200.  
  201. ## Gentoo Rescue ##
  202. mkdir /mnt/gentoo
  203. mount /dev/sda3 /mnt/gentoo
  204.  
  205. Next, bindmount /proc, /dev and /sys on top the /mnt/gentoo mountpoint:
  206. mount --rbind /proc /mnt/gentoo/proc
  207. mount --rbind /dev /mnt/gentoo/dev
  208. mount --rbind /sys /mnt/gentoo/sys
  209.  
  210. Finally, chroot into the environment, mount the remaining partitions, and start recovering the system:
  211. chroot /mnt/gentoo /bin/sh
  212. source /etc/profile
  213. mount -a
  214.  
  215. Once finished with the recovery steps, umount all partitions, exit the chroot, umount the remaining partitions, and reboot back into the system to see if the recovery has succeeded:
  216. umount -a
  217. exit
  218. umount -l /mnt/gentoo/{dev,proc,sys,}
  219. sync
  220. reboot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement