Skip to content

Instantly share code, notes, and snippets.

Created September 23, 2023 21:39
Show Gist options
  • Save MCMXCIII/428da21580e1c8fa982806126fce7266 to your computer and use it in GitHub Desktop.
Save MCMXCIII/428da21580e1c8fa982806126fce7266 to your computer and use it in GitHub Desktop.
# Function to mount necessary filesystems
mount_filesystems() {
mount -o rbind /dev /mnt/exherbo/dev/
mount -o rbind /sys /mnt/exherbo/sys/
mount -t proc none /mnt/exherbo/proc/
mount /dev/sda1 /mnt/exherbo/boot/
mount /dev/sda3 /mnt/exherbo/home/
cp /etc/resolv.conf /mnt/exherbo/etc/resolv.conf
# Function to chroot into the system
chroot_system() {
env -i TERM=$TERM SHELL=/bin/bash HOME=$HOME $(which chroot) /mnt/exherbo /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"
# Prepare the hard disk
if [[ -d /sys/firmware/efi ]]; then
# Using UEFI booting
cfdisk /dev/sda
mkfs.vfat -F32 /dev/sda1
# Using BIOS/Legacy booting
cfdisk /dev/sda
mkfs.ext2 /dev/sda1
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda3
mkdir /mnt/exherbo && mount /dev/sda2 /mnt/exherbo && cd /mnt/exherbo
# Download and extract the Exherbo stage
curl -O
curl -O
sha256sum -c exherbo-x86_64-pc-linux-gnu-current.tar.xz.sha256sum
tar xJpf exherbo*xz
# Update fstab
cat <<EOF > /mnt/exherbo/etc/fstab
/dev/sda2 / ext4 defaults 0 0
/dev/sda3 /home ext4 defaults 0 2
if [[ -d /sys/firmware/efi ]]; then
# Using UEFI booting
echo "/dev/sda1 /boot vfat defaults 0 0" >> /mnt/exherbo/etc/fstab
# Using BIOS/Legacy booting
echo "/dev/sda1 /boot ext2 defaults 0 0" >> /mnt/exherbo/etc/fstab
# Chroot into the system
# Update the install
cd /etc/paludis
# Make sure Paludis is configured correctly
vim bashrc && vim *conf
# Sync all the trees
cave sync
# Make it bootable
# Download and extract the latest stable kernel from The Linux Kernel Archives.
# Install the kernel (replace 'path-to-kernel' with the actual path)
cd path-to-kernel
make nconfig
make modules_install
cp arch/x86/boot/bzImage /boot/kernel
# Install an init system (systemd is used here)
cave resolve world -c
cave resolve --execute --preserve-world --skip-phase test sys-apps/systemd
# For BIOS/Legacy booting, using GRUB 2
grub-install /dev/sda
# Configure GRUB 2
cat <<EOF > /boot/grub/grub.cfg
set timeout=10
set default=0
menuentry "Exherbo" {
set root=(hd0,1)
linux /kernel root=/dev/sda2
# For UEFI booting, using systemd-boot and kernel-install
bootctl install
# Copy the kernel you just installed into the appropriate directory
kernel-install add kernel-version /boot/vmlinuz-kernel-version
# Configure hostname
cat <<EOF > /etc/hostname
# Ensure hostname mapping in /etc/hosts
cat <<EOF > /etc/hosts my-hostname localhost
::1 localhost
# Install Linux firmware files (if needed)
cave resolve linux-firmware
# Set root password
# Install additional locales if needed
localedef -i en_US -f ISO-8859-1 en_US
localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
# Change system-wide locale if needed
echo LANG="en_US.UTF-8" > /etc/env.d/99locale
# Set system timezone (e.g., Copenhagen, Denmark)
ln -s /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime
# Reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment