helloSystem / ISO

helloSystem Live and installation ISO
https://github.com/helloSystem/
BSD 3-Clause "New" or "Revised" License
805 stars 59 forks source link

Installation stalls when trying to install onto a previously used disk #473

Closed probonopd closed 1 year ago

probonopd commented 1 year ago

helloSystem 0.8.1, installation stalls on the pulsating ("indeterminate") progress bar forever.

==> /tmp/bsdinstall_log <==
DEBUG: f_getvar: var=[nonInteractive] value=[YES] r=0
DEBUG: f_getvar: var=[zfsInteractive] value=[] r=1
DEBUG: BSDINSTALL_CHROOT=[/mnt]
DEBUG: BSDINSTALL_TMPETC=[/tmp/bsdinstall_etc]
DEBUG: FSTAB_FMT=[%s\t\t%s\t%s\t%s\t\t%s\t%s\n]
DEBUG: Checking zroot against zroot
DEBUG: Pool zroot already taken
DEBUG: f_dialog_max_size: dialog --print-maxsize = [MaxSize: 24, 80]
DEBUG: f_getvar: var=[height] value=[8] r=0
DEBUG: f_getvar: var=[width] value=[80] r=0

bsdinstall is quite flaky... and no, there is no pool with that name yet:

#  zpool import -D -f zroot
cannot import 'zroot': no such pool available
probonopd commented 1 year ago

The

DEBUG: Checking zroot against zroot
DEBUG: Pool zroot already taken

happens whenever there was previously a zpool with that name on the target disk. Even though the target disk has been formatted, e.g., like this:

sudo -A -E /sbin/gpart destroy -F /dev/ada0
sudo -A -E /sbin/gpart create -s GPT ada0
sudo -A -E /sbin/gpart add -t freebsd-ufs ada0
sudo -A -E newfs -L 'Ohne Titel' /dev/ada0
sudo -A -E /usr/local/sbin/automount ada0 attach

The only workaround I found is to overwrite the whole disk with zeros, which takes a lot of time. Another solution would be greatly preferred.

probonopd commented 1 year ago

Code in question seems to be:

https://github.com/freebsd/freebsd-src/blob/65308195e82487d82a1feace82686e5c45f88bd3/usr.sbin/bsdinstall/scripts/zfsboot#L1634-L1642

pools=$(zpool import | awk '$1 == "pool:" { print $2}')
for pool in ${pools}; do
    f_dprintf "Checking ${pool} against ${ZFSBOOT_POOL_NAME}"
    if [ "${pool}" = "${ZFSBOOT_POOL_NAME}" ]; then
        f_dprintf "Pool ${pool} already taken"
        ZFSBOOT_POOL_NAME=$(dialog_zpool_name "${ZFSBOOT_POOL_NAME}")
        break
    fi
done

And indeed. zpool import | awk '$1 == "pool:" { print $2}' returns zroot even though the disk has been formatted (but not overwritten with zeros) using the procedure described above.

So it sees zroot, lets me not create a new pool with the same name, but also refuses to destroy the old one:

% sudo su

# zpool import | awk '$1 == "pool:" { print $2}'
zroot

# zpool destroy zroot
cannot open 'zroot': no such pool

What gives?

How can I make it forget that there ever was a zpool on the target disk?

# zpool import
   pool: zroot
     id: 5046784991774597898
  state: UNAVAIL
status: One or more devices contains corrupted data.
 action: The pool cannot be imported due to damaged devices or data.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-5E
 config:

        zroot                               UNAVAIL  insufficient replicas
          diskid/DISK-AA000000000000002088  UNAVAIL  invalid label
probonopd commented 1 year ago
sudo zpool labelclear -f /dev/adaX