From 35adc676e14b23e7ed96d899101fa12705249141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Mon, 19 Jul 2021 03:43:48 +0200 Subject: [PATCH] Support parted 3.3 exiting 1 on kernel inform failure. Fixes #9 --- ...etzner-dedicated-wipe-and-install-nixos.sh | 12 ++++++---- .../hetzner-dedicated/zfs-uefi-nvme-nixos.sh | 12 ++++++---- ...aseweb-dedicated-wipe-and-install-nixos.sh | 12 ++++++---- .../ovh-dedicated-wipe-and-install-nixos.sh | 22 +++++++++++-------- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/hosters/hetzner-dedicated/hetzner-dedicated-wipe-and-install-nixos.sh b/hosters/hetzner-dedicated/hetzner-dedicated-wipe-and-install-nixos.sh index 27d2f6c..041274c 100644 --- a/hosters/hetzner-dedicated/hetzner-dedicated-wipe-and-install-nixos.sh +++ b/hosters/hetzner-dedicated/hetzner-dedicated-wipe-and-install-nixos.sh @@ -59,9 +59,13 @@ mdadm --stop --scan echo 'AUTO -all ARRAY UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf +# Create wrapper for parted >= 3.3 that does not exit 1 when it cannot inform +# the kernel of partitions changing (we use partprobe for that). +echo -e "#! /usr/bin/env bash\nset -e\n" 'parted $@ 2> parted-stderr.txt || grep "unable to inform the kernel of the change" parted-stderr.txt && echo "This is expected, continuing" || echo >&2 "Parted failed; stderr: $(< parted-stderr.txt)"' > parted-ignoring-partprobe-error.sh && chmod +x parted-ignoring-partprobe-error.sh + # Create partition tables (--script to not ask) -parted --script /dev/sda mklabel gpt -parted --script /dev/sdb mklabel gpt +./parted-ignoring-partprobe-error.sh --script /dev/sda mklabel gpt +./parted-ignoring-partprobe-error.sh --script /dev/sdb mklabel gpt # Create partitions (--script to not ask) # @@ -78,8 +82,8 @@ parted --script /dev/sdb mklabel gpt # ... part-type is one of 'primary', 'extended' or 'logical', and may be specified only with 'msdos' or 'dvh' partition tables. # A name must be specified for a 'gpt' partition table. # GPT partition names are limited to 36 UTF-16 chars, see https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries_(LBA_2-33). -parted --script --align optimal /dev/sda -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%' -parted --script --align optimal /dev/sdb -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%' +./parted-ignoring-partprobe-error.sh --script --align optimal /dev/sda -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%' +./parted-ignoring-partprobe-error.sh --script --align optimal /dev/sdb -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%' # Relaod partitions partprobe diff --git a/hosters/hetzner-dedicated/zfs-uefi-nvme-nixos.sh b/hosters/hetzner-dedicated/zfs-uefi-nvme-nixos.sh index 445369a..1b37031 100644 --- a/hosters/hetzner-dedicated/zfs-uefi-nvme-nixos.sh +++ b/hosters/hetzner-dedicated/zfs-uefi-nvme-nixos.sh @@ -113,9 +113,13 @@ mdadm --stop --scan echo 'AUTO -all ARRAY UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf +# Create wrapper for parted >= 3.3 that does not exit 1 when it cannot inform +# the kernel of partitions changing (we use partprobe for that). +echo -e "#! /usr/bin/env bash\nset -e\n" 'parted $@ 2> parted-stderr.txt || grep "unable to inform the kernel of the change" parted-stderr.txt && echo "This is expected, continuing" || echo >&2 "Parted failed; stderr: $(< parted-stderr.txt)"' > parted-ignoring-partprobe-error.sh && chmod +x parted-ignoring-partprobe-error.sh + # Create partition tables (--script to not ask) -parted --script $DISK1 mklabel gpt -parted --script $DISK2 mklabel gpt +./parted-ignoring-partprobe-error.sh --script $DISK1 mklabel gpt +./parted-ignoring-partprobe-error.sh --script $DISK2 mklabel gpt # Create partitions (--script to not ask) # @@ -135,12 +139,12 @@ parted --script $DISK2 mklabel gpt # TODO the bios partition should not be this big # however if it's less the installation fails with # cannot copy /nix/store/d4xbrrailkn179cdp90v4m57mqd73hvh-linux-5.4.100/bzImage to /boot/kernels/d4xbrrailkn179cdp90v4m57mqd73hvh-linux-5.4.100-bzImage.tmp: No space left on device -parted --script --align optimal $DISK1 -- mklabel gpt \ +./parted-ignoring-partprobe-error.sh --script --align optimal $DISK1 -- mklabel gpt \ mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on \ mkpart 'EFI-system-partition' 2MB 512MB set 2 esp on \ mkpart 'data-partition' 512MB '100%' -parted --script --align optimal $DISK2 -- mklabel gpt \ +./parted-ignoring-partprobe-error.sh --script --align optimal $DISK2 -- mklabel gpt \ mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on \ mkpart 'EFI-system-partition' 2MB 512MB set 2 esp on \ mkpart 'data-partition' 512MB '100%' diff --git a/hosters/leaseweb-dedicated/leaseweb-dedicated-wipe-and-install-nixos.sh b/hosters/leaseweb-dedicated/leaseweb-dedicated-wipe-and-install-nixos.sh index 2b621cc..cd845fe 100644 --- a/hosters/leaseweb-dedicated/leaseweb-dedicated-wipe-and-install-nixos.sh +++ b/hosters/leaseweb-dedicated/leaseweb-dedicated-wipe-and-install-nixos.sh @@ -61,9 +61,13 @@ mdadm --stop --scan echo 'AUTO -all ARRAY UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf +# Create wrapper for parted >= 3.3 that does not exit 1 when it cannot inform +# the kernel of partitions changing (we use partprobe for that). +echo -e "#! /usr/bin/env bash\nset -e\n" 'parted $@ 2> parted-stderr.txt || grep "unable to inform the kernel of the change" parted-stderr.txt && echo "This is expected, continuing" || echo >&2 "Parted failed; stderr: $(< parted-stderr.txt)"' > parted-ignoring-partprobe-error.sh && chmod +x parted-ignoring-partprobe-error.sh + # Create partition tables (--script to not ask) -parted --script /dev/sda mklabel gpt -parted --script /dev/sdb mklabel gpt +./parted-ignoring-partprobe-error.sh /dev/sda mklabel gpt +./parted-ignoring-partprobe-error.sh /dev/sdb mklabel gpt # Create partitions (--script to not ask) # @@ -80,8 +84,8 @@ parted --script /dev/sdb mklabel gpt # ... part-type is one of 'primary', 'extended' or 'logical', and may be specified only with 'msdos' or 'dvh' partition tables. # A name must be specified for a 'gpt' partition table. # GPT partition names are limited to 36 UTF-16 chars, see https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries_(LBA_2-33). -parted --script --align optimal /dev/sda -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%' -parted --script --align optimal /dev/sdb -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%' +./parted-ignoring-partprobe-error.sh --align optimal /dev/sda -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%' +./parted-ignoring-partprobe-error.sh --align optimal /dev/sdb -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%' # Relaod partitions partprobe diff --git a/hosters/ovh-dedicated/ovh-dedicated-wipe-and-install-nixos.sh b/hosters/ovh-dedicated/ovh-dedicated-wipe-and-install-nixos.sh index 9fbab40..080054e 100644 --- a/hosters/ovh-dedicated/ovh-dedicated-wipe-and-install-nixos.sh +++ b/hosters/ovh-dedicated/ovh-dedicated-wipe-and-install-nixos.sh @@ -57,12 +57,16 @@ set -e # Stop all mdadm arrays that the boot may have activated. mdadm --stop --scan +# Create wrapper for parted >= 3.3 that does not exit 1 when it cannot inform +# the kernel of partitions changing (we use partprobe for that). +echo -e "#! /usr/bin/env bash\nset -e\n" 'parted $@ 2> parted-stderr.txt || grep "unable to inform the kernel of the change" parted-stderr.txt && echo "This is expected, continuing" || echo >&2 "Parted failed; stderr: $(< parted-stderr.txt)"' > parted-ignoring-partprobe-error.sh && chmod +x parted-ignoring-partprobe-error.sh + # Create partition tables (--script to not ask) -parted --script /dev/sda mklabel gpt -parted --script /dev/sdb mklabel gpt -parted --script /dev/sdc mklabel gpt -parted --script /dev/sdd mklabel gpt -parted --script /dev/nvme0n1 mklabel gpt +./parted-ignoring-partprobe-error.sh --script /dev/sda mklabel gpt +./parted-ignoring-partprobe-error.sh --script /dev/sdb mklabel gpt +./parted-ignoring-partprobe-error.sh --script /dev/sdc mklabel gpt +./parted-ignoring-partprobe-error.sh --script /dev/sdd mklabel gpt +./parted-ignoring-partprobe-error.sh --script /dev/nvme0n1 mklabel gpt # Create partitions (--script to not ask) # @@ -84,10 +88,10 @@ parted --script /dev/nvme0n1 mklabel gpt # ... part-type is one of 'primary', 'extended' or 'logical', and may be specified only with 'msdos' or 'dvh' partition tables. # A name must be specified for a 'gpt' partition table. # GPT partition names are limited to 36 UTF-16 chars, see https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_entries_(LBA_2-33). -parted --script --align optimal /dev/sda -- mklabel gpt mkpart 'ESP-partition0' fat32 1MB 551MB set 1 esp on mkpart 'OS-partition0' 551MB 500GB mkpart 'data-partition0' 500GB '100%' -parted --script --align optimal /dev/sdb -- mklabel gpt mkpart 'ESP-partition1' fat32 1MB 551MB set 1 esp on mkpart 'OS-partition1' 551MB 500GB mkpart 'data-partition1' 500GB '100%' -parted --script --align optimal /dev/sdc -- mklabel gpt mkpart 'ESP-partition2-unused' fat32 1MB 551MB set 1 esp off mkpart 'data-partition2' 551MB '100%' -parted --script --align optimal /dev/sdd -- mklabel gpt mkpart 'ESP-partition3-unused' fat32 1MB 551MB set 1 esp off mkpart 'data-partition3' 551MB '100%' +./parted-ignoring-partprobe-error.sh --script --align optimal /dev/sda -- mklabel gpt mkpart 'ESP-partition0' fat32 1MB 551MB set 1 esp on mkpart 'OS-partition0' 551MB 500GB mkpart 'data-partition0' 500GB '100%' +./parted-ignoring-partprobe-error.sh --script --align optimal /dev/sdb -- mklabel gpt mkpart 'ESP-partition1' fat32 1MB 551MB set 1 esp on mkpart 'OS-partition1' 551MB 500GB mkpart 'data-partition1' 500GB '100%' +./parted-ignoring-partprobe-error.sh --script --align optimal /dev/sdc -- mklabel gpt mkpart 'ESP-partition2-unused' fat32 1MB 551MB set 1 esp off mkpart 'data-partition2' 551MB '100%' +./parted-ignoring-partprobe-error.sh --script --align optimal /dev/sdd -- mklabel gpt mkpart 'ESP-partition3-unused' fat32 1MB 551MB set 1 esp off mkpart 'data-partition3' 551MB '100%' # Relaod partitions partprobe