afaik the geli keys or on last sectors on the encrypted block device (disk,partition) and they are decrypted at run time with the passphprase
so if you dump the metadata, you can recover the size of the geli provider and by simple arithmetic deduce its start
then create a label and attach it
look in dmesg for the number of sectors of ada0
subtract 32 of that number and let the result be N
dd if=/dev/ada0 iseek=N of=somefile.out bs=4k
hexdump -Cv somefile.out and look for the geli magic string GEOM::ELI
at offset 30 you have the size of the provider (8 bytes little endian) in bytes
convert it to sectors
subtract it from ada0s1 size and you get its original offset, so you can recreate the label
ada0: 476490MB (976773168 512 byte sectors)
976773136
dd if=/dev/ada0 iseek=976773136 of=somefile.out bs=4kdd: /dev/ada0: Input/output error
dd if=/dev/diskid/DISK-J3310081H173EBs1 bs=512 count=2|hd to get that start of the partition. Also you can use zdb -l /dev/diskid/DISK-J3310081H173EBs1 to get the exact size of the partition. From top of my head I don't know if you can find the LBA of the partition from zdb or something similar ; if not you can search for it as mentioned above. I also wonder if /boot/zfs/zpool.cache can provide some information. zdb -l /dev/diskid/DISK-J3310081H173EBs1 is:------------------------------------
LABEL 0
------------------------------------
version: 5000
name: 'bootpool'
state: 0
txg: 28240385
pool_guid: 17749244303695315483
errata: 0
hostname: ''
top_guid: 5973502406743286860
guid: 5973502406743286860
vdev_children: 1
vdev_tree:
type: 'disk'
id: 0
guid: 5973502406743286860
path: '/dev/diskid/DISK-J3310081H173EBs1'
phys_path: '/dev/ada0s1a'
whole_disk: 1
metaslab_array: 34
metaslab_shift: 24
ashift: 12
asize: 2142765056
is_log: 0
DTL: 162
create_txg: 4
features_for_read:
com.delphix:hole_birth
com.delphix:embedded_data
labels = 0 1 2 3
# dd if=/dev/diskid/DISK-J3310081H173EBs1 bs=512 skip=976773080 | hd | less and this is the result:Then ignore my previous post regarding manual creation of bsdlabel as it was based on your first post (2G Bootpool, 2G swap, rest)Regarding the order in which I could see with the partitions withgpartit was:
1. bootpool (2G)
2. main zpool (zroot)
3. swap partition (2G)
gnop create -o 6442483712 -s 493665370112 ada0. Last sector was checked with dd if=/dev/ada0.nop bs=512 count=1 skip=964190175 |hd to match the GEOM::ELI header. All OK. geli was failing though.Cannot access ada0.nop (error=1). truss output:
openat(AT_FDCWD,"/dev/geom.ctl",O_RDONLY,00) = 3 (0x3)
ioctl(3,GEOM_CTL,0x800a0f0c0) ERR#22 'Invalid argument'
close(3) = 0 (0x0)
sysctl kern.geom.nop.debug=2 but nothing obvious showed up.geli attach -k /path/to/key/from/bootpool /dev/ada0.nop did the trick. Apparently pools were updated to newer versions so only ro mode was possible; enough for a full data recovery. Pool was imported with zpool import -o readonly=on -R /tmp/oldsys zroot (sidenote: I just hate that FreeBSD calls rpool zroot)zdb -U /path/to/zpool.cache can be used to check the contents of the cache file. geli made this a bit easier as it saves its size in the metadata (size of the geli provider is bigger than zroot's asize).