Add ability to grow root partition + filesystem
This commit is contained in:
parent
21076fd535
commit
f8b5d82ac5
14
arch.pkr.hcl
14
arch.pkr.hcl
@ -82,6 +82,20 @@ build {
|
||||
destination = "/mnt/etc/systemd/network/99-dhcp-wildcard.network"
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
source = "files/grow-root"
|
||||
destination = "/usr/local/sbin/grow-root"
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
inline = ["chmod +x /usr/local/sbin/grow-root"]
|
||||
}
|
||||
|
||||
provisioner "file" {
|
||||
source = "files/grow-root.service"
|
||||
destination = "/etc/systemd/system/grow-root.service"
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
pause_before = "10s"
|
||||
scripts = [
|
||||
|
16
files/grow-root
Normal file
16
files/grow-root
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
dev="$(findmnt -nfvo SOURCE -- "/")"
|
||||
|
||||
# If it's a partition, expand that first using growpart.
|
||||
if [ "$(lsblk -ndo TYPE -- "$dev")" = part ]; then
|
||||
disk="$(lsblk -ndpo PKNAME -- "$dev")"
|
||||
partnum="${dev##*[!0-9]}"
|
||||
growpart "$disk" "$partnum" || { [ $? -ne 1 ] && exit 1; }
|
||||
fi
|
||||
|
||||
# Inform kernel of new partition
|
||||
partprobe
|
||||
|
||||
# Expand the filesystem.
|
||||
resize2fs -- "$dev" || exit 1
|
9
files/grow-root.service
Normal file
9
files/grow-root.service
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Grows the root partition and filesystem to match disk size
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/sbin/grow-root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -4,8 +4,8 @@ set -eux
|
||||
pacman-key --init
|
||||
|
||||
# Install the system
|
||||
pacstrap -K /mnt base linux linux-firmware rng-tools grub sudo \
|
||||
openssh ufw git vim python-pip nomad nomad-driver-nspawn
|
||||
pacstrap -K /mnt base linux linux-firmware rng-tools grub parted sudo \
|
||||
openssh ufw git vim cloud-utils python-pip nomad nomad-driver-nspawn
|
||||
|
||||
# Clear the cache
|
||||
arch-chroot /mnt pacman -Scc --noconfirm
|
||||
|
Loading…
Reference in New Issue
Block a user