Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions hack/scripts/expand-root-volume.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -x

# 1. Rescan physical paths
for dev in /sys/block/sd*/device/rescan; do echo 1 > "$dev"; done
sleep 2

# 2. Resize Multipath Map
multipathd -k"resize map mpatha"
sleep 2

# 3. Handle GPT 'Fix' separately and silently
# We pipe 'Fix' to a print command. If there's no error, Fix is ignored.
printf "Fix\n" | parted /dev/mapper/mpatha ---pretend-input-tty print > /dev/null 2>&1

# 4. Resize the partition
printf "Yes\n" | parted /dev/mapper/mpatha ---pretend-input-tty resizepart 2 100%

# 5. Refresh mappings
kpartx -u /dev/mapper/mpatha
udevadm settle

# 6. Grow Filesystem
xfs_growfs /

# 7. Flag completion
touch /var/lib/pac-root-expanded
25 changes: 23 additions & 2 deletions hack/scripts/image-prep.template.static
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ subscription-manager register --force --auto-attach --username={{ .RHNUser }} --

yum update -y && yum install -y yum-utils
yum install -y cloud-init firewalld
yum install -y device-mapper-multipath parted kpartx
rm -rf /etc/systemd/system/multi-user.target.wants/firewalld.service
rpm -vih --nodeps https://public.dhe.ibm.com/software/server/POWER/Linux/yum/download/ibm-power-repo-latest.noarch.rpm
sed -i 's/^more \/opt\/ibm\/lop\/notice/#more \/opt\/ibm\/lop\/notice/g' /opt/ibm/lop/configure
Expand Down Expand Up @@ -56,13 +57,32 @@ done
grub2-mkconfig -o /boot/grub2/grub.cfg

curl https://raw.githubusercontent.com/IBM/power-access-cloud/refs/heads/main/hack/scripts/prep-pac.sh -o /usr/local/bin/prep-pac.sh
curl https://raw.githubusercontent.com/IBM/power-access-cloud/refs/heads/main/hack/scripts/expand-root-volume.sh -o /usr/local/bin/expand-root-volume.sh
chmod +x /usr/local/bin/prep-pac.sh
chmod +x /usr/local/bin/expand-root-volume.sh

cat <<EOT >> /usr/lib/systemd/system/expand-root-volume.service
[Unit]
Description=Expand multipath root volume on first boot
DefaultDependencies=no
After=local-fs.target systemd-udev-settle.service multipathd.service
Before=prep-pac.service cloud-final.service
ConditionPathExists=!/var/lib/pac-root-expanded

[Service]
ExecStart=/usr/local/bin/expand-root-volume.sh
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOT

cat <<EOT >> /usr/lib/systemd/system/prep-pac.service
[Unit]
Description=Prepare the machine for the Power Access Cloud
Requires=cloud-final.service
After=cloud-final.service
Requires=cloud-final.service expand-root-volume.service
After=cloud-final.service expand-root-volume.service

[Service]
ExecStart=/usr/local/bin/prep-pac.sh
Expand All @@ -75,6 +95,7 @@ RemainAfterExit=yes
WantedBy=cloud-init.target
EOT

systemctl enable expand-root-volume.service
systemctl enable prep-pac.service
#mkdir -p /etc/cloud/cloud.cfg.d
#cat <<EOT >> /etc/cloud/cloud.cfg.d/99-custom-networking.cfg
Expand Down
Loading