From 196088e777f72e23e9fe1e5f0bc8e98003465f2d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 6 Feb 2019 15:04:04 +0000 Subject: [PATCH] Switch to GPT partitioning With a `/boot` partition. But today Anaconda doesn't expose an API to explicitly label it `/boot` (or even change the filesystem type). We'll live with that for now. Prep for UEFI. --- src/gf-anaconda-cleanup | 12 ++++++++++++ src/image-base.ks | 4 ++-- src/libguestfish.sh | 16 ++++++++++++++-- src/virt-install | 5 ++++- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/gf-anaconda-cleanup b/src/gf-anaconda-cleanup index 8a2c93f459..bbb9622379 100755 --- a/src/gf-anaconda-cleanup +++ b/src/gf-anaconda-cleanup @@ -9,8 +9,20 @@ dn=$(dirname "$0") . "${dn}"/libguestfish.sh src="$1" +shift +skip_partition_fixups= +if [ "${1:-}" = "--skip-partition-fixups" ]; then + skip_partition_fixups=1 + shift +fi set -x +if [ "${skip_partition_fixups}" != 1 ]; then + coreos_gf_run "${src}" + # We don't have a way to do this with Anaconda/kickstart right now. + # This bootstraps us to be able to do all of the mounts. + coreos_gf set-label /dev/sda2 boot +fi coreos_gf_run_mount "${src}" # Both of these are written by Anaconda diff --git a/src/image-base.ks b/src/image-base.ks index d2d2f1cf55..4f98391bf5 100644 --- a/src/image-base.ks +++ b/src/image-base.ks @@ -18,13 +18,13 @@ firewall --disabled network --bootproto=dhcp --onboot=on zerombr -clearpart --initlabel --all +clearpart --initlabel --all --disklabel=gpt # https://github.com/coreos/fedora-coreos-tracker/issues/18 # See also coreos-growpart.service defined in fedora-coreos-base.yaml # You can change this partition layout, but note that the `boot` and `root` # filesystem labels are currently mandatory (they're interpreted by coreos-assembler). -part /boot --size=300 --fstype="xfs" --label=boot +reqpart --add-boot # Note no reflinks for /boot since the bootloader may not understand them part / --size=3000 --fstype="xfs" --label=root --grow --mkfsoptions="-m reflink=1" diff --git a/src/libguestfish.sh b/src/libguestfish.sh index 7041c3ae7d..18cb041b05 100755 --- a/src/libguestfish.sh +++ b/src/libguestfish.sh @@ -9,6 +9,9 @@ export LIBGUESTFS_BACKEND=direct # http://libguestfs.org/guestfish.1.html#using-remote-control-robustly-from-shell-scripts GUESTFISH_PID= coreos_gf_launch() { + if [ -n "$GUESTFISH_PID" ]; then + return + fi local src=$1 shift local guestfish @@ -32,11 +35,20 @@ coreos_gf() { guestfish --remote -- "$@" } +GUESTFISH_RUNNING= +coreos_gf_run() { + if [ -n "$GUESTFISH_RUNNING" ]; then + return + fi + coreos_gf_launch "$@" + coreos_gf run + GUESTFISH_RUNNING=1 +} + # Run libguestfs and mount the root and boot partitions. # Export `stateroot` and `deploydir` variables. coreos_gf_run_mount() { - coreos_gf_launch "$@" - coreos_gf run + coreos_gf_run "$@" local root root=$(coreos_gf findfs-label root) coreos_gf mount "${root}" / diff --git a/src/virt-install b/src/virt-install index 748c2e8018..26cb1b4a4f 100755 --- a/src/virt-install +++ b/src/virt-install @@ -228,7 +228,10 @@ try: run_sync_verbose(vinstall_args) # And strip out all of the Anaconda stuff in /var; this uses libguestfs # to ensure we fully control the code. - run_sync_verbose(['/usr/lib/coreos-assembler/gf-anaconda-cleanup', args.dest]) + cleanup_argv = ['/usr/lib/coreos-assembler/gf-anaconda-cleanup', args.dest] + if args.image_config is None: + cleanup_argv.append('--skip-partition-fixups') + run_sync_verbose(cleanup_argv) finally: subprocess.call(['virsh', '--connect=qemu:///session', 'undefine', domain]) if tail_proc is not None: