You are not logged in.

#1 2025-11-04 05:14:38

Archeus
Member
Registered: 2025-11-02
Posts: 7

[SOLVED] Installing Arch with a custom script I made

So, I am trying a mix of manual and automated install by essentially writing a custom script to do the installation for me, but I am completely lost on how to do the whole adding loaders section (I want to use systemd-boot).
Most of the videos I have seen use GRUB as the boot loader, but I went with systemd-boot because it was "simpler".
This is my script so far, I have put the boot loader section between two #BOOT LOADER comments to make it stand out.

#!/usr/bin/env bash
set -e

DISK="/dev/nvme0n1"
TIMEZONE="US/Eastern"
LOCALE="en_US.UTF-8"
HOSTNAME="archlinux"
PASSWORD="password"

parted -s $DISK mklabel gpt
parted -s $DISK mkpart primary fat32 1MiB 513MiB
parted -s $DISK set 1 esp on
parted -s $DISK mkpart primary linux-swap 513MiB 1537MiB
parted -s $DISK mkpart primary ext4 1537MiB 100%

mkfs.fat -F 32 "${DISK}p1"
mkswap "${DISK}p2"
mkfs.ext4 "${DISK}p3"

mount "${DISK}p3" /mnt
swapon "${DISK}p2"
mount --mkdir "${DISK}p1" /mnt/boot
PARTUUID=$(blkid -s PARTUUID -o value "${DISK}p3")

pacstrap -K /mnt base linux linux-firmware
genfstab -U /mnt >> /mnt/etc/fstab

arch-chroot /mnt /usr/bin/env bash <<ARCH-CHROOT
ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
hwclock --systohc
sed -i "s/^#$LOCALE /$LOCALE /" /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "$HOSTNAME" > /etc/hostname
echo "root:$PASSWORD" | chpasswd

bootctl install
printf "%s\n" \
"default arch.conf" \
"timeout 4" \
"console-mode max" \
"editor no" \
> /boot/loader/loader.conf

printf "%s\n" \
"title Arch Linux" \
"linux /vmlinuz-linux" \
"initrd /initramfs-linux.img" \
"options root=PARTUUID=$PARTUUID rw" \
> /boot/loader/entries/arch.conf
bootctl

exit
ARCH-CHROOT
umount -R /mnt
echo "Rebooting in 5 seconds..."
sleep 5
reboot

Edit: Added code tags and minor spelling mistake.
Edit: Fixed, cleaned up and added more variable to the script.
Edit: Now it is fixed, for real.

Last edited by Archeus (2025-11-05 09:00:02)

Offline

#2 2025-11-04 07:40:18

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 69,973

Re: [SOLVED] Installing Arch with a custom script I made

Please use [code][/code] tags. Edit your post in this regard.

Most of the video I have seen

… you best try to forget as hard as possible.
See https://wiki.archlinux.org/title/Installation_guide => https://wiki.archlinux.org/title/Instal … oot_loader => https://wiki.archlinux.org/title/Arch_b … oot_loader => https://wiki.archlinux.org/title/Systemd-boot

Offline

#3 2025-11-04 12:47:17

cryptearth
Member
Registered: 2024-02-03
Posts: 1,793

Re: [SOLVED] Installing Arch with a custom script I made

Archeus wrote:
echo "Mounting the file systems..."
mount --mkdir "${DISK}p1" /mnt/boot
swapon "${DISK}p2"
mount "${DISK}p3" /mnt
echo "Done!"

you obviously have not tested that as this does not what you think it does

also, without the intentions if starting an argue: your question is "how to create the required conf" - how exactly is this easier compared to using grub and its config generator grub-mkconfig which solves exactly that problem for you?

(before someone else jumps the gun: this is not about my personal opinion but rather OPs own words systemd-boot being simpler then grub while that choice is the very reason for this thread which when just sticking to grub would have solved this - ergo: i question OPs point of view about his choice being the simpler one when it cause them the issue in the first place)

Offline

#4 2025-11-04 22:55:51

Archeus
Member
Registered: 2025-11-02
Posts: 7

Re: [SOLVED] Installing Arch with a custom script I made

seth wrote:

If you would please consult the image...
https://i.imgur.com/yVy3YR0.png

Last edited by V1del (2025-11-05 01:13:45)

Offline

#5 2025-11-04 23:17:40

Archeus
Member
Registered: 2025-11-02
Posts: 7

Re: [SOLVED] Installing Arch with a custom script I made

cryptearth wrote:
Archeus wrote:
echo "Mounting the file systems..."
mount --mkdir "${DISK}p1" /mnt/boot
swapon "${DISK}p2"
mount "${DISK}p3" /mnt
echo "Done!"

you obviously have not tested that as this does not what you think it does

also, without the intentions if starting an argue: your question is "how to create the required conf" - how exactly is this easier compared to using grub and its config generator grub-mkconfig which solves exactly that problem for you?

(before someone else jumps the gun: this is not about my personal opinion but rather OPs own words systemd-boot being simpler then grub while that choice is the very reason for this thread which when just sticking to grub would have solved this - ergo: i question OPs point of view about his choice being the simpler one when it cause them the issue in the first place)

But I have, in fact, tested that it does what I think it does (I now understand the problem thanks to frostschutz)
https://i.imgur.com/Si4Ba3U.png

True, it is not easier compared to using GRUB, it is merely me wanting to use systemd-boot over GRUB, nothing more. Since systemd-boot already comes with the base package is it perfect for a minimal setup, had I wanted to use GRUB I would not be asking the question as to how to script the steps required to configure systemd-boot.

Replace oversized image -- V1del

Last edited by Archeus (2025-11-05 02:05:09)

Offline

#6 2025-11-04 23:45:51

frostschutz
Member
Registered: 2013-11-15
Posts: 1,578

Re: [SOLVED] Installing Arch with a custom script I made

/mnt/boot will be invisible as its hidden under /mnt which was mounted later

have to mount /mnt first then /mnt/boot afterwards

Offline

#7 2025-11-05 00:48:55

Archeus
Member
Registered: 2025-11-02
Posts: 7

Re: [SOLVED] Installing Arch with a custom script I made

frostschutz wrote:

/mnt/boot will be invisible as its hidden under /mnt which was mounted later

have to mount /mnt first then /mnt/boot afterwards

Alright, I will look into it.

Edit: I see the problem now, my mistake.

Last edited by Archeus (2025-11-05 01:05:08)

Offline

#8 2025-11-05 01:14:31

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,857

Re: [SOLVED] Installing Arch with a custom script I made

Please don't embed huge images directly and just link to them instead in the future. If you see the issue and your original question [SOLVED], can you mark it as such by editing the title in your first post?

Offline

#9 2025-11-05 01:56:18

Archeus
Member
Registered: 2025-11-02
Posts: 7

Re: [SOLVED] Installing Arch with a custom script I made

LET'S GO
https://i.imgur.com/vFUJ74N.png
https://i.imgur.com/x5edEmC.png

Now the only issue remaining is the fact that it is not 100% unattended, I still had to create and edit the arch.conf manually, which is still an issue for an unattended install.
So if any has any idea as to how to do so with just commands, I would appreciate it.

Last edited by Archeus (2025-11-05 02:00:56)

Offline

#10 2025-11-05 01:57:39

Archeus
Member
Registered: 2025-11-02
Posts: 7

Re: [SOLVED] Installing Arch with a custom script I made

V1del wrote:

Please don't embed huge images directly and just link to them instead in the future. If you see the issue and your original question [SOLVED], can you mark it as such by editing the title in your first post?

Noted.

Offline

#11 2025-11-05 07:54:46

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 69,973

Re: [SOLVED] Installing Arch with a custom script I made

I still had to create and edit the arch.conf manually

printf into /boot/loader/loader.conf works but into  /boot/loader/entries/arch.conf does not?
Do you create /boot/loader/entries ?

Offline

#12 2025-11-05 08:32:41

Archeus
Member
Registered: 2025-11-02
Posts: 7

Re: [SOLVED] Installing Arch with a custom script I made

seth wrote:

I still had to create and edit the arch.conf manually

printf into /boot/loader/loader.conf works but into  /boot/loader/entries/arch.conf does not?
Do you create /boot/loader/entries ?

Yes, I managed to create an entry with this:

PARTUUID=$(blkid -s PARTUUID -o value "${DISK}p3")
printf "%s\n" \
"title Arch Linux" \
"linux /vmlinuz-linux" \
"initrd /initramfs-linux.img" \
"options root=PARTUUID=$PARTUUID rw" \
> /boot/loader/entries/arch.conf

The issue I had is basically resolved, I will simply continue to fix/improve the script.
(Moved the PARTUUID variable outside of arch-chroot, otherwise it won't work)

Last edited by Archeus (2025-11-05 09:01:49)

Offline

Board footer

Powered by FluxBB