Blog


Gentoo quick setup (for advanced gentoo users)

  • May 8, 2016
  • Linux

This is an excerpt from gentoo handbook containing only the stuff that really matters, with no extra stuff:

Prepare your disks

Do I need to explain how? 🙂 if yes, this is not for you

Mount them

mkdir /mnt/gentoo
mount root /mnt/gentoo
mount boot /mnt/gentoo/boot

Prepare stage3

cd /mnt/gentoo
lynx http://distfiles.gentoo.org/releases/amd64/autobuilds/current-install-amd64-minimal/
tar xvjpf stage3-*.tar.bz2 --xattrs

Chroot

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 -L /etc/resolv.conf /mnt/gentoo/etc/
mount -t 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
emerge-webrsync
emerge --sync

Emerge setup

eselect profile list
eselect profile set XXX
emerge --ask --update --deep --newuse @world
echo "Europe/Prague" > /etc/timezone
emerge --config sys-libs/timezone-data
emerge vim
vi /etc/locale.gen
locale-gen
eselect locale list
eselect locale set 5

Kernel

emerge sys-kernel/gentoo-sources sys-apps/pciutils 
cd /usr/src/linux 
# Build as you like
emerge sys-kernel/linux-firmware

Initramfs

Pick one

# Genkernel
emerge sys-kernel/genkernel
genkernel --install initramfs

# Dracut
emerge dracut
cd /boot
dracut

Filesystems

Just edit /etc/fstab

/dev/sda2   /boot        ext2    defaults,noatime     0 2
/dev/sda3   none         swap    sw                   0 0
/dev/sda4   /            ext4    noatime              0 1

Networking

emerge net-misc/dhcpcd ntpd net-misc/netifrc

cd /etc/init.d
ln -s net.lo net.eth0
rc-update add net.eth0 default

Grub

emerge --ask sys-boot/grub:2
grub2-install /dev/sda
grub2-mkconfig -o /boot/grub/grub.cfg

 




systemd cheat sheet

Services overview and unit files

# Show running units
systemctl

# Show status of OS
systemctl status

# List all units
systemctl list-units

# Display failed units:
systemctl --failed

The available unit files can be seen in /usr/lib/systemd/system/ and /etc/systemd/system/

Start / stop

systemctl start unit
# samples
systemctl start apache2.service

# stop
systemctl stop apache2.service

# restart
systemctl restart unit

# reload
systemctl reload unit

# Check whether a unit is already enabled or not:
systemctl is-enabled unit

# Show the status of a unit, including whether it is running or not:
systemctl status unit

Checking status

By default it should be possible to view the output of every unit using journal – journalctl

# Display logs of unit
journalctl -u unit

Enable / disable service

# Enable a unit to be started on bootup:
systemctl enable unit

# Disable a unit to not start during bootup:
systemctl disable unit

# Mask a unit to make it impossible to start it:
systemctl mask unit

# Unmask a unit:
systemctl unmask unit

Power management

# Reboot
systemctl reboot

# Shut down and power-off the system:
systemctl poweroff

# Suspend the system:
systemctl suspend

# Put the system into hibernation:
systemctl hibernate

# Put the system into hybrid-sleep state (or suspend-to-both):
systemctl hybrid-sleep

Modifying system

  • /usr/lib/systemd/system/: units provided by installed packages
  • /etc/systemd/system/: units installed by the system administrator

When you modify the unit file, you always need to run:

systemctl daemon-reload

See https://wiki.archlinux.org/index.php/systemd for more information