nix-community / nixos-install-scripts

collection of one-shot scripts to install NixOS on various server hosters and other hardware. [maintainer=@happysalada]
123 stars 68 forks source link

parted 3.3 sets exit code 1 when "unable to inform the kernel of the change" #9

Closed nh2 closed 2 years ago

nh2 commented 2 years ago

This is new in the current Hetzner rescue mode, aborting the script due to set -e:

root@rescue ~ # for diskletter in {a..b}; do parted --script --align optimal /dev/sd"$diskletter" -- mklabel gpt mkpart "BIOS-boot-partition-$diskletter" 1MiB 2MiB set 1 bios_grub on mkpart "OS-partition-$diskletter" 2MiB '100%'; done
Error: Partition(s) 2 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.
Error: Partition(s) 2 on /dev/sdb have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.
root@rescue ~ # echo $?
1
root@rescue ~ # parted --version
parted (GNU parted) 3.3

It's likely this:

https://git.savannah.gnu.org/cgit/parted.git/tree/NEWS?h=v3.3#n249

parted now exits nonzero for certain failures already diagnosed as "Error". For example, before this change, parted would exit successfully in spite of "Error: ...unrecognised disk label" and "Error:... both GPT primary and backup partition tables are corrupted".

We will have to disable set -e for that call, ideally grepping that the error is only the but we have been unable to inform the kernel of the change one.

nh2 commented 2 years ago

PR in #10, would appreciate others trying it out.