Last active
September 21, 2025 14:03
-
-
Save jondkinney/7b7858e9f3acc6d673eafbb3e0107eeb to your computer and use it in GitHub Desktop.
Archboot ISO Creator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| echo "=== Archboot Custom ISO Automation Script ===" | |
| # Add Archboot repository | |
| if ! grep -q "^\[archboot\]" /etc/pacman.conf; then | |
| echo "Adding Archboot repository..." | |
| cat >> /etc/pacman.conf <<'EOF' | |
| [archboot] | |
| Server = https://pkg.archboot.com | |
| EOF | |
| fi | |
| # Update package database | |
| echo "Updating package database..." | |
| pacman -Sy | |
| # Install required packages | |
| echo "Installing archboot-arm..." | |
| pacman -Sd --noconfirm --overwrite '*' archboot-arm | |
| echo "Installing kernel..." | |
| pacman -S --noconfirm linux-aarch64 | |
| echo "Installing limine (for package cache)..." | |
| pacman -S --noconfirm limine | |
| # The Archboot ISO builder expects Image.gz | |
| if [ -f /boot/Image ] && [ ! -f /boot/Image.gz ]; then | |
| echo "Creating Image.gz from Image for ISO builder..." | |
| gzip -c /boot/Image > /boot/Image.gz | |
| fi | |
| # Install autorun script | |
| echo "Installing custom autorun script..." | |
| if [ -f autorun.sh ]; then | |
| mkdir -p /etc/archboot/run/ | |
| cp autorun.sh /etc/archboot/run/autorun.sh | |
| chmod +x /etc/archboot/run/autorun.sh | |
| else | |
| echo "ERROR: autorun.sh not found!" | |
| exit 1 | |
| fi | |
| # Build ISO (will use default GRUB bootloader) | |
| echo "Building ISO..." | |
| cd /root | |
| archboot-aarch64-iso.sh -i=custom-archboot-$(date +%Y%m%d) -g | |
| echo "=== Build Complete ===" | |
| echo "ISO location: /root/*.iso" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # SPDX-License-Identifier: GPL-3.0-or-later | |
| # created by Tobias Powalowski <[email protected]> | |
| . /usr/lib/archboot/common.sh | |
| . /usr/lib/archboot/installer/common.sh | |
| echo "Automatic Archboot - Arch Linux Installation:" | |
| echo "Logging is done on ${_LOG}..." | |
| echo "10 seconds to stop the process with CTRL-C now..." | |
| sleep 10 | |
| ### localize | |
| echo "Localization..." | |
| echo "LANG=en_US.UTF-8" > /etc/locale.conf | |
| echo LC_COLLATE=C >> /etc/locale.conf | |
| localectl set-locale "en_US.UTF-8" &>"${_NO_LOG}" | |
| sd '(^[a-z])' '#$1' /etc/locale.gen | |
| sd "^#en_US.UTF-8" "en_US.UTF-8" /etc/locale.gen | |
| locale-gen &>"${_NO_LOG}" | |
| echo KEYMAP="us" > /etc/vconsole.conf | |
| echo FONT="ter-v32n" >> /etc/vconsole.conf | |
| systemctl restart systemd-vconsole-setup | |
| export LANG="en_US.UTF-8" | |
| : > /.localize | |
| ### network profile | |
| echo "Network..." | |
| : >"/etc/systemd/network/eth0-ethernet.network" | |
| { | |
| echo "#/etc/systemd/network/eth0-ethernet.network generated by Archboot setup" | |
| echo "[Match]" | |
| echo "Name=eth0" | |
| echo "" | |
| echo "[Network]" | |
| echo "MulticastDNS=yes" | |
| echo "DHCP=yes" | |
| } >>"/etc/systemd/network/eth0-ethernet.network" | |
| unset "http_proxy" | |
| unset "https_proxy" | |
| unset "ftp_proxy" | |
| unset "rsync_proxy" | |
| unset "HTTP_PROXY" | |
| unset "HTTPS_PROXY" | |
| unset "FTP_PROXY" | |
| unset "RSYNC_PROXY" | |
| rm -f /etc/systemd/network/10-wired-auto-dhcp.network | |
| systemctl restart systemd-networkd | |
| systemctl restart systemd-resolved | |
| echo "Waiting for network link..." | |
| while true; do | |
| if getent hosts www.google.com &>"${_LOG}"; then | |
| break | |
| else | |
| sleep 1 | |
| fi | |
| done | |
| : > /.network | |
| ### clock | |
| echo "Clock..." | |
| timedatectl set-timezone "America/Chicago" | |
| echo 0.0 0 0.0 > /etc/adjtime | |
| echo 0 >> /etc/adjtime | |
| echo UTC >> /etc/adjtime | |
| timedatectl set-local-rtc 0 | |
| systemctl restart systemd-timesyncd | |
| timedatectl set-ntp 1 | |
| : > /.clock | |
| ### pacman mirror | |
| echo "Pacman Server..." | |
| sd '^Server' '#Server' "/etc/pacman.d/mirrorlist" | |
| echo 'Server = http://mirror.archlinuxarm.org/$arch/$repo' >> "/etc/pacman.d/mirrorlist" | |
| ### pacman keyring | |
| echo "Pacman keyring..." | |
| _pacman_keyring | |
| pacman -Sy --noconfirm --noprogressbar archlinux-keyring &>"${_LOG}" | |
| : > /.pacsetup | |
| ### quicksetup | |
| : > /tmp/.device-names | |
| : > /tmp/.fstab | |
| wipefs -a -f "/dev/sda" &>"${_NO_LOG}" | |
| dd if=/dev/zero of="/dev/sda" bs=1M count=10 &>"${_NO_LOG}" | |
| sync | |
| ### partition | |
| echo "Partitioning /dev/sda..." | |
| sfdisk "/dev/sda" << EOF &>"${_LOG}" | |
| label: gpt | |
| label-id: 2FD59199-57D0-4557-9F72-9762C527CE01 | |
| device: /dev/sda | |
| unit: sectors | |
| first-lba: 2048 | |
| last-lba: 524287966 | |
| sector-size: 512 | |
| /dev/sda1 : start= 2048, size= 4096, type=21686148-6449-6E6F-744E-656564454649, uuid=F8ED3F00-80DF-452C-9914-E388FE15B9A5, name="BIOS_GRUB" | |
| /dev/sda2 : start= 6144, size= 1048576, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=18BDC0AD-F49B-4BB5-86EF-80D19F4223F0, name="ESP" | |
| /dev/sda3 : start= 1054720, size= 524288, type=0657FD6D-A4AB-43C4-84E5-0933C84B4F4F, uuid=2D009C38-EA82-4451-A684-9FCAF9B1C5AD, name="SWAP" | |
| /dev/sda4 : start= 1579008, size= 522706944, type=B921B045-1DF0-41C3-AF44-4C6F280D3FAE, uuid=EF790404-6D0A-4E23-A098-32E180C61F8A, name="ARCH_LINUX_ROOT" | |
| EOF | |
| ### quicksetup mountpoints | |
| udevadm settle | |
| echo "Creating and activating swapspace on /dev/sda3..." | |
| mkswap -L "SWAP" "/dev/sda3" &>"${_LOG}" | |
| swapon "/dev/sda3" &>"${_LOG}" | |
| echo "# DEVICE DETAILS: /dev/sda3 PARTUUID=2d009c38-ea82-4451-a684-9fcaf9b1c5ad PARTLABEL=SWAP UUID=$(lsblk -rpno UUID /dev/sda3) LABEL=SWAP" >> /tmp/.device-names | |
| echo "Creating btrfs on /dev/sda4, mounting to /mnt/install/..." | |
| mkfs.btrfs -f -L ARCH_ROOT /dev/sda4 &>"${_LOG}" | |
| btrfs device scan &>"${_NO_LOG}" | |
| mkdir -p "/tmp/btrfsmp.qusY" | |
| mount "/dev/sda4" "/tmp/btrfsmp.qusY" | |
| btrfs subvolume create "/tmp/btrfsmp.qusY"/"root" &>"${_LOG}" | |
| umount "/tmp/btrfsmp.qusY" | |
| rm -r "/tmp/btrfsmp.qusY" | |
| btrfs device scan &>"${_NO_LOG}" | |
| mkdir -p "/mnt/install""/" | |
| mount -t "btrfs" -o "subvol=root,compress=zstd,noatime" "/dev/sda4" "/mnt/install""/" &>"${_LOG}" | |
| btrfs balance start --full-balance "/mnt/install""/" &>"${_LOG}" | |
| echo "# DEVICE DETAILS: /dev/sda4 PARTUUID=ef790404-6d0a-4e23-a098-32e180c61f8a PARTLABEL=ARCH_LINUX_ROOT UUID=$(lsblk -rpno UUID /dev/sda4) LABEL=ARCH_ROOT" >> /tmp/.device-names | |
| echo -n "PARTUUID=ef790404-6d0a-4e23-a098-32e180c61f8a / btrfs defaults,subvol=root,compress=zstd,noatime 0 " >>/tmp/.fstab | |
| echo 0 >>/tmp/.fstab | |
| btrfs subvolume set-default "${_DESTDIR}"/"/" | |
| echo "Creating vfat on /dev/sda2, mounting to /mnt/install/boot..." | |
| mkfs.vfat -F32 -n ESP /dev/sda2 &>"${_LOG}" | |
| btrfs device scan &>"${_NO_LOG}" | |
| mkdir -p "/mnt/install""/boot" | |
| mount -t "vfat" -o "" "/dev/sda2" "/mnt/install""/boot" &>"${_LOG}" | |
| mkdir "/mnt/install/boot/EFI" | |
| echo "# DEVICE DETAILS: /dev/sda2 PARTUUID=18bdc0ad-f49b-4bb5-86ef-80d19f4223f0 PARTLABEL=ESP UUID=$(lsblk -rpno UUID /dev/sda2) LABEL=ESP" >> /tmp/.device-names | |
| echo -n "PARTUUID=18bdc0ad-f49b-4bb5-86ef-80d19f4223f0 /boot vfat defaults 0 " >>/tmp/.fstab | |
| echo 1 >>/tmp/.fstab | |
| ### pacman installation | |
| _chroot_mount | |
| mkdir -p "${_DESTDIR}/var/lib/pacman" | |
| echo "Installing base iptables-nft linux terminus-font..." | |
| pacman --root /mnt/install --cachedir=/mnt/install/var/cache/pacman/pkg --noconfirm -Sy base iptables-nft linux terminus-font &>"${_LOG}" | |
| sync | |
| _chroot_umount | |
| ### autoconfiguration | |
| _chroot_mount | |
| echo "Enable timezone setting on installed system..." | |
| cp -a /etc/localtime "${_DESTDIR}"/etc/localtime | |
| echo "Enable clock setting on installed system..." | |
| cp /etc/adjtime "${_DESTDIR}"/etc/adjtime | |
| echo "Enable network and disable wifi on installed system..." | |
| cp /etc/systemd/network/* "${_DESTDIR}"/etc/systemd/network/ &>"${_NO_LOG}" | |
| chroot "${_DESTDIR}" systemctl enable systemd-networkd &>"${_NO_LOG}" | |
| mkdir -p "${_DESTDIR}/etc/systemd/network.conf.d" | |
| cp /etc/systemd/network.conf.d/ipv6-privacy-extensions.conf "${_DESTDIR}"/etc/systemd/network.conf.d/ipv6-privacy-extensions.conf | |
| echo "Create new fstab on installed system..." | |
| sort /tmp/.device-names >>"${_DESTDIR}"/etc/fstab | |
| sd '^[^#]*' '' "${_DESTDIR}"/etc/fstab | |
| sort /tmp/.fstab >>"${_DESTDIR}"/etc/fstab | |
| echo "Enable performance ioscheduler settings on installed system..." | |
| cp /etc/udev/rules.d/60-ioschedulers.rules "${_DESTDIR}"/etc/udev/rules.d/60-ioschedulers.rules | |
| echo "Enable sysctl swap settings on installed system..." | |
| cp /etc/sysctl.d/99-sysctl.conf "${_DESTDIR}"/etc/sysctl.d/99-sysctl.conf | |
| echo "Enable pacman's GPG keyring files on installed system..." | |
| cp -ar /etc/pacman.d/gnupg "${_DESTDIR}"/etc/pacman.d &>"${_NO_LOG}" | |
| echo "Enable pacman mirror on installed system..." | |
| cat << EOF > /tmp/inst-mirrorlist | |
| # Mirror used during installation | |
| Server = http://mirror.archlinuxarm.org/$arch/$repo | |
| EOF | |
| cat "${_DESTDIR}"/etc/pacman.d/mirrorlist >> /tmp/inst-mirrorlist | |
| mv /tmp/inst-mirrorlist "${_DESTDIR}/etc/pacman.d/mirrorlist" | |
| echo "Setting keymap and font on installed system..." | |
| cp /etc/vconsole.conf "${_DESTDIR}"/etc/vconsole.conf | |
| echo "Set default hostname on installed system..." | |
| echo "myhostname" > "${_DESTDIR}"/etc/hostname | |
| echo "Set default locale on installed system..." | |
| cp /etc/locale.conf "${_DESTDIR}"/etc/locale.conf | |
| echo "Enable glibc locales based on locale.conf on installed system..." | |
| sd "^#en_US" "en_US" "${_DESTDIR}"/etc/locale.gen | |
| echo "Enable windowkeys in console on installed system..." | |
| cp "/etc/systemd/system/windowkeys.service" "${_DESTDIR}/etc/systemd/system/windowkeys.service" | |
| chroot "${_DESTDIR}" systemctl enable windowkeys &>"${_NO_LOG}" | |
| echo "Setup bash with custom options on installed system..." | |
| cp "${_DESTDIR}"/etc/skel/.bash* "${_DESTDIR}"/root/ | |
| echo ". /etc/profile.d/custom-bash-options.sh" >> "${_DESTDIR}/etc/skel/.bashrc" | |
| echo ". /etc/profile.d/custom-bash-options.sh" >> "${_DESTDIR}/root/.bashrc" | |
| cp /etc/profile.d/custom-bash-options.sh "${_DESTDIR}"/etc/profile.d/ | |
| _chroot_umount | |
| echo "Rebuilding glibc locales on installed system..." | |
| systemd-nspawn -q -D /mnt/install locale-gen &>"${_NO_LOG}" | |
| ### set root password | |
| echo "root" > /tmp/.password | |
| echo "root" >> /tmp/.password | |
| passwd -R "${_DESTDIR}" "root" < /tmp/.password &>"${_NO_LOG}" | |
| echo "New password set for root." | |
| rm /tmp/.password | |
| ### pacman installation | |
| _chroot_mount | |
| echo "Installing neovim..." | |
| pacman --root /mnt/install --cachedir=/mnt/install/var/cache/pacman/pkg --noconfirm -Sy neovim &>"${_LOG}" | |
| sync | |
| _chroot_umount | |
| ### hwdetect | |
| echo "Preconfiguring mkinitcpio settings on installed system..." | |
| sd "^MODULES=.*" "MODULES=(btrfs vfat crc32c)" "${_DESTDIR}"/etc/mkinitcpio.conf | |
| sd "^HOOKS=.*" "HOOKS=(systemd autodetect microcode modconf kms keyboard sd-vconsole block filesystems fsck)" "${_DESTDIR}"/etc/mkinitcpio.conf | |
| ### mkinitcpio disable fallback | |
| sd " 'fallback'" '' "${_DESTDIR}"/etc/mkinitcpio.d/*.preset | |
| rm -f "${_DESTDIR}/boot/initramfs-linux-fallback.img" | |
| ### mkinitcpio | |
| _chroot_mount | |
| echo "Running mkinitcpio on installed system..." | |
| _chroot_umount | |
| ### /mnt/install/etc/hostname file | |
| : > "/mnt/install/etc/hostname" | |
| echo 'omarchy-arm' >> /mnt/install/etc/hostname | |
| echo '' >> /mnt/install/etc/hostname | |
| ### /mnt/install/etc/pacman.conf file | |
| : > "/mnt/install/etc/pacman.conf" | |
| echo '#' >> /mnt/install/etc/pacman.conf | |
| echo '# /etc/pacman.conf' >> /mnt/install/etc/pacman.conf | |
| echo '#' >> /mnt/install/etc/pacman.conf | |
| echo '# See the pacman.conf(5) manpage for option and repository directives' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '#' >> /mnt/install/etc/pacman.conf | |
| echo '# GENERAL OPTIONS' >> /mnt/install/etc/pacman.conf | |
| echo '#' >> /mnt/install/etc/pacman.conf | |
| echo '[options]' >> /mnt/install/etc/pacman.conf | |
| echo '# The following paths are commented out with their default values listed.' >> /mnt/install/etc/pacman.conf | |
| echo '# If you wish to use different paths, uncomment and update the paths.' >> /mnt/install/etc/pacman.conf | |
| echo '#RootDir = /' >> /mnt/install/etc/pacman.conf | |
| echo '#DBPath = /var/lib/pacman/' >> /mnt/install/etc/pacman.conf | |
| echo '#CacheDir = /var/cache/pacman/pkg/' >> /mnt/install/etc/pacman.conf | |
| echo '#LogFile = /var/log/pacman.log' >> /mnt/install/etc/pacman.conf | |
| echo '#GPGDir = /etc/pacman.d/gnupg/' >> /mnt/install/etc/pacman.conf | |
| echo '#HookDir = /etc/pacman.d/hooks/' >> /mnt/install/etc/pacman.conf | |
| echo 'HoldPkg = pacman glibc' >> /mnt/install/etc/pacman.conf | |
| echo '#XferCommand = /usr/bin/curl -L -C - -f -o %o %u' >> /mnt/install/etc/pacman.conf | |
| echo '#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u' >> /mnt/install/etc/pacman.conf | |
| echo '#CleanMethod = KeepInstalled' >> /mnt/install/etc/pacman.conf | |
| echo 'Architecture = aarch64' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup' >> /mnt/install/etc/pacman.conf | |
| echo '#IgnorePkg =' >> /mnt/install/etc/pacman.conf | |
| echo '#IgnoreGroup =' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '#NoUpgrade =' >> /mnt/install/etc/pacman.conf | |
| echo '#NoExtract =' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '# Misc options' >> /mnt/install/etc/pacman.conf | |
| echo '#UseSyslog' >> /mnt/install/etc/pacman.conf | |
| echo '#Color' >> /mnt/install/etc/pacman.conf | |
| echo '#NoProgressBar' >> /mnt/install/etc/pacman.conf | |
| echo 'CheckSpace' >> /mnt/install/etc/pacman.conf | |
| echo '#VerbosePkgLists' >> /mnt/install/etc/pacman.conf | |
| echo 'ParallelDownloads = 5' >> /mnt/install/etc/pacman.conf | |
| echo 'DownloadUser = alpm' >> /mnt/install/etc/pacman.conf | |
| echo '#DisableSandbox' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '# By default, pacman accepts packages signed by keys that its local keyring' >> /mnt/install/etc/pacman.conf | |
| echo '# trusts (see pacman-key and its man page), as well as unsigned packages.' >> /mnt/install/etc/pacman.conf | |
| echo 'SigLevel = Required DatabaseOptional' >> /mnt/install/etc/pacman.conf | |
| echo 'LocalFileSigLevel = Optional' >> /mnt/install/etc/pacman.conf | |
| echo '#RemoteFileSigLevel = Required' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '# NOTE: You must run `pacman-key --init` before first using pacman; the local' >> /mnt/install/etc/pacman.conf | |
| echo '# keyring can then be populated with the keys of all official Arch Linux ARM' >> /mnt/install/etc/pacman.conf | |
| echo '# packagers with `pacman-key --populate archlinuxarm`.' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '#' >> /mnt/install/etc/pacman.conf | |
| echo '# REPOSITORIES' >> /mnt/install/etc/pacman.conf | |
| echo '# - can be defined here or included from another file' >> /mnt/install/etc/pacman.conf | |
| echo '# - pacman will search repositories in the order defined here' >> /mnt/install/etc/pacman.conf | |
| echo '# - local/custom mirrors can be added here or in separate files' >> /mnt/install/etc/pacman.conf | |
| echo '# - repositories listed first will take precedence when packages' >> /mnt/install/etc/pacman.conf | |
| echo '# have identical names, regardless of version number' >> /mnt/install/etc/pacman.conf | |
| echo '# - URLs will have $repo replaced by the name of the current repo' >> /mnt/install/etc/pacman.conf | |
| echo '# - URLs will have $arch replaced by the name of the architecture' >> /mnt/install/etc/pacman.conf | |
| echo '#' >> /mnt/install/etc/pacman.conf | |
| echo '# Repository entries are of the format:' >> /mnt/install/etc/pacman.conf | |
| echo '# [repo-name]' >> /mnt/install/etc/pacman.conf | |
| echo '# Server = ServerName' >> /mnt/install/etc/pacman.conf | |
| echo '# Include = IncludePath' >> /mnt/install/etc/pacman.conf | |
| echo '#' >> /mnt/install/etc/pacman.conf | |
| echo '# The header [repo-name] is crucial - it must be present and' >> /mnt/install/etc/pacman.conf | |
| echo '# uncommented to enable the repo.' >> /mnt/install/etc/pacman.conf | |
| echo '#' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '# The testing repositories are disabled by default. To enable, uncomment the' >> /mnt/install/etc/pacman.conf | |
| echo '# repo name header and Include lines. You can add preferred servers immediately' >> /mnt/install/etc/pacman.conf | |
| echo '# after the header, and they will be used before the default mirrors.' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '[core]' >> /mnt/install/etc/pacman.conf | |
| echo 'Include = /etc/pacman.d/mirrorlist' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '[extra]' >> /mnt/install/etc/pacman.conf | |
| echo 'Include = /etc/pacman.d/mirrorlist' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '[alarm]' >> /mnt/install/etc/pacman.conf | |
| echo 'Include = /etc/pacman.d/mirrorlist' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '[aur]' >> /mnt/install/etc/pacman.conf | |
| echo 'Include = /etc/pacman.d/mirrorlist' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '[archboot]' >> /mnt/install/etc/pacman.conf | |
| echo 'Server = https://pkg.archboot.com' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| echo '# An example of a custom package repository. See the pacman manpage for' >> /mnt/install/etc/pacman.conf | |
| echo '# tips on creating your own repositories.' >> /mnt/install/etc/pacman.conf | |
| echo '#[custom]' >> /mnt/install/etc/pacman.conf | |
| echo '#SigLevel = Optional TrustAll' >> /mnt/install/etc/pacman.conf | |
| echo '#Server = file:///home/custompkgs' >> /mnt/install/etc/pacman.conf | |
| echo '' >> /mnt/install/etc/pacman.conf | |
| ### pacman installation | |
| _chroot_mount | |
| echo "Installing dosfstools efivar efibootmgr..." | |
| pacman --root /mnt/install --cachedir=/mnt/install/var/cache/pacman/pkg --noconfirm -Sy dosfstools efivar efibootmgr &>"${_LOG}" | |
| sync | |
| _chroot_umount | |
| ### pacman installation | |
| _chroot_mount | |
| echo "Installing grub..." | |
| pacman --root /mnt/install --cachedir=/mnt/install/var/cache/pacman/pkg --noconfirm -Sy grub &>"${_LOG}" | |
| sync | |
| _chroot_umount | |
| ### grub uefi | |
| echo "Setting up GRUB(2) UEFI..." | |
| _chroot_mount | |
| chroot "${_DESTDIR}" grub-install --directory="/usr/lib/grub/arm64-efi" --target="arm64-efi" --efi-directory="/boot" --bootloader-id="GRUB" --recheck --debug &>"${_LOG}" | |
| cp -f "${_DESTDIR}/usr/share/grub/ter-u16n.pf2" "${_DESTDIR}/boot/grub/fonts/ter-u16n.pf2" | |
| ### /mnt/install/boot/grub/grub.cfg file | |
| : > "/mnt/install/boot/grub/grub.cfg" | |
| echo '# Include modules - required for boot' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod part_gpt' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod part_msdos' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod fat' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod fat' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod btrfs' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod btrfs' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod search_fs_file' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod search_fs_uuid' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod search_label' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod linux' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod chain' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'set pager=1' >> /mnt/install/boot/grub/grub.cfg | |
| echo '# set debug="all"' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'set locale_dir="${prefix}/locale"' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'if [ "${grub_platform}" == "efi" ]; then' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod all_video' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod efi_gop' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' if [ "${grub_cpu}" == "x86_64" ]; then' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod bli' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod efi_uga' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' elif [ "${grub_cpu}" == "i386" ]; then' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod bli' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod efi_uga' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' fi' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'elif [ "${grub_platform}" == "pc" ]; then' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod vbe' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod vga' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod png' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'fi' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod video_bochs' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod video_cirrus' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'insmod font' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'search --fs-uuid --no-floppy --set=usr_part --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5b92b2a5-2d23-4a3d-b93a-eb656243441b' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'search --fs-uuid --no-floppy --set=root_part --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 5b92b2a5-2d23-4a3d-b93a-eb656243441b' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'if [ -e "${prefix}/fonts/ter-u16n.pf2" ]; then' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' set _fontfile="${prefix}/fonts/ter-u16n.pf2"' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'else' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' if [ -e "(${root_part})/usr/share/grub/ter-u16n.pf2" ]; then' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' set _fontfile="(${root_part})/usr/share/grub/ter-u16n.pf2"' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' else' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' if [ -e "(${usr_part})/share/grub/ter-u16n.pf2" ]; then' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' set _fontfile="(${usr_part})/share/grub/ter-u16n.pf2"' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' fi' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' fi' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'fi' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'if loadfont "${_fontfile}" ; then' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' insmod gfxterm' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' set gfxmode="auto"' >> /mnt/install/boot/grub/grub.cfg | |
| echo '' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' terminal_input console' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' terminal_output gfxterm' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'fi' >> /mnt/install/boot/grub/grub.cfg | |
| echo '# DEVICE DETAILS: /dev/sda2 PARTUUID=18bdc0ad-f49b-4bb5-86ef-80d19f4223f0 PARTLABEL=ESP UUID=901C-F852 LABEL=ESP' >> /mnt/install/boot/grub/grub.cfg | |
| echo '# DEVICE DETAILS: /dev/sda3 PARTUUID=2d009c38-ea82-4451-a684-9fcaf9b1c5ad PARTLABEL=SWAP UUID=67c8a1de-ba26-4406-a3ef-4590f459c1e6 LABEL=SWAP' >> /mnt/install/boot/grub/grub.cfg | |
| echo '# DEVICE DETAILS: /dev/sda4 PARTUUID=ef790404-6d0a-4e23-a098-32e180c61f8a PARTLABEL=ARCH_LINUX_ROOT UUID=5b92b2a5-2d23-4a3d-b93a-eb656243441b LABEL=ARCH_ROOT' >> /mnt/install/boot/grub/grub.cfg | |
| echo '# (0) Arch Linux' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'menuentry "Arch Linux" {' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' set gfxpayload="keep"' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 901C-F852' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' linux /Image.gz root=PARTUUID=ef790404-6d0a-4e23-a098-32e180c61f8a rootfstype=btrfs rw rootflags=rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/root ' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' initrd /initramfs-linux.img' >> /mnt/install/boot/grub/grub.cfg | |
| echo '' >> /mnt/install/boot/grub/grub.cfg | |
| echo '}' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'if [ "${grub_platform}" == "efi" ]; then' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' menuentry "UEFI Firmware Setup" {' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' fwsetup' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' }' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'fi' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'menuentry "Reboot System" {' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' reboot' >> /mnt/install/boot/grub/grub.cfg | |
| echo '}' >> /mnt/install/boot/grub/grub.cfg | |
| echo 'menuentry "Poweroff System" {' >> /mnt/install/boot/grub/grub.cfg | |
| echo ' halt' >> /mnt/install/boot/grub/grub.cfg | |
| echo '}' >> /mnt/install/boot/grub/grub.cfg | |
| echo '' >> /mnt/install/boot/grub/grub.cfg | |
| ### fixing grub uuids | |
| _chroot_mount | |
| _BOOTDEV_FS_UUID_OLD="901C-F852" | |
| _ROOTDEV_FS_UUID_OLD="5b92b2a5-2d23-4a3d-b93a-eb656243441b" | |
| _USRDEV_FS_UUID_OLD="5b92b2a5-2d23-4a3d-b93a-eb656243441b" | |
| _BOOTDEV_FS_UUID="$(chroot /mnt/install grub-probe --target="fs_uuid" "/boot" 2>"${_NO_LOG}")" | |
| _ROOTDEV_FS_UUID="$(chroot /mnt/install grub-probe --target="fs_uuid" "/" 2>"${_NO_LOG}")" | |
| _USRDEV_FS_UUID="$(chroot /mnt/install grub-probe --target="fs_uuid" "/usr" 2>"${_NO_LOG}")" | |
| _ESP_DEV_FS_UUID_OLD="901C-F852" | |
| _ESP_DEV_FS_UUID="$(chroot /mnt/install grub-probe --target="fs_uuid" "/boot" 2>"${_NO_LOG}")" | |
| sd "${_ESP_DEV_FS_UUID_OLD}" "${_ESP_DEV_FS_UUID}" "${_DESTDIR}/boot/grub/grub.cfg" | |
| sd "${_BOOTDEV_FS_UUID_OLD}" "${_BOOTDEV_FS_UUID}" "${_DESTDIR}/boot/grub/grub.cfg" | |
| sd "${_ROOTDEV_FS_UUID_OLD}" "${_ROOTDEV_FS_UUID}" "${_DESTDIR}/boot/grub/grub.cfg" | |
| sd "${_USRDEV_FS_UUID_OLD}" "${_USRDEV_FS_UUID}" "${_DESTDIR}/boot/grub/grub.cfg" | |
| _chroot_umount | |
| ### pacman hook | |
| mkdir -p "${_DESTDIR}"/etc/pacman.d/hooks | |
| ### /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook file | |
| : > "/mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook" | |
| echo '[Trigger]' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| echo 'Type = Package' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| echo 'Operation = Upgrade' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| echo 'Target = grub' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| echo '' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| echo '[Action]' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| echo 'Description = Update GRUB after upgrade...' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| echo 'When = PostTransaction' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| echo 'Exec = /usr/bin/sh -c "grub-install --directory='/usr/lib/grub/arm64-efi' --target='arm64-efi' --efi-directory='/boot' --bootloader-id='GRUB' --recheck"' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| echo '' >> /mnt/install/etc/pacman.d/hooks/999-grub-uefi.hook | |
| ### default uefi bootloader | |
| mkdir -p "${_DESTDIR}/boot/EFI/BOOT" | |
| rm -f "${_DESTDIR}/boot/EFI/BOOT/BOOTAA64.EFI" | |
| cp -f "${_DESTDIR}/boot/EFI/grub/grubaa64.efi" "${_DESTDIR}/boot/EFI/BOOT/BOOTAA64.EFI" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment