Skip to content

Commit 85b8f00

Browse files
committed
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.
1 parent 5d2ef52 commit 85b8f00

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

build-arch-gce

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ append_gce_repo() {
7676
cp /etc/pacman.conf "$work_dir"
7777
append_gce_repo "$work_dir/pacman.conf"
7878
pacstrap -G -M -C "$work_dir/pacman.conf" -- "$mount_dir" \
79-
base linux grub dosfstools e2fsprogs dhclient openssh sudo google-compute-engine growpartfs
79+
base linux grub dosfstools e2fsprogs dhclient openssh sudo google-compute-engine
8080
append_gce_repo "$mount_dir/etc/pacman.conf"
8181

8282
echo '- Configuring fstab.'
@@ -90,7 +90,7 @@ print_fstab() {
9090
printf '\n\n'
9191
} >> "$mount_dir/etc/fstab"
9292
{
93-
print_fstab root "$root_uuid" / ext4 rw,discard,errors=remount-ro 0 1
93+
print_fstab root "$root_uuid" / ext4 rw,discard,errors=remount-ro,x-systemd.growfs 0 1
9494
print_fstab efi "$efi_uuid" /efi vfat uid=root,gid=root,umask=022,showexec 0 0
9595
}
9696

@@ -147,14 +147,26 @@ arch-chroot -- "$mount_dir" /bin/bash -s <<-'EOS'
147147
EOF
148148
systemctl --quiet enable pacman-init.service
149149
150+
echo '-- Configuring systemd-repart.'
151+
mkdir /etc/repart.d
152+
cat <<-'EOF' > /etc/repart.d/root.conf
153+
[Partition]
154+
Type=root
155+
EOF
156+
mkdir /etc/systemd/system/systemd-repart.service.d
157+
cat <<-'EOF' > /etc/systemd/system/systemd-repart.service.d/override.conf
158+
[Unit]
159+
Before=systemd-growfs@-.service
160+
EOF
161+
150162
echo '-- Enabling other services.'
151-
systemctl --quiet enable dhclient@eth0.service growpartfs@-.service
163+
systemctl --quiet enable dhclient@eth0.service
152164
153165
echo '-- Configuring initcpio.'
154166
gawk -i assert -i inplace '
155167
/^MODULES=/ { $0 = "MODULES=(virtio_pci virtio_scsi sd_mod ext4)"; ++f1 }
156168
/^BINARIES=/ { $0 = "BINARIES=(fsck fsck.ext4)"; ++f2 }
157-
/^HOOKS=/ { $0 = "HOOKS=(base modconf)"; ++f3 }
169+
/^HOOKS=/ { $0 = "HOOKS=(systemd modconf)"; ++f3 }
158170
{ print } END { assert(f1 * f2 * f3 == 1, "f == 1") }' /etc/mkinitcpio.conf
159171
gawk -i assert -i inplace '
160172
/^PRESETS=/ { $0 = "PRESETS=(default)"; ++f }

0 commit comments

Comments
 (0)