I have been doing a Gentoo install and learning about the process as I go. I recently had the machine I was installing to up for three days and while I was compiling gcc it over-heated and crapped out. I do not want to start all over again, how do I chroot back in? I know I need to mount something, but I am confused. Here is everything I have done so far:
#==========================#
# #
# Gentoo Install Notes #
# #
#==========================#
##
## Pre Installation
##
# download the gentoo iso and verify it:
wget
http://distfiles.gentoo.org/releases...03T214503Z.iso
sha512sum install-amd64-minimal-20190403T214503Z.iso
curl
https://gentoo.osuosl.org/releases/a...3Z.iso.DIGESTS
# brun iso to USB:
sudo dd if=/home/user/Downloads/install-amd64-minimal-20190403T214503Z.iso of=/dev/sdb bs=4M
sudo sync
# unmount the USB:
sudo unmount /dev/sdb (or whatever your USB is)
## plug the USB into the system you are installing too and ssh into it from your other machine (if you have one):
# configure network
## figure wireless network interface
### run ifconfig and find wireless interface (example: wlp7s0):
ifconfig
### check the current wireless settings:
iw dev wlp7s0 info
### check for a current connection:
iw dev wlp7s0 link
### setup wireless with wpa_supplicant for WPA network:
#### setup wpa_supplicant with SSID and Passphrase:
wpa_passphrase MYSSID PASSPHRASE
#### start wpa_supplicant:
wpa_supplicant -B -i wlp7s0 -c <(wpa_passphrase MYSSID PASSPHRASE)
#### test network connection:
ping gentoo.org
# set a password for the machine:
passwd
# get the ip of the machine and start sshd:
ip addr show | grep 'inet'
rc-service sshd start
# ssh into the machine:
ssh root@ipaddress
##
## Installation
##
# wipe drive and clear the dead space (if your previous installation was encrypted, then you do not need to do this as the key will be lost anyway):
dd if=/dev/urandom of=/dev/sda
# setup the disk
# start partitioning on /dev/sda:
parted -a optimal /dev/sda
# use GPT for the partition table:
mklabel gpt
# use mebibytes for unit size:
unit mib
# create a new partition (primary):
mkpart primary 1 3
# name partition 1 "bios_grub":
name 1 bios_grub
# set partiton one on:
set 1 bios_grub on
# create a new partition (primary):
mkpart primary 3 515
# name partition 2 boot:
name 2 boot
# set partition 2 on:
set 2 BOOT on
# create a parition (primary):
mkpart primary 515 -1
# name partition 3 "lvm":
name 3 lvm
# set partition 3 on:
set 3 lvm on
# print the partition scheme:
print (make sure boot and esp is there)
# quit parted
q
# format partiton one in FAT32:
mkfs.vfat /dev/sda1
# format partition two in ext2:
mkfs.ext2 /dev/sda2
# encrypt partition three with luks:
cryptsetup --verbose --cipher serpent-xts-plain64 --key-size 512 --hash whirlpool luksFormat /dev/sda3
# verify the encryption:
YES
# eneter decrypt passphrase:
type in passphrase
# dump LUKS header to /dev/sda3 (take a picture of this information):
cryptsetup luksDump /dev/sda3
# initialize the volume set an initial key/passphrase:
cryptsetup luksOpen /dev/sda3 gentoolv
# initialize partition for LVM:
pvcreate /dev/mapper/gentoolv
# display attributes of the physical volume (take a picture of this):
pvdisplay
# create a volume group named "gentoovg":
vgcreate gentoovg /dev/mapper/gentoolv
# display attributes of volume group "gentoovg" (take a picture of this):
vgdisplay
## create logical volumes in existing group "gentoovg":
# create logical volume swap:
lvcreate -C y -L 4G gentoovg -n swap
# create logical volume root:
lvcreate -C y -L 70G gentoovg -n root
# create logical volume home:
lvcreate -n home -l 100%FREE gentoovg
# display attributes of the logical volumes:
lvdisplay
# scan all disks for volume groups and rebuild caches:
vgscan
# change attributes of a volume group and make the volume group known to the kernal:
vgchange -ay
# set up a Linux swap area:
mkswap /dev/mapper/gentoovg-swap
# enable device for paging and swapping:
swapon /dev/mapper/gentoovg-swap
# display amount of free and used memory in the system in mebibytes:
free -m
# format gentoovg-root in ext4:
mkfs.ext4 /dev/mapper/gentoovg-root
# format gentoovg-home in ext4:
mkfs.ext4 /dev/mapper/gentoovg-home
# mount gentoovg-root to /mnt/gentoo:
mount /dev/mapper/gentoovg-root /mnt/gentoo
# set time using ntpd:
ntpd -q -g
# go to the Gentoo mount point where the root file system is mounted:
cd /mnt/gentoo
# wget hardened stage3:
wget
http://distfiles.gentoo.org/releases...214503Z.tar.xz
# verify the stage3:
sha512sum stage3-amd64-hardened-20190403T214503Z.tar.xz
curl -s
https://gentoo.osuosl.org/releases/a...tar.xz.DIGESTS
# unpack hardened stage3:
tar xpvf stage3-amd64-hardened*.tar.xz --xattrs-include='*.*' --numeric-owner
# mount /dev/sda2 on /mnt/gentoo/boot:
mount /dev/sda2 /mnt/gentoo/boot
# mount gentoovg-home on /mnt/gentoo/home:
mount /dev/mapper/gentoovg-home /mnt/gentoo/home
## configure make.conf (NOTE: once you chroot in and have CPU_FLAGS_X86 you will edit using: nano /etc/portage/make.conf)
To get CPU_FLAGS_X86 do the following:
# sync the repos:
emerge-webrsync && emerge --sync
# install cpuid2cpuflags:
emerge --ask --verbose --oneshot app-portage/cpuid2cpuflags
# get the cpu flags:
cpuid2cpuflags
# open make.conf in vi:
vi /mnt/gentoo/etc/portage/make.conf
# clear out make.conf:
hold d
# add the following:
## 64-bit architecture
CHOST="x86_64-pc-linux-gnu"
## compilation optimization
COMMON_FLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
## CPU optimization
MAKEOPTS="-j8"
EMERGE_DEFAULT_OPS="--jobs 4"
#CPU_FLAGS_X86=" PUT THE FLAGS GIVEN BY cpuid2cpuflags HERE"
## package optimization
USE="crypt cryptsetup lvm icu smp udev dbus wayland -dhcpcd -systemd -consolekit -X -bluetooth -dhcp -bindist -kde -gnome"
ACCEPT_LICENSE="-* @FREE"
## languages
LINGUAS="en en_US"
L10N="en en_US"
LC_MESSAGES=C
## basic input/output
VIDEO_CARDS="nouveau"
INPUT_DEVICES="libinput mouse keyboard synaptics"
## download over Tor
#FETCHCOMMAND="curl --socks5-hostname 127.0.0.1:9050 --retry 3 -L --connect-timeout 60 -o "\${DISTDIR}/\${FILE}" "\${URI}""
#RESUMECOMMAND="curl -C - --socks5-hostname 127.0.0.1:9050 --retry 3 -L --connect-timeout 60 -o "\${DISTDIR}/\${FILE}" "\${URI}""
## generic
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"
## Configuring Portage mirrors
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
mkdir --parents /mnt/gentoo/etc/portage/repos.conf
cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
less /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
## Mounting the necessary filesystems
mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/dev
## Entering the new environment
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"
## build base system:
# install a snapshot of the main ebuild repository:
emerge-webrsync
# list all profiles:
eselect profile list
# eselect profile set [number of regular hardened profile]:
eselect profile set [number of hardened profile]
# source profile:
source /etc/profile
emerge --oneshot gcc # stopped here
emerge --oneshot binutils virtual/libc
I am sorry for asking what is likely a very basic question, but I am just nervous and confused about how I chroot back into my current installation. I am taking notes as I go and am looking to add these steps for feature reference, thank you in advance.
Solution:
cryptsetup luksOpen /dev/sda3 gentoolv
mount -t ext4 /dev/mapper/gentoovg-root /mnt/gentoo
mount -t ext2 /dev/sda2 /mnt/gentoo/boot
mount -t ext4 /dev/mapper/gentoovg-home /mnt/gentoo/home
mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"