Skip to content
Snippets Groups Projects
Verified Commit 6a1a1f2a authored by David Runge's avatar David Runge :chipmunk:
Browse files

feat: force unmount /dev, /proc, /sys after arch-chroot

It appears arch-chroot does not clean up after itself:
https://github.com/archlinux/arch-install-scripts/issues/6
parent b4cb1e92
No related branches found
Tags 20191011
No related merge requests found
Pipeline #60608 failed
......@@ -7,7 +7,13 @@ function pre() {
# https://gitlab.archlinux.org/archlinux/arch-boxes/-/issues/117
rm "${MOUNT}/etc/machine-id"
sleep 5
printf "Add swap\n"
arch-chroot "${MOUNT}" /usr/bin/btrfs subvolume create /swap
sleep 5
set +e
umount -R "${MOUNT}/"{dev,proc,sys}
set -e
chattr +C "${MOUNT}/swap"
chmod 0700 "${MOUNT}/swap"
fallocate -l 512M "${MOUNT}/swap/swapfile"
......@@ -15,15 +21,21 @@ function pre() {
mkswap -U clear "${MOUNT}/swap/swapfile"
echo -e "/swap/swapfile none swap defaults 0 0" >>"${MOUNT}/etc/fstab"
sleep 5
printf "Run systemd-firstboot\n"
arch-chroot "${MOUNT}" /usr/bin/systemd-firstboot --locale=C.UTF-8 --timezone=UTC --hostname=archlinux --keymap=us
ln -sf /run/systemd/resolve/stub-resolv.conf "${MOUNT}/etc/resolv.conf"
sleep 5
set +e
umount -R "${MOUNT}/"{dev,proc,sys}
set -e
printf "Add pacman-init.service\n"
# Setup pacman-init.service for clean pacman keyring initialization
cat <<EOF >"${MOUNT}/etc/systemd/system/pacman-init.service"
[Unit]
Description=Initializes Pacman keyring
Before=sshd.service cloud-final.service archlinux-keyring-wkd-sync.service
After=time-sync.target
ConditionFirstBoot=yes
[Service]
......@@ -36,6 +48,7 @@ ExecStart=/usr/bin/pacman-key --populate
WantedBy=multi-user.target
EOF
printf "Add pacman mirrorlist\n"
# Setup mirror list to Geo IP mirrors
cat <<EOF >"${MOUNT}/etc/pacman.d/mirrorlist"
Server = https://geo.mirror.pkgbuild.com/\$repo/os/\$arch
......@@ -43,6 +56,8 @@ Server = https://mirror.rackspace.com/archlinux/\$repo/os/\$arch
Server = https://mirror.leaseweb.net/archlinux/\$repo/os/\$arch
EOF
sleep 5
printf "Enable systemd services\n"
# enabling important services
arch-chroot "${MOUNT}" /bin/bash -e <<EOF
source /etc/profile
......@@ -50,15 +65,30 @@ systemctl enable sshd
systemctl enable systemd-networkd
systemctl enable systemd-resolved
systemctl enable systemd-timesyncd
systemctl enable systemd-time-wait-sync
systemctl enable pacman-init.service
EOF
sleep 5
set +e
umount -R "${MOUNT}/"{dev,proc,sys}
set -e
sleep 5
printf "Install GRUB for BIOS\n"
# GRUB
arch-chroot "${MOUNT}" /usr/bin/grub-install --target=i386-pc "${LOOPDEV}"
sleep 5
set +e
umount -R "${MOUNT}/"{dev,proc,sys}
set -e
sed -i 's/^GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=1/' "${MOUNT}/etc/default/grub"
# setup unpredictable kernel names
sed -i 's/^GRUB_CMDLINE_LINUX=.*$/GRUB_CMDLINE_LINUX="net.ifnames=0"/' "${MOUNT}/etc/default/grub"
sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"rootflags=compress-force=zstd\"/' "${MOUNT}/etc/default/grub"
sleep 5
printf "Create GRUB config\n"
arch-chroot "${MOUNT}" /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg
sleep 5
set +e
umount -R "${MOUNT}/"{dev,proc,sys}
set -e
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment