From f98dd12ef9a5a48cc98e9dc7a4797c1993268124 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 13 Sep 2018 17:40:56 -0400 Subject: [PATCH] Rework partitioning to drop LVM This is part of https://github.com/coreos/fedora-coreos-tracker/issues/18 For now, this just drops LVM to make it easier to use Ignition to both build images, and help enable ignition-disks. Note that I tried to use a separate `/var` but this currently does not work with our Ignition, which would need to learn how to mount `/var` in the initramfs. We add growpart logic adapted from https://github.com/projectatomic/container-storage-setup/pull/275/commits/d4994e68408f7a715d7741b25fcf9c8332b09414 (Probably at some point should teach growpart how to grow based on mount point paths...) --- fedora-coreos-base.yaml | 33 ++++++++++++++++++++++++++++++++- image.ks | 12 +++--------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/fedora-coreos-base.yaml b/fedora-coreos-base.yaml index e7aca06629..50e21d1bda 100644 --- a/fedora-coreos-base.yaml +++ b/fedora-coreos-base.yaml @@ -49,10 +49,41 @@ postprocess: echo '%sudo ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/coreos-sudo-group # We're not using resolved yet rm -f /usr/lib/systemd/system/systemd-resolved.service + # https://github.com/coreos/fedora-coreos-tracker/issues/18 + # See also image.ks. + # Growpart /, until we can fix Ignition for separate /var + # (And eventually we want ignition-disks) + cat > /usr/libexec/coreos-growpart << 'EOF' + #!/bin/bash + set -euo pipefail + path=$1 + shift + majmin=$(findmnt -nvr -o MAJ:MIN $path) + devpath=$(realpath /sys/dev/block/$majmin) + partition=$(cat $devpath/partition) + parent_path=$(dirname $devpath) + parent_device=/dev/$(basename ${parent_path}) + # TODO: make this idempotent, and don't error out if + # we can't resize. + growpart ${parent_device} ${partition} || true + touch /var/lib/coreos-growpart.stamp + EOF + chmod a+x /usr/libexec/coreos-growpart + cat > /usr/lib/systemd/system/coreos-growpart.service <<'EOF' + [Unit] + ConditionPathExists=!/var/lib/coreos-growpart.stamp + [Service] + ExecStart=/usr/libexec/coreos-growpart / + RemainAfterExit=yes + Before=sshd.service + [Install] + WantedBy=multi-user.target + EOF cat >/usr/lib/systemd/system-preset/42-coreos.preset << EOF # Presets here that eventually should live in the generic fedora presets # This one is from https://github.com/dustymabe/ignition-dracut enable coreos-firstboot-complete.service + enable coreos-growpart.service EOF # Let's have a non-boring motd, just like CL (although theirs is more subdued # nowadays compared to early versions with ASCII art). One thing we do here @@ -79,7 +110,7 @@ packages: - bridge-utils nfs-utils biosdevname iptables-services - NetworkManager dnsmasq hostname # Storage - - container-storage-setup cloud-utils-growpart + - cloud-utils-growpart - lvm2 iscsi-initiator-utils sg3_utils - device-mapper-multipath - xfsprogs e2fsprogs mdadm diff --git a/image.ks b/image.ks index b1c89c832e..d4919467eb 100644 --- a/image.ks +++ b/image.ks @@ -24,10 +24,10 @@ clearpart --initlabel --all # - $coreos_firstboot # This is actually a GRUB variable bootloader --timeout=1 --append="no_timer_check console=ttyS0,115200n8 console=tty0 net.ifnames=0 biosdevname=0 ip=dhcp rd.neednet=1 rw $coreos_firstboot" +# https://github.com/coreos/fedora-coreos-tracker/issues/18 +# See also coreos-growpart.service defined in fedora-coreos-base.yaml part /boot --size=300 --fstype="xfs" --label=boot -part pv.01 --grow -volgroup coreos pv.01 -logvol / --size=3000 --fstype="xfs" --name=root --vgname=coreos --label=root +part / --size=3000 --fstype="xfs" --label=root --grow reboot @@ -36,12 +36,6 @@ reboot # https://github.com/dustymabe/ignition-dracut/pull/12 touch /boot/coreos-firstboot -# Configure docker-storage-setup to resize the partition table on boot -# https://github.com/projectatomic/docker-storage-setup/pull/25 -echo 'GROWPART=true' >> /etc/sysconfig/docker-storage-setup -# https://pagure.io/atomic-wg/issue/343 -echo 'ROOT_SIZE=+100%FREE' >> /etc/sysconfig/docker-storage-setup - # Remove any persistent NIC rules generated by udev rm -vf /etc/udev/rules.d/*persistent-net*.rules