Merge pull request #10 from nix-community/issue-9-support-parted-3.3

Support parted 3.3 exiting 1 on kernel inform failure
This commit is contained in:
Yt 2022-04-27 07:23:39 -04:00 committed by GitHub
commit 266f688176
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 21 deletions

View file

@ -59,9 +59,13 @@ mdadm --stop --scan
echo 'AUTO -all echo 'AUTO -all
ARRAY <ignore> UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf ARRAY <ignore> 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) # Create partition tables (--script to not ask)
parted --script /dev/sda mklabel gpt ./parted-ignoring-partprobe-error.sh --script /dev/sda mklabel gpt
parted --script /dev/sdb mklabel gpt ./parted-ignoring-partprobe-error.sh --script /dev/sdb mklabel gpt
# Create partitions (--script to not ask) # 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. # ... 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. # 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). # 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-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 --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/sdb -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%'
# Relaod partitions # Relaod partitions
partprobe partprobe

View file

@ -113,9 +113,13 @@ mdadm --stop --scan
echo 'AUTO -all echo 'AUTO -all
ARRAY <ignore> UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf ARRAY <ignore> 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) # Create partition tables (--script to not ask)
parted --script $DISK1 mklabel gpt ./parted-ignoring-partprobe-error.sh --script $DISK1 mklabel gpt
parted --script $DISK2 mklabel gpt ./parted-ignoring-partprobe-error.sh --script $DISK2 mklabel gpt
# Create partitions (--script to not ask) # Create partitions (--script to not ask)
# #
@ -135,12 +139,12 @@ parted --script $DISK2 mklabel gpt
# TODO the bios partition should not be this big # TODO the bios partition should not be this big
# however if it's less the installation fails with # 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 # 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 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on \
mkpart 'EFI-system-partition' 2MB 512MB set 2 esp on \ mkpart 'EFI-system-partition' 2MB 512MB set 2 esp on \
mkpart 'data-partition' 512MB '100%' 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 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on \
mkpart 'EFI-system-partition' 2MB 512MB set 2 esp on \ mkpart 'EFI-system-partition' 2MB 512MB set 2 esp on \
mkpart 'data-partition' 512MB '100%' mkpart 'data-partition' 512MB '100%'

View file

@ -61,9 +61,13 @@ mdadm --stop --scan
echo 'AUTO -all echo 'AUTO -all
ARRAY <ignore> UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf ARRAY <ignore> 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) # Create partition tables (--script to not ask)
parted --script /dev/sda mklabel gpt ./parted-ignoring-partprobe-error.sh /dev/sda mklabel gpt
parted --script /dev/sdb mklabel gpt ./parted-ignoring-partprobe-error.sh /dev/sdb mklabel gpt
# Create partitions (--script to not ask) # 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. # ... 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. # 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). # 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-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 --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/sdb -- mklabel gpt mkpart 'BIOS-boot-partition' 1MB 2MB set 1 bios_grub on mkpart 'data-partition' 2MB '100%'
# Relaod partitions # Relaod partitions
partprobe partprobe

View file

@ -57,12 +57,16 @@ set -e
# Stop all mdadm arrays that the boot may have activated. # Stop all mdadm arrays that the boot may have activated.
mdadm --stop --scan 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) # Create partition tables (--script to not ask)
parted --script /dev/sda mklabel gpt ./parted-ignoring-partprobe-error.sh --script /dev/sda mklabel gpt
parted --script /dev/sdb mklabel gpt ./parted-ignoring-partprobe-error.sh --script /dev/sdb mklabel gpt
parted --script /dev/sdc mklabel gpt ./parted-ignoring-partprobe-error.sh --script /dev/sdc mklabel gpt
parted --script /dev/sdd mklabel gpt ./parted-ignoring-partprobe-error.sh --script /dev/sdd mklabel gpt
parted --script /dev/nvme0n1 mklabel gpt ./parted-ignoring-partprobe-error.sh --script /dev/nvme0n1 mklabel gpt
# Create partitions (--script to not ask) # 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. # ... 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. # 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). # 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-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 --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/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-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 --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/sdd -- mklabel gpt mkpart 'ESP-partition3-unused' fat32 1MB 551MB set 1 esp off mkpart 'data-partition3' 551MB '100%'
# Relaod partitions # Relaod partitions
partprobe partprobe