Gentoo Linux quick installer script

Published on Author Artem ButusovLeave a comment

Why?

Sometimes working gentoo environment could be needed just right now but typical manual installation is taking time.

Let’s say you need Gentoo running on Virtual Box on you physical box to test some gentoo-specific things or you just like Gentoo more than other distros.

The script I will share with you will save you time. It a little bit naive and straightforward but it is also simple and easy to tune for your needs. Pretty linear bash script.

NOTE: There is full automated script available for Virtual Box here: https://github.com/sormy/gentoo-vbox-builder

What this doing

It is actually a minimal set of actions needed to get bootable Gentoo:

  • prepare partitions (boot, swap, root partitions)
  • install latest stage3 and portage snapshot (for x86_64 platform, but that could be altered in script)
  • install bootloader
  • install kernel
    • either quick mode: copy minimal install CD kernel
    • or regular mode: download source and build with genkernel
  • setup dhcp network on first interface
  • enable ssh
  • install your public ssh key for ssh access (password access disabled)
  • all other options like locale, charset, hostname are default, you could login into host and change if you want.

Prerequisites

Instruction below are for macOS host OS and guest Virtual Box instance. For windows it is similar but you will need to use Putty for SSH.

By the way, even SSH is optional here. You could technically just type manually a few commands directly in virtual box console session to initiate installation.

  • Install VirtualBox
  • Create new instance (around 15GB is needed for minimal Gentoo)
  • (optional) Setup port forwarding from host to guest for SSH (for example, host 5555 -> guest 22)
  • Download minimal installation CD iso
  • Attach installation CD to instance
  • Boot from installation CD
  • (optional) Set root’s password (could be any, even very simple, used just for this installation session): passwd
  • (optional) Run SSH: /etc/init.d/sshd start
  • (optional) Connect from host over SSH: ssh root@localhost -p 5555
    • If the same host and port was previously used for SSH connection then previous SSH certificate fingerprint need to be remove to connect. It could be done here: ~/.ssh/known_hosts

Installation

The link below could be outdated, please follow gist to download revision of script.

The script source code is available here: https://gist.github.com/sormy/7221a65a3becf082aaa3af2ec8dee1bc

THIS SCRIPT WILL DESTROY ALL DATA ON GUEST OS DISK!!! DO NOT RUN ON HOST OS WITH YOUR DATA!!!

  • Download gentoo installer: wget https://gist.githubusercontent.com/sormy/7221a65a3becf082aaa3af2ec8dee1bc/raw/317d2aa4819e84b3ee6c8b20f15762684d6d7630/gentoo-installer.sh
  • Edit script: nano gentoo-installer.sh
    • SSH_PUBLIC_KEY – set to your SSH public key to be able to login into Gentoo after
    • USE_LIVECD_KERNEL – it is up to you, using binary precompiled version is a faster way to get bootable Gentoo.
  • Run script: bash gentoo-installer.sh
  • After installation script will beep 10 times and will initiate reboot
  • Do not forget to eject installation CD from instance

Please note, script will stop if any error will happen.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.