Skip to content

Instantly share code, notes, and snippets.

Created January 22, 2024 12:06
Show Gist options
  • Save MCMXCIII/d53ed7844d5b0bbdbf18e2eafe6cf9c9 to your computer and use it in GitHub Desktop.
Save MCMXCIII/d53ed7844d5b0bbdbf18e2eafe6cf9c9 to your computer and use it in GitHub Desktop.
Exherbo Script.
# Prompt for BIOS or UEFI booting
echo "Select the boot mode:"
echo "1. BIOS/Legacy booting"
echo "2. UEFI booting"
read -p "Enter the number (1 or 2): " boot_mode
# Validate user input
if [[ $boot_mode != "1" && $boot_mode != "2" ]]; then
echo "Invalid choice. Exiting."
exit 1
# Prompt for disk selection
read -p "Enter the disk to use (e.g., /dev/sda): " selected_disk
# Validate user input
if [[ ! -e $selected_disk ]]; then
echo "Invalid disk. Exiting."
exit 1
# Prepare the hard disk
cfdisk $selected_disk
if [[ $boot_mode == "1" ]]; then
mkfs.ext2 "${selected_disk}1"
mkfs.vfat -F32 "${selected_disk}1"
mkfs.ext4 "${selected_disk}2"
mkfs.ext4 "${selected_disk}3"
mkdir /mnt/exherbo && mount "${selected_disk}2" /mnt/exherbo && cd /mnt/exherbo
curl -O
curl -O
sha256sum -c exherbo-x86_64-pc-linux-gnu-current.tar.xz.sha256sum
tar xJpf exherbo*xz
cat <<EOF > /mnt/exherbo/etc/fstab
${selected_disk}2 / ext4 defaults 0 0
${selected_disk}3 /home ext4 defaults 0 2
if [[ $boot_mode == "1" ]]; then
echo "${selected_disk}1 /boot ext2 defaults 0 0" >> /mnt/exherbo/etc/fstab
echo "${selected_disk}1 /boot vfat defaults 0 0" >> /mnt/exherbo/etc/fstab
# Chroot into the system
mount -o rbind /dev /mnt/exherbo/dev/
mount -o rbind /sys /mnt/exherbo/sys/
mount -t proc none /mnt/exherbo/proc/
mount "$selected_disk"1 /mnt/exherbo/boot/
mount "$selected_disk"3 /mnt/exherbo/home/
cp /etc/resolv.conf /mnt/exherbo/etc/resolv.conf
env -i TERM=$TERM SHELL=/bin/bash HOME=$HOME $(which chroot) /mnt/exherbo /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"
# Update the install
cd /etc/paludis && vim bashrc && vim *conf
cave sync
# Make it bootable
# Download and extract the latest stable kernel from The Linux Kernel Archives.
# Install the kernel
# Clone the stable kernel on Linux and navigate to it
git clone git:// /kernel
cd /kernel
# Switch to the desired kernel version (6.6.8 in this case)
git checkout tags/v6.6.8
# Configure the kernel
make nconfig
# Compile kernel to arch/x86/boot/bzImage
# Install kernel modules
make modules_install
# For BIOS/Legacy booting using GRUB 2
grub-install $selected_disk
cat <<EOF > /boot/grub/grub.cfg
set timeout=10
set default=0
menuentry "Exherbo" {
set root=(${selected_disk}1)
linux /kernel root=${selected_disk}2
# OR
if [[ $boot_mode == "2" ]]; then
grub-mkconfig -o /boot/grub/grub.cfg
# For UEFI booting using systemd-boot
if [[ $boot_mode == "2" ]]; then
bootctl install
# Assuming kernel copy and systemd-boot configuration steps here
# Configure hostname and hosts file
read -p "Enter the hostname: " user_hostname
cat <<EOF > /etc/hostname
read -p "Enter the domain (e.g., " user_domain
cat <<EOF > /etc/hosts ${user_hostname}.${user_domain} ${user_hostname} localhost
::1 localhost
# Install Linux firmware files if needed
cave resolve linux-firmware
# Set root password
# Install additional locales if needed
# Example locales: en_US.UTF-8 and ru_RU.UTF-8
localedef -i en_US -f ISO-8859-1 en_US
localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
# Change system timezone to Berlin
ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
# Reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment