ZFS How to mount / map a zfs partition with mdconfig

Hello.

I've mapped into the memory my image file with the mdconfig command like this :

Code:
# mdconfig -a -t vnode -f FreeBSD-15-xen.img -u 0

as you can see below all the partitions inside the image file have been mapped correctly inside the memory :

Code:
=> 40 419430320 md0 GPT (200G)
        40     532480    1  efi  (260M)     532520
      1024    2  freebsd-boot  (512K)     533544
       984       - free -  (492K)     534528
   4194304    3  freebsd-swap  (2.0G)    4728832
 414699520    4  freebsd-zfs  (198G)  419428352
      2008       - free -  (1.0M)

they are present even in /dev :

Code:
# ls /dev/md0*

/dev/md0       /dev/md0p1      /dev/md0p2 
/dev/md0p3     /dev/md0p4

now,what I want to do is to mount the md0p4 / zfs partition. The most obvious command to try is :

Code:
# mount -t zfs /dev/md0p4 ./FreeBSD-15-xen

but it didn't work :

Code:
mount: /dev/md0p4: Invalid fstype: Invalid argument

or :

Code:
# mount /dev/md0p4 ./FreeBSD-15-xen
mount: /dev/md0p4: Invalid fstype: Invalid argument

if I do :

Code:
# zfs list

the md0 disk is not in the list :

Code:
# zfs list

NAME                                                                 USED  AVAIL     REFER  MOUNTPOINT
zroot                                                                425G  20.9G       96K  /zroot
zroot/ROOT                                                           345G  20.9G       96K  none
zroot/ROOT/13.1-RELEASE-p5_2023-01-12_235731                         268M  20.9G      136G  /
zroot/ROOT/13.1-RELEASE-p5_2023-01-20_181957                         344G  20.9G      292G  /
zroot/ROOT/13.1-RELEASE-p5_2023-01-20_181957@2023-01-20-18:19:57-0  52.1G      -      140G  -
zroot/tmp                                                            198M  20.9G      198M  /tmp
zroot/usr                                                           77.5G  20.9G      120K  /usr
zroot/usr/home                                                      63.3G  20.9G     63.3G  /usr/home
zroot/usr/ports                                                     14.2G  20.9G     14.2G  /usr/ports
zroot/usr/src-old                                                     96K  20.9G       96K  /usr/src-old
zroot/var                                                           2.46G  20.9G      136K  /var
zroot/var/audit                                                       96K  20.9G       96K  /var/audit
zroot/var/crash                                                     1.11G  20.9G     1.11G  /var/crash
zroot/var/log                                                       4.73M  20.9G     4.73M  /var/log
zroot/var/mail                                                      1.33G  20.9G     1.33G  /var/mail
zroot/var/tmp                                                       18.1M  20.9G     18.1M  /var/tmp
zroot2                                                               468G   431G      468G  /mnt/zroot2/zroot2
zroot2/ROOT                                                          288K   431G       96K  none
zroot2/ROOT/default                                                  192K   431G      192K  /mnt/zroot2
zroot2/tmp                                                           148K   431G      148K  /mnt/zroot2/tmp
zroot2/usr                                                           384K   431G       96K  /mnt/zroot2/usr
zroot2/usr/home                                                       96K   431G       96K  /mnt/zroot2/usr/home
zroot2/usr/ports                                                      96K   431G       96K  /mnt/zroot2/usr/ports
zroot2/usr/src                                                        96K   431G       96K  /mnt/zroot2/usr/src
zroot2/var                                                          3.71M   431G       96K  /mnt/zroot2/var
zroot2/var/audit                                                      96K   431G       96K  /mnt/zroot2/var/audit
zroot2/var/crash                                                    2.74M   431G     2.74M  /mnt/zroot2/var/crash
zroot2/var/log                                                       588K   431G      588K  /mnt/zroot2/var/log
zroot2/var/mail                                                       96K   431G       96K  /mnt/zroot2/var/mail
zroot2/var/tmp                                                       120K   431G      120K  /mnt/zroot2/var/tmp

How to do that ?
 
Code:
# zpool import

pool: zroot id: 11154659067869287794 state: 
ONLINE action: The pool can be imported using 
its name or numeric identifier. config:

    zroot     ONLINE
    md0p4     ONLINE

# zpool import 11154659067869287794 

cannot import 'zroot': pool was previously in 
use from another system. Last accessed by 
<unknown> (hostid=0) at Mon Jan 23 19:12:06 
2023 The pool can be imported, use 'zpool 
import -f' to import the pool.

# zpool import -o altroot=/newpool 
11154659067869287794 newpool

cannot import 'zroot': pool was previously in
use from another system.
Last accessed by <unknown> (hostid=0) at Mon 
Jan 23 19:12:06 2023 The pool can be imported,
 use 'zpool import -f' to import the pool.

# zpool import -f

  pool: zroot     id: 11154659067869287794 
 state: ONLINE action: The pool can be 
imported using its name or numeric identifier.
config:

      zroot     ONLINE
      md0p4     ONLINE

# zpool list

NAME     SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT

zroot    460G   425G  35.1G        -         -    54%    92%  1.00x    ONLINE  -
zroot2   928G   468G   460G        -         -    18%    50%  1.00x    ONLINE  /mnt/zroot2
 
You should be able to export zroot from the md device, but keep in mind that the zroot pool is already existing. On the other hand, it has another zpool called zroot2 that is hosted in /mnt.

This is an example:

mkdir -p /mnt2
zpool import -R /mnt2 11154659067869287794 newpool


Could you add the -f import option, I understand that it is practically the same as what you added in your last publication, what are the results?
 
I'm not able to boot my primary FreeBSD installation that's on the disk sda :

Code:
Disk /dev/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: CT500MX500SSD4  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: C4E17451-AE72-11EC-9419-E0D55EE21F22

Device       Start       End   Sectors   Size Type
/dev/sda1       40    532519    532480   260M EFI System
/dev/sda2   532520    533543      1024   512K FreeBSD boot
/dev/sda3   534528   4728831   4194304     2G FreeBSD swap
/dev/sda4  4728832 976773119 972044288 463.5G FreeBSD ZFS

I suspect that the reason is because I set canmount=on everywhere :

Code:
# zfs get -r canmount zroot

NAME                                                                PROPERTY  VALUE     SOURCE
zroot                                                               canmount  on        local
zroot/ROOT                                                          canmount  on        local
zroot/ROOT/13.1-RELEASE-p5_2023-01-12_235731                        canmount  on        local
zroot/ROOT/13.1-RELEASE-p5_2023-01-20_181957                        canmount  on        local
zroot/ROOT/13.1-RELEASE-p5_2023-01-20_181957@2023-01-20-18:19:57-0  canmount  -         -
zroot/tmp                                                           canmount  on        default
zroot/usr                                                           canmount  on        local
zroot/usr/home                                                      canmount  on        default
zroot/usr/ports                                                     canmount  on        default
zroot/usr/src-old                                                   canmount  on        default
zroot/var                                                           canmount  on        local
zroot/var/audit                                                     canmount  on        local
zroot/var/crash                                                     canmount  on        local
zroot/var/log                                                       canmount  on        local
zroot/var/mail                                                      canmount  on        local
zroot/var/tmp                                                       canmount  on        local

can you tell me what are the correct values ? I know that on some "node" should be configured with canmount=off or auto.
 
Code:
#zfs get canmount
NAME                                          PROPERTY  VALUE     SOURCE
zroot                                         canmount  on        default
zroot/ROOT                                    canmount  on        default
zroot/ROOT/13.1                               canmount  noauto    local
zroot/ROOT/13.1-RELEASE-p2_2023-11-27_121646  canmount  noauto    local
zroot/ROOT/13.2p5                             canmount  noauto    local
zroot/ROOT/13.2p5@2022-09-01-22:40:35-0       canmount  -         -
zroot/ROOT/13.2p5@2023-11-27-12:16:46-0       canmount  -         -
zroot/ROOT/13.2p5@2023-11-27-12:17:56-0       canmount  -         -
zroot/ROOT/default                            canmount  noauto    local
zroot/tmp                                     canmount  on        default
zroot/usr                                     canmount  off       local
zroot/usr/home                                canmount  on        default
zroot/usr/ports                               canmount  on        default
zroot/usr/src                                 canmount  on        default
zroot/var                                     canmount  off       local
zroot/var/audit                               canmount  on        default
zroot/var/crash                               canmount  on        default
zroot/var/log                                 canmount  on        default
zroot/var/mail                                canmount  on        default
zroot/var/tmp                                 canmount  on        default
 
Let's forget the previous problem. Now I have another problem to fix. I don't know what I did to pass from the old to the new problem. And since they seem to be different,I think that's a good idea to create a new post.
 
Here is the history of my zpool, in case it can help you recreate the entire set.

History for 'zroot':
2022-12-12.01:18:13 zpool create -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f zroot ada0p3
2022-12-12.01:18:13 zfs create -o mountpoint=none zroot/ROOT
2022-12-12.01:18:13 zfs create -o mountpoint=/ zroot/ROOT/default
2022-12-12.01:18:13 zfs create -o mountpoint=/home zroot/home
2022-12-12.01:18:13 zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zroot/tmp
2022-12-12.01:18:13 zfs create -o mountpoint=/usr -o canmount=off zroot/usr
2022-12-12.01:18:13 zfs create -o setuid=off zroot/usr/ports
2022-12-12.01:18:13 zfs create zroot/usr/src
2022-12-12.01:18:14 zfs create -o mountpoint=/var -o canmount=off zroot/var
2022-12-12.01:18:14 zfs create -o exec=off -o setuid=off zroot/var/audit
2022-12-12.01:18:14 zfs create -o exec=off -o setuid=off zroot/var/crash
2022-12-12.01:18:14 zfs create -o exec=off -o setuid=off zroot/var/log
2022-12-12.01:18:14 zfs create -o atime=on zroot/var/mail
2022-12-12.01:18:14 zfs create -o setuid=off zroot/var/tmp
2022-12-12.01:18:14 zfs set mountpoint=/zroot zroot
2022-12-12.01:18:14 zpool set bootfs=zroot/ROOT/default zroot
2022-12-12.01:18:14 zpool set cachefile=/mnt/boot/zfs/zpool.cache zroot
2022-12-12.01:18:15 zfs set canmount=noauto zroot/ROOT/default
 
 
Back
Top