setup-disk fails when installing over identical previous installation
Hello,
while instaling in "sys" mode, setup-disk fails to install on top of an identical previous installation in most cases, the behaviour produces this output:
[...]
WARNING: Erase the above disk(s) and continue? (y/n) [n] y
Partition #1 contains a ext4 signature.
Partition #2 contains a swap signature.
Partition #3 contains a ext4 signature.
Creating file systems...
The file /dev/sda1 does not exist and no size was specified.
The file /dev/sda3 does not exist and no size was specified.
mount: mounting /dev/sda3 on /mnt failed: No such file or directory
Sometimes either /dev/sda1
or /dev/sda3
are recognized, rarely both, meaning that this operation fails the overwhelming majority of times.
Solution
As I had previously seen funky behaviour with sfdisk
when creating partitions on top of existing identical partitions, I remembered that the following consistently worked:
- Create new disklabel
- Create partitions (and optionally wipe signatures)
Doing both in one command as it is currently being done in line 848 of the script does not work reliably.
I suggest first running this to create the label:
echo "label: $DISKLABEL" | sfdisk --quiet $diskdev
Then modifying line 850 to look like this:
) sfdisk --quiet $diskdev
Even better would be this, to also wipe the previous signatures, otherwise you need to confirm overwriting the previous signatures again with the mkfs.$whatever commands:
) sfdisk --quiet -w always -W always $diskdev
Perhaps this is also needed in other places, I am not sure. I will submit a patch fixing this particular instance, please let me know if you have feedback!