aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Castelli <lcastelli@gmail.com>2022-07-02 12:24:36 +0000
committerLorenzo Castelli <lcastelli@google.com>2022-07-02 14:42:26 +0200
commit85b8f0073af7ae233c80483dbe275088d5940f63 (patch)
tree7079164f6d4ec05062b32ff6466686a4e01fff13
parent5d2ef52555c6b7d907f70bbf54dfaa4a6acf6fb8 (diff)
downloadcompute-archlinux-image-builder-85b8f0073af7ae233c80483dbe275088d5940f63.tar.xz
Replaces growpartfs with the systemd equivalent functionalities.
This configures systemd-repart to resize the root partition, and systemd-growfs to resize the root filesystem. Both services run early in the boot process, and expect the /dev filesystem to be properly populated. This was only happening later in the bootup process in the previous configuration, as udev was not started in the minimal initrd that was used, and as a result they would both fail. To fix this, systemd is now enabled in initrd, so that udev is started there and we get a more complete system earlier. This makes initrd somewhat bigger, but it probably makes the setup more robust in general.
-rwxr-xr-xbuild-arch-gce20
1 files changed, 16 insertions, 4 deletions
diff --git a/build-arch-gce b/build-arch-gce
index 5169684..d92bdcf 100755
--- a/build-arch-gce
+++ b/build-arch-gce
@@ -76,7 +76,7 @@ append_gce_repo() {
cp /etc/pacman.conf "$work_dir"
append_gce_repo "$work_dir/pacman.conf"
pacstrap -G -M -C "$work_dir/pacman.conf" -- "$mount_dir" \
- base linux grub dosfstools e2fsprogs dhclient openssh sudo google-compute-engine growpartfs
+ base linux grub dosfstools e2fsprogs dhclient openssh sudo google-compute-engine
append_gce_repo "$mount_dir/etc/pacman.conf"
echo '- Configuring fstab.'
@@ -90,7 +90,7 @@ print_fstab() {
printf '\n\n'
} >> "$mount_dir/etc/fstab"
{
- print_fstab root "$root_uuid" / ext4 rw,discard,errors=remount-ro 0 1
+ print_fstab root "$root_uuid" / ext4 rw,discard,errors=remount-ro,x-systemd.growfs 0 1
print_fstab efi "$efi_uuid" /efi vfat uid=root,gid=root,umask=022,showexec 0 0
}
@@ -147,14 +147,26 @@ arch-chroot -- "$mount_dir" /bin/bash -s <<-'EOS'
EOF
systemctl --quiet enable pacman-init.service
+ echo '-- Configuring systemd-repart.'
+ mkdir /etc/repart.d
+ cat <<-'EOF' > /etc/repart.d/root.conf
+ [Partition]
+ Type=root
+ EOF
+ mkdir /etc/systemd/system/systemd-repart.service.d
+ cat <<-'EOF' > /etc/systemd/system/systemd-repart.service.d/override.conf
+ [Unit]
+ Before=systemd-growfs@-.service
+ EOF
+
echo '-- Enabling other services.'
- systemctl --quiet enable dhclient@eth0.service growpartfs@-.service
+ systemctl --quiet enable dhclient@eth0.service
echo '-- Configuring initcpio.'
gawk -i assert -i inplace '
/^MODULES=/ { $0 = "MODULES=(virtio_pci virtio_scsi sd_mod ext4)"; ++f1 }
/^BINARIES=/ { $0 = "BINARIES=(fsck fsck.ext4)"; ++f2 }
- /^HOOKS=/ { $0 = "HOOKS=(base modconf)"; ++f3 }
+ /^HOOKS=/ { $0 = "HOOKS=(systemd modconf)"; ++f3 }
{ print } END { assert(f1 * f2 * f3 == 1, "f == 1") }' /etc/mkinitcpio.conf
gawk -i assert -i inplace '
/^PRESETS=/ { $0 = "PRESETS=(default)"; ++f }