# ZFS failure: How do I attach the disk with FreeBSD when booting from a pendrive?



## Sivan! (Oct 27, 2022)

A perfectly functioning 13.1, while there was not as much as a keyboard interrupt,  suddenly rebooted, and the boot process was stuck with "Mounting from ZFS:zroot/ROOT/default failed with error 2". I tried booting from multiboot, tried single user mode, tried kernel.old, the same error.

Found this solution in the forum from vermaden :




vermaden said:


> You need to 'regenerate' the /boot/zfs/zpool.cache file.
> 
> To do that, boot from FreeBSD live CD, then after attaching the GELI devices do:
> 
> ...



I downloaded 13.1 memstick.img, DDd that to a USB drive, ready to boot from the USB image. But how do I attach the GELI device? I don't have an encrypted disk, "?" from mountroot prompt shows:

List of GEOM managed disk devices:
gpt/zfs0 gpt/swap0 gpt/gptboot0 gpt/efiboot0 nvd0p4 nvd0p3 nvd0p2 nvd0

*When I boot from the USB, how do I attach any of these devices? *Which one? By what command syntax? Will it give me root prompt as below? Please help.

Thank you.


----------



## Alain De Vos (Oct 27, 2022)

The output of following commands can give guidance.

```
zpool import
zpool list -v
gpart show -p
```


----------



## Sivan! (Oct 27, 2022)

Alain De Vos Did that. Attaching a photo. Not sure what to do, given the error zroot FAULTED, and "no ppols available" Run `zpool imprt` with a -f flag?

Update: I ran the zpool command with the same syntax given by vermaden but may be I got the pool name wrong or the command parameters wrong. Attaching another screenshot








Thanks


----------



## Alain De Vos (Oct 27, 2022)

Without backup or mirror this looks very bad.
You could try

```
zpool import -f -o altroot=/mnt/zroot
zpool clear zroot
```
If that does not work you could try,

```
zpool clear nvd0p4
```
Have a look at the output of

```
zpool status -v
```


----------



## Sivan! (Oct 27, 2022)

Alain De Vos said:


> Without backup or mirror this looks very bad.
> You could try
> 
> ```
> ...


----------



## Alain De Vos (Oct 27, 2022)

Before "clear" or "status" it might be needed to "import" the pool with "force"

```
zpool import -f -o altroot=/mnt/zroot
```
If the import fails I don't know [ probably a broken disk leading to a broken filesystem]


----------



## Sivan! (Oct 27, 2022)

Alain De Vos Thank you.  I did that. "FAULTED. corrupted data. no such pool. no pools available. May be, just may be, this has something to do with the nvme not detected or mounted by the live cd?

Alain De Vos

`mount` shows:

/dev/ifs/FreeBSD_Install on / (ufs, local, noatime, *read-only)*

devfs on /dev (devfs)
tempfs on /tmp (tempfs, local)
temps on /var (temps, local)
#

`geom disk list`

Image attached


----------



## Alain De Vos (Oct 28, 2022)

To check if nvme module is already loaded,

```
kldload nvme
```


----------



## Sivan! (Oct 31, 2022)

Thank you Alain De Vos  When I try to boot from harddisk I get mountroot prompt.

From LIVECD root, `kldload nvme`
returns "can't load nvme, module already loaded" but `kldstat` doesn't show nvme.





Also wondering if something is amiss here. How would I find out if the hard disk boot process (not the LIVECD) loads kld nvme?  I can only get to mountroot or boot prompt. Root commands wouldn't work. 

LIVECD is read-only,  don't know how to try and mount nvme, nor do I know how to access and copy files.


----------

