Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## MoJo's Gentoo install with LUKS, LVM and EFI
- Video Tutorial: https://youtu.be/IzUf-wFEirQ
- https://pastebin.com/z406J0RD
- https://www.youtube.com/watch?v=4FLhSSsIw-E
- ### Preparing the disks ###
- fdisk -l
- parted -a optimal /dev/sda
- mklabel gpt
- unit mib
- mkpart primary 1 3
- name 1 grub
- set 1 bios_grub on
- mkpart primary fat32 3 131
- name 2 boot
- set 2 BOOT on
- mkpart primary 131 -1
- name 3 lvm
- set 3 lvm on
- print
- quit
- mkfs.vfat -F32 /dev/sda2
- ### LVM setup ###
- cryptsetup -v -y -c aes-xts-plain64 -s 512 -h sha512 -i 5000 --use-random luksFormat /dev/sda3
- YES
- Enter: passphrase
- Verify
- cryptsetup luksDump /dev/sda3
- cryptsetup luksOpen /dev/sda3 gentoo
- Enter passphrase
- lvmdiskscan
- pvcreate /dev/mapper/gentoo
- pvdisplay
- vgcreate gentoo /dev/mapper/gentoo
- vgdisplay
- lvcreate -C y -L 4G gentoo -n swap
- lvcreate -L 10GB gentoo -n root
- lvcreate -l +100%FREE gentoo -n home
- lvdisplay
- vgscan (may say running but disabled)
- vgchange -ay (should say active now)
- mkswap /dev/mapper/gentoo-swap
- mkfs.ext4 /dev/mapper/gentoo-root
- mkfs.ext4 /dev/mapper/gentoo-home
- swapon /dev/mapper/gentoo-swap
- mount /dev/mapper/gentoo-root /mnt/gentoo
- mkdir /mnt/gentoo/boot
- mkdir /mnt/gentoo/home
- mount /dev/sda2 /mnt/gentoo/boot
- mount /dev/mapper/gentoo-home /mnt/gentoo/home
- lsblk /dev/sda
- Should print out schematic of lvm
- ### Installing stage3 ###
- cd /mnt/gentoo
- links gentoo.org/main/en/mirrors.xml
- download Stage3 tarball
- sha512sum stage3-amd64-*.tar.xz
- tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
- nano -w /mnt/gentoo/etc/portage/make.conf
- Set Nexcloud\make_conf\*.txt
- ### Install Base System ###
- mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
- mkdir /mnt/gentoo/etc/portage/repos.conf
- cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
- cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
- mount --types proc /proc /mnt/gentoo/proc
- mount --rbind /sys /mnt/gentoo/sys
- mount --rbind /dev /mnt/gentoo/dev
- #### Prepare chroot environment with lvmetad service (needed for grub-mkconfig when using lvm) ####
- mkdir /mnt/gentoo/hostrun
- mount --bind /run /mnt/gentoo/hostrun/
- chroot /mnt/gentoo /bin/bash && source /etc/profile && export PS1="(chroot) $PS1"
- #### Now mount lvmetad service for grub-mkconfig ####
- mkdir /run/lvm
- mount --bind /hostrun/lvm /run/lvm/
- #### Configuring Portage ####
- emerge-webrsync
- emerge --sync
- eselect profile list
- eselect profile set X
- echo "Europe/Amsterdam" > /etc/timezone
- emerge --config sys-libs/timezone-data
- nano -w /etc/locale.gen
- locale-gen
- eselect locale list
- eselect locale set 4
- emerge --ask --verbose --update --deep --newuse @world
- dispatch-conf
- emerge --ask --verbose vim sys-kernel/gentoo-sources plymouth sys-apps/pciutils lvm2 sys-kernel/genkernel-next app-editors/vim app-portage/flaggie
- emerge --verbose --oneshot app-portage/cpuid2cpuflags sys-apps/kmod
- env-update && source /etc/profile && export PS1="(chroot) ${PS1}"
- ### Configuring the kernel ###
- cd /usr/src/linux
- genkernel --makeopts=-j3 --menuconfig --lvm --luks all
- or
- make menuconfig
- lvm requirements
- luks requirements (sha512,AES)
- make && make modules_install
- make install
- ### Configuring the system ###
- vim /etc/fstab
- # <file system> <dir> <type> <options> <dump> <pass>
- /dev/sda2 /boot ext2 noatime 0 2
- /dev/mapper/gentoo-root / ext4 defaults,rw,relatime,data=ordered 0 1
- /dev/mapper/gentoo-home /home ext4 rw,relatime,data=ordered 0 2
- /dev/mapper/gentoo-swap none swap defaults 0 0
- passwd
- useradd -m -G users,wheel,audio,video -s /bin/bash main
- passwd main
- rm stage*
- echo "home" > /etc/hostname
- vim /etc/hosts
- home localhost
- ""
- ### Installing system tools ###
- emerge -av app-admin/sysklogd sys-process/cronie sys-apps/mlocate net-misc/dhcpcd app-misc/tmux
- rc-update add sysklogd default
- rc-update add cronie default
- rc-update add sshd default
- rc-update add lvm boot
- emerge -av sys-kernel/linux-firmware net-tools app-text/tree
- tree /sys/class/net
- emerge --ask --noreplace net-misc/netifrc
- vim /etc/conf.d/net
- config_enp0s3="dhcp"
- cd /etc/init.d
- ln -s net.lo net.enp0s3
- rc-update add net.enp0s3 default
- vim /etc/rc.conf
- vim /etc/conf.d/keymaps
- vim /etc/conf.d/hwclock
- clock="local"
- ### Configuring the bootloader/GRUB install ###
- echo 'GRUB_PLATFORMS="emu efi-64 pc"' >> /etc/portage/make.conf
- flaggie grub +mount +device-mapper
- emerge -av sys-boot/grub:2 sys-kernel/linux-firmware sys-fs/e2fsprogs sys-fs/dosfstools
- vim /etc/default/grub
- GRUB_PRELOAD_MODULES=lvm
- GRUB_ENABLE_CRYPTODISK=y
- GRUB_DEVICE=/dev/ram0
- GRUB_CMDLINE_LINUX="crypt_root=/dev/sda3 real_root=/dev/mapper/gentoo-root rootfstype=ext4 dolvm quiet splash"
- (remove quiet splash for debugging)
- grub-install --target=x86_64-efi --efi-directory=/boot --modules="linux crypto search_fs_uuid luks lvm" --recheck /dev/sda
- grub-mkconfig -o /boot/grub/grub.cfg
- exit
- cd ~
- umount -l /mnt/gentoo/dev{/shm,/pts,}
- umount -R /mnt/gentoo
- reboot
- should see "Enter passphrase for /dev/sda2"
- echo "SOLARIZED=TRUE" > /etc/eixrc/99-color
- SOLARIZED=true
- ### Updating Plymouth Theme ###
- plymouth-set-default-theme --list
- plymouth-set-default-theme set X
- ## Gentoo Rescue ##
- mkdir /mnt/gentoo
- mount /dev/sda3 /mnt/gentoo
- Next, bindmount /proc, /dev and /sys on top the /mnt/gentoo mountpoint:
- mount --rbind /proc /mnt/gentoo/proc
- mount --rbind /dev /mnt/gentoo/dev
- mount --rbind /sys /mnt/gentoo/sys
- Finally, chroot into the environment, mount the remaining partitions, and start recovering the system:
- chroot /mnt/gentoo /bin/sh
- source /etc/profile
- mount -a
- 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:
- umount -a
- exit
- umount -l /mnt/gentoo/{dev,proc,sys,}
- sync
- reboot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement